# 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.ContactController do
@moduledoc """
API calls for all endpoints tagged `ContactController`.
"""
alias MailSlurpAPI.Connection
import MailSlurpAPI.RequestBuilder
@doc """
Create a contact
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- create_contact_options (CreateContactOptions):
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.ContactDto{}} on success
{:error, info} on failure
"""
@spec create_contact(Tesla.Env.client, MailSlurpAPI.Model.CreateContactOptions.t, keyword()) :: {:ok, MailSlurpAPI.Model.ContactDto.t} | {:error, Tesla.Env.t}
def create_contact(connection, create_contact_options, _opts \\ []) do
%{}
|> method(:post)
|> url("/contacts")
|> add_param(:body, :body, create_contact_options)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 201, %MailSlurpAPI.Model.ContactDto{}}
])
end
@doc """
Delete contact
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- contact_id (String.t):
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %{}} on success
{:error, info} on failure
"""
@spec delete_contact(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
def delete_contact(connection, contact_id, _opts \\ []) do
%{}
|> method(:delete)
|> url("/contacts/#{contact_id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 204, false}
])
end
@doc """
Get all contacts
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :page (integer()): Optional page index in list pagination
- :size (integer()): Optional page size in list pagination
- :sort (String.t): Optional createdAt sort direction ASC or DESC
- :since (DateTime.t): Filter by created at after the given timestamp
- :before (DateTime.t): Filter by created at before the given timestamp
## Returns
{:ok, %MailSlurpAPI.Model.PageContactProjection{}} on success
{:error, info} on failure
"""
@spec get_all_contacts(Tesla.Env.client, keyword()) :: {:ok, MailSlurpAPI.Model.PageContactProjection.t} | {:error, Tesla.Env.t}
def get_all_contacts(connection, opts \\ []) do
optional_params = %{
:"page" => :query,
:"size" => :query,
:"sort" => :query,
:"since" => :query,
:"before" => :query
}
%{}
|> method(:get)
|> url("/contacts/paginated")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.PageContactProjection{}}
])
end
@doc """
Get contact
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- contact_id (String.t):
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.ContactDto{}} on success
{:error, info} on failure
"""
@spec get_contact(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.ContactDto.t} | {:error, Tesla.Env.t}
def get_contact(connection, contact_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/contacts/#{contact_id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.ContactDto{}}
])
end
@doc """
Get contact vCard vcf file
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- contact_id (String.t):
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, [%String{}, ...]} on success
{:error, info} on failure
"""
@spec get_contact_v_card(Tesla.Env.client, String.t, keyword()) :: {:ok, list(String.t)} | {:error, Tesla.Env.t}
def get_contact_v_card(connection, contact_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/contacts/#{contact_id}/download")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, []}
])
end
@doc """
Get all contacts
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, [%ContactProjection{}, ...]} on success
{:error, info} on failure
"""
@spec get_contacts(Tesla.Env.client, keyword()) :: {:ok, list(MailSlurpAPI.Model.ContactProjection.t)} | {:error, Tesla.Env.t}
def get_contacts(connection, _opts \\ []) do
%{}
|> method(:get)
|> url("/contacts")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, [%MailSlurpAPI.Model.ContactProjection{}]}
])
end
end