# NOTE: This file is auto generated by OpenAPI Generator 7.1.0 (https://openapi-generator.tech). # Do not edit this file manually. defmodule MBTA.Api.Service do @moduledoc """ API calls for all endpoints tagged `Service`. """ alias MBTA.Connection import MBTA.RequestBuilder @doc """ List of services. Service represents the days of the week, as well as extra days, that a trip is valid. ### Parameters - `connection` (MBTA.Connection): Connection to server - `opts` (keyword): Optional parameters - `:"page[offset]"` (integer()): Offset (0-based) of first element in the page - `:"page[limit]"` (integer()): Max number of elements to return - `:sort` (String.t): Results can be [sorted](http://jsonapi.org/format/#fetching-sorting) by the id or any `/data/{index}/attributes` key. Assumes ascending; may be prefixed with '-' for descending | JSON pointer | Direction | `sort` | |--------------|-----------|------------| | `/data/{index}/attributes/added_dates` | ascending | `added_dates` | | `/data/{index}/attributes/added_dates` | descending | `-added_dates` | | `/data/{index}/attributes/added_dates_notes` | ascending | `added_dates_notes` | | `/data/{index}/attributes/added_dates_notes` | descending | `-added_dates_notes` | | `/data/{index}/attributes/description` | ascending | `description` | | `/data/{index}/attributes/description` | descending | `-description` | | `/data/{index}/attributes/end_date` | ascending | `end_date` | | `/data/{index}/attributes/end_date` | descending | `-end_date` | | `/data/{index}/attributes/rating_description` | ascending | `rating_description` | | `/data/{index}/attributes/rating_description` | descending | `-rating_description` | | `/data/{index}/attributes/rating_end_date` | ascending | `rating_end_date` | | `/data/{index}/attributes/rating_end_date` | descending | `-rating_end_date` | | `/data/{index}/attributes/rating_start_date` | ascending | `rating_start_date` | | `/data/{index}/attributes/rating_start_date` | descending | `-rating_start_date` | | `/data/{index}/attributes/removed_dates` | ascending | `removed_dates` | | `/data/{index}/attributes/removed_dates` | descending | `-removed_dates` | | `/data/{index}/attributes/removed_dates_notes` | ascending | `removed_dates_notes` | | `/data/{index}/attributes/removed_dates_notes` | descending | `-removed_dates_notes` | | `/data/{index}/attributes/schedule_name` | ascending | `schedule_name` | | `/data/{index}/attributes/schedule_name` | descending | `-schedule_name` | | `/data/{index}/attributes/schedule_type` | ascending | `schedule_type` | | `/data/{index}/attributes/schedule_type` | descending | `-schedule_type` | | `/data/{index}/attributes/schedule_typicality` | ascending | `schedule_typicality` | | `/data/{index}/attributes/schedule_typicality` | descending | `-schedule_typicality` | | `/data/{index}/attributes/start_date` | ascending | `start_date` | | `/data/{index}/attributes/start_date` | descending | `-start_date` | | `/data/{index}/attributes/valid_days` | ascending | `valid_days` | | `/data/{index}/attributes/valid_days` | descending | `-valid_days` | - `:"fields[service]"` (String.t): Fields to include with the response. Multiple fields **MUST** be a comma-separated (U+002C COMMA, \",\") list. Note that fields can also be selected for included data types: see the [V3 API Best Practices](https://www.mbta.com/developers/v3-api/best-practices) for an example. - `:"filter[id]"` (String.t): Filter by multiple IDs. **MUST** be a comma-separated (U+002C COMMA, \",\") list. - `:"filter[route]"` (String.t): Filter by route. Multiple `route` **MUST** be a comma-separated (U+002C COMMA, \",\") list. ### Returns - `{:ok, MBTA.Model.Services.t}` on success - `{:error, Tesla.Env.t}` on failure """ @spec api_web_service_controller_index(Tesla.Env.client, keyword()) :: {:ok, MBTA.Model.Forbidden.t} | {:ok, MBTA.Model.TooManyRequests.t} | {:ok, MBTA.Model.Services.t} | {:ok, MBTA.Model.BadRequest.t} | {:error, Tesla.Env.t} def api_web_service_controller_index(connection, opts \\ []) do optional_params = %{ :"page[offset]" => :query, :"page[limit]" => :query, :sort => :query, :"fields[service]" => :query, :"filter[id]" => :query, :"filter[route]" => :query } request = %{} |> method(:get) |> url("/services") |> add_optional_params(optional_params, opts) |> Enum.into([]) connection |> Connection.request(request) |> evaluate_response([ {429, MBTA.Model.TooManyRequests}, {403, MBTA.Model.Forbidden}, {400, MBTA.Model.BadRequest}, {200, MBTA.Model.Services} ]) end @doc """ Single service, which represents the days of the week, as well as extra days, that a trip is valid. ### Parameters - `connection` (MBTA.Connection): Connection to server - `id` (String.t): Unique identifier for a service - `opts` (keyword): Optional parameters - `:"fields[service]"` (String.t): Fields to include with the response. Multiple fields **MUST** be a comma-separated (U+002C COMMA, \",\") list. Note that fields can also be selected for included data types: see the [V3 API Best Practices](https://www.mbta.com/developers/v3-api/best-practices) for an example. ### Returns - `{:ok, MBTA.Model.Service.t}` on success - `{:error, Tesla.Env.t}` on failure """ @spec api_web_service_controller_show(Tesla.Env.client, String.t, keyword()) :: {:ok, MBTA.Model.Service.t} | {:ok, MBTA.Model.NotAcceptable.t} | {:ok, MBTA.Model.Forbidden.t} | {:ok, MBTA.Model.TooManyRequests.t} | {:ok, MBTA.Model.NotFound.t} | {:error, Tesla.Env.t} def api_web_service_controller_show(connection, id, opts \\ []) do optional_params = %{ :"fields[service]" => :query } request = %{} |> method(:get) |> url("/services/#{id}") |> add_optional_params(optional_params, opts) |> Enum.into([]) connection |> Connection.request(request) |> evaluate_response([ {429, MBTA.Model.TooManyRequests}, {406, MBTA.Model.NotAcceptable}, {404, MBTA.Model.NotFound}, {403, MBTA.Model.Forbidden}, {200, MBTA.Model.Service} ]) end end