lib/spatio/api/notifications.ex

# NOTE: This file is auto generated by OpenAPI Generator 7.22.0 (https://openapi-generator.tech).
# Do not edit this file manually.

defmodule Spatio.Api.Notifications do
  @moduledoc """
  API calls for all endpoints tagged `Notifications`.
  """

  alias Spatio.Connection
  import Spatio.RequestBuilder

  @doc """
  Read the caller's notification preferences.

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, %{}}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec get_notification_preferences(Tesla.Env.client, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def get_notification_preferences(connection, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/notifications/preferences")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, %{}},
      {401, Spatio.Model.ApiError}
    ])
  end

  @doc """
  Update notification preferences.

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `request_body` (%{optional(String.t) => any()}): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, %{}}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec update_notification_preferences(Tesla.Env.client, %{optional(String.t) => any()}, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def update_notification_preferences(connection, request_body, _opts \\ []) do
    request =
      %{}
      |> method(:patch)
      |> url("/v1/notifications/preferences")
      |> add_param(:body, :body, request_body)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, %{}},
      {401, Spatio.Model.ApiError}
    ])
  end
end