lib/mail_slurp_api/api/domain_controller.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 MailSlurpAPI.Api.DomainController do
  @moduledoc """
  API calls for all endpoints tagged `DomainController`.
  """

  alias MailSlurpAPI.Connection
  import MailSlurpAPI.RequestBuilder


  @doc """
  Add catch all wild card inbox to domain
  Add a catch all inbox to a domain so that any emails sent to it that cannot be matched will be sent to the catch all inbox generated

  ## Parameters

  - connection (MailSlurpAPI.Connection): Connection to server
  - id (String.t): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, %MailSlurpAPI.Model.DomainDto{}} on success
  {:error, info} on failure
  """
  @spec add_domain_wildcard_catch_all(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.DomainDto.t} | {:error, Tesla.Env.t}
  def add_domain_wildcard_catch_all(connection, id, _opts \\ []) do
    %{}
    |> method(:post)
    |> url("/domains/#{id}/wildcard")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, %MailSlurpAPI.Model.DomainDto{}}
    ])
  end

  @doc """
  Create Domain
  Link a domain that you own with MailSlurp so you can create email addresses using it. Endpoint returns DNS records used for validation. You must add these verification records to your host provider's DNS setup to verify the domain.

  ## Parameters

  - connection (MailSlurpAPI.Connection): Connection to server
  - create_domain_options (CreateDomainOptions): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, %MailSlurpAPI.Model.DomainDto{}} on success
  {:error, info} on failure
  """
  @spec create_domain(Tesla.Env.client, MailSlurpAPI.Model.CreateDomainOptions.t, keyword()) :: {:ok, MailSlurpAPI.Model.DomainDto.t} | {:error, Tesla.Env.t}
  def create_domain(connection, create_domain_options, _opts \\ []) do
    %{}
    |> method(:post)
    |> url("/domains")
    |> add_param(:body, :body, create_domain_options)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 201, %MailSlurpAPI.Model.DomainDto{}}
    ])
  end

  @doc """
  Delete a domain
  Delete a domain. This will disable any existing inboxes that use this domain.

  ## Parameters

  - connection (MailSlurpAPI.Connection): Connection to server
  - id (String.t): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, [%String{}, ...]} on success
  {:error, info} on failure
  """
  @spec delete_domain(Tesla.Env.client, String.t, keyword()) :: {:ok, list(String.t)} | {:error, Tesla.Env.t}
  def delete_domain(connection, id, _opts \\ []) do
    %{}
    |> method(:delete)
    |> url("/domains/#{id}")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 204, []}
    ])
  end

  @doc """
  Get a domain
  Returns domain verification status and tokens for a given domain

  ## Parameters

  - connection (MailSlurpAPI.Connection): Connection to server
  - id (String.t): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, %MailSlurpAPI.Model.DomainDto{}} on success
  {:error, info} on failure
  """
  @spec get_domain(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.DomainDto.t} | {:error, Tesla.Env.t}
  def get_domain(connection, id, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/domains/#{id}")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, %MailSlurpAPI.Model.DomainDto{}}
    ])
  end

  @doc """
  Get domains
  List all custom domains you have created

  ## Parameters

  - connection (MailSlurpAPI.Connection): Connection to server
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, [%DomainPreview{}, ...]} on success
  {:error, info} on failure
  """
  @spec get_domains(Tesla.Env.client, keyword()) :: {:ok, list(MailSlurpAPI.Model.DomainPreview.t)} | {:error, Tesla.Env.t}
  def get_domains(connection, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/domains")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, [%MailSlurpAPI.Model.DomainPreview{}]}
    ])
  end

  @doc """
  Update a domain
  Update values on a domain. Note you cannot change the domain name as it is immutable. Recreate the domain if you need to alter this.

  ## Parameters

  - connection (MailSlurpAPI.Connection): Connection to server
  - id (String.t): 
  - update_domain_options (UpdateDomainOptions): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, %MailSlurpAPI.Model.DomainDto{}} on success
  {:error, info} on failure
  """
  @spec update_domain(Tesla.Env.client, String.t, MailSlurpAPI.Model.UpdateDomainOptions.t, keyword()) :: {:ok, MailSlurpAPI.Model.DomainDto.t} | {:error, Tesla.Env.t}
  def update_domain(connection, id, update_domain_options, _opts \\ []) do
    %{}
    |> method(:put)
    |> url("/domains/#{id}")
    |> add_param(:body, :body, update_domain_options)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, %MailSlurpAPI.Model.DomainDto{}}
    ])
  end
end