lib/open_xchange_client/api/clientonboarding.ex

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

  alias OpenXchangeClient.Connection
  import OpenXchangeClient.RequestBuilder

  @doc """
  Direct-downloads a profile to configure an apple device for CalDAV and/or CardDAV

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - type (String.t): The identifier of profile to download; one of - caldav - carddav - dav
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, String.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec download_client_onboarding_profile(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
          {:ok, String.t()} | {:error, Tesla.Env.t()}
  def download_client_onboarding_profile(connection, session, type, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/onboarding?action=download")
    |> add_param(:query, :session, session)
    |> add_param(:query, :type, type)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, false}
    ])
  end

  @doc """
  Performs a certain client on-boarding action for a given device and scenario; e.g. download a profile or send an E-Mail/SMS

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - id (String.t): The compiste identifier of device and scenario pair; e.g. \"apple.iphone/davsync\"
  - action_id (String.t): The identifier of action to perform; one of - download - email - sms - display or - link
  - opts (KeywordList): [optional] Optional parameters
    - :body (String.t): An optional JSON object containing additional data for the action.
  ## Returns

  {:ok, OpenXchangeClient.Model.CommonResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec execute_client_onboarding(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          String.t(),
          keyword()
        ) :: {:ok, OpenXchangeClient.Model.CommonResponse.t()} | {:error, Tesla.Env.t()}
  def execute_client_onboarding(connection, session, id, action_id, opts \\ []) do
    optional_params = %{
      :body => :body
    }

    %{}
    |> method(:put)
    |> url("/onboarding?action=execute")
    |> add_param(:query, :session, session)
    |> add_param(:query, :id, id)
    |> add_param(:query, :action_id, action_id)
    |> add_optional_params(optional_params, opts)
    |> ensure_body()
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, %OpenXchangeClient.Model.CommonResponse{}}
    ])
  end

  @doc """
  Generate link to direct-download a profile to configure an apple device for CalDAV and/or CardDAV

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - type (String.t): The identifier of profile to download; one of - caldav - carddav - dav
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, String.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec generate_download_link_for_client_onboarding_profile(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          keyword()
        ) :: {:ok, String.t()} | {:error, Tesla.Env.t()}
  def generate_download_link_for_client_onboarding_profile(connection, session, type, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/onboarding?action=link")
    |> add_param(:query, :session, session)
    |> add_param(:query, :type, type)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, false}
    ])
  end

  @doc """
  Retrieves the configuration providing available client on-boarding possibilities for session-associated user

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, OpenXchangeClient.Model.ClientOnboardingResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_client_onboarding_config(Tesla.Env.client(), String.t(), keyword()) ::
          {:ok, OpenXchangeClient.Model.ClientOnboardingResponse.t()} | {:error, Tesla.Env.t()}
  def get_client_onboarding_config(connection, session, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/onboarding?action=config")
    |> add_param(:query, :session, session)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, %OpenXchangeClient.Model.ClientOnboardingResponse{}}
    ])
  end
end