lib/mbta/api/live_facility.ex

# 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.LiveFacility do
  @moduledoc """
  API calls for all endpoints tagged `LiveFacility`.
  """

  alias MBTA.Connection
  import MBTA.RequestBuilder

  @doc """
  Live Facility Data  Live data about a given facility.  

  ### 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/properties` | ascending | `properties` | | `/data/{index}/attributes/properties` | descending | `-properties` | | `/data/{index}/attributes/updated_at` | ascending | `updated_at` | | `/data/{index}/attributes/updated_at` | descending | `-updated_at` |  
    - `:include` (String.t): Relationships to include.  * `facility`  The value of the include parameter **MUST** be a comma-separated (U+002C COMMA, \",\") list of relationship paths. A relationship path is a dot-separated (U+002E FULL-STOP, \".\") list of relationship names. [JSONAPI \"include\" behavior](http://jsonapi.org/format/#fetching-includes)   
    - `:"filter[id]"` (String.t): Filter by multiple parking facility ids. **MUST** be a comma-separated (U+002C COMMA, \",\") list.

  ### Returns

  - `{:ok, MBTA.Model.LiveFacility.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec api_web_live_facility_controller_index(Tesla.Env.client, keyword()) :: {:ok, MBTA.Model.Forbidden.t} | {:ok, MBTA.Model.TooManyRequests.t} | {:ok, MBTA.Model.LiveFacility.t} | {:ok, MBTA.Model.BadRequest.t} | {:error, Tesla.Env.t}
  def api_web_live_facility_controller_index(connection, opts \\ []) do
    optional_params = %{
      :"page[offset]" => :query,
      :"page[limit]" => :query,
      :sort => :query,
      :include => :query,
      :"filter[id]" => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/live_facilities")
      |> 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.LiveFacility}
    ])
  end

  @doc """
  List live parking data for specific parking facility  Live data about a given facility.  

  ### Parameters

  - `connection` (MBTA.Connection): Connection to server
  - `id` (String.t): Unique identifier for facility
  - `opts` (keyword): Optional parameters
    - `:include` (String.t): Relationships to include.  * `facility`  The value of the include parameter **MUST** be a comma-separated (U+002C COMMA, \",\") list of relationship paths. A relationship path is a dot-separated (U+002E FULL-STOP, \".\") list of relationship names. [JSONAPI \"include\" behavior](http://jsonapi.org/format/#fetching-includes)   

  ### Returns

  - `{:ok, MBTA.Model.LiveFacility.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec api_web_live_facility_controller_show(Tesla.Env.client, String.t, keyword()) :: {:ok, MBTA.Model.NotAcceptable.t} | {:ok, MBTA.Model.Forbidden.t} | {:ok, MBTA.Model.TooManyRequests.t} | {:ok, MBTA.Model.NotFound.t} | {:ok, MBTA.Model.LiveFacility.t} | {:error, Tesla.Env.t}
  def api_web_live_facility_controller_show(connection, id, opts \\ []) do
    optional_params = %{
      :include => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/live_facilities/#{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.LiveFacility}
    ])
  end
end