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

  alias MailSlurpAPI.Connection
  import MailSlurpAPI.RequestBuilder


  @doc """
  Create tracking pixel
  Create a tracking pixel. A tracking pixel is an image that can be embedded in an email. When the email is viewed and the image is seen MailSlurp will mark the pixel as seen. Use tracking pixels to monitor email open events. You can receive open notifications via webhook or by fetching the pixel.

  ## Parameters

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

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

  @doc """
  Get tracking pixels
  List tracking pixels in paginated form

  ## 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
    - :search_filter (String.t): Optional search filter
    - :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.PageTrackingPixelProjection{}} on success
  {:error, info} on failure
  """
  @spec get_all_tracking_pixels(Tesla.Env.client, keyword()) :: {:ok, MailSlurpAPI.Model.PageTrackingPixelProjection.t} | {:error, Tesla.Env.t}
  def get_all_tracking_pixels(connection, opts \\ []) do
    optional_params = %{
      :"page" => :query,
      :"size" => :query,
      :"sort" => :query,
      :"searchFilter" => :query,
      :"since" => :query,
      :"before" => :query
    }
    %{}
    |> method(:get)
    |> url("/tracking/pixels")
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, %MailSlurpAPI.Model.PageTrackingPixelProjection{}}
    ])
  end

  @doc """
  Get pixel

  ## Parameters

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

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