# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# https://openapi-generator.tech
# Do not edit the class manually.
defmodule OpenXchangeClient.Api.Pns do
@moduledoc """
API calls for all endpoints tagged `Pns`.
"""
alias OpenXchangeClient.Connection
import OpenXchangeClient.RequestBuilder
@doc """
Adds a new subscription associated with a token for certain topics
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- token (String.t): The token to use when sending out notifications using specified transport
- transport (String.t): The identifer of the transport; currently supported: - \\\"apn\\\" - \\\"gcm\\\" - \\\"wns\\\" and - \\\"websocket\\\"
- topics ([String.t]): An array of topic identifiers or wild-cards, to which the subscription signals interest. E.g. [\\\"ox:mail:*\\\",\\\"ox:calendar:new\\\"] interest for all mail-related events and for newly created appointments
- opts (KeywordList): [optional] Optional parameters
- :client (String.t): The client identifier; e.g. \\\"open-xchange-appsuite\\\". If not specified, session-associated client identifier is considered
## Returns
{:ok, OpenXchangeClient.Model.PnsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec subscribe(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
list(String.t()),
keyword()
) :: {:ok, OpenXchangeClient.Model.PnsResponse.t()} | {:error, Tesla.Env.t()}
def subscribe(connection, session, token, transport, topics, opts \\ []) do
optional_params = %{
:client => :form
}
%{}
|> method(:put)
|> url("/pns?action=subscribe")
|> add_param(:query, :session, session)
|> add_param(:form, :token, token)
|> add_param(:form, :transport, transport)
|> add_param(:form, :topics, topics)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.PnsResponse{}}
])
end
@doc """
Removes a subscription associated with a token for certain topics
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- token (String.t): The token to use when sending out notifications using specified transport
- transport (String.t): The identifer of the transport; currently supported: - \\\"apn\\\" - \\\"gcm\\\" - \\\"wns\\\" and - \\\"websocket\\\"
- opts (KeywordList): [optional] Optional parameters
- :client (String.t): The client identifier; e.g. \\\"open-xchange-appsuite\\\". If not specified, session-associated client identifier is considered
## Returns
{:ok, OpenXchangeClient.Model.PnsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec unsubscribe(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.PnsResponse.t()} | {:error, Tesla.Env.t()}
def unsubscribe(connection, session, token, transport, opts \\ []) do
optional_params = %{
:client => :form
}
%{}
|> method(:put)
|> url("/pns?action=unsubscribe")
|> add_param(:query, :session, session)
|> add_param(:form, :token, token)
|> add_param(:form, :transport, transport)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.PnsResponse{}}
])
end
end