# NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule Thinkific.Api.Promotions do @moduledoc """ API calls for all endpoints tagged `Promotions`. """ alias Thinkific.Connection import Thinkific.RequestBuilder @doc """ createPromotion Create a new promotion ## Parameters - connection (Thinkific.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :body (PromotionRequest): New Promotion parameters ## Returns {:ok, %Thinkific.Model.PromotionResponse{}} on success {:error, info} on failure """ @spec create_promotion(Tesla.Env.client, keyword()) :: {:ok, Thinkific.Model.PromotionResponse.t} | {:error, Tesla.Env.t} def create_promotion(connection, opts \\ []) do optional_params = %{ :"body" => :body } %{} |> method(:post) |> url("/promotions") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%Thinkific.Model.PromotionResponse{}) end @doc """ deletePromotionByID Delete promotion by provided ID ## Parameters - connection (Thinkific.Connection): Connection to server - id (float()): Id of the promotion in the form of an integer - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, %{}} on success {:error, info} on failure """ @spec delete_promotion_by_id(Tesla.Env.client, float(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def delete_promotion_by_id(connection, id, _opts \\ []) do %{} |> method(:delete) |> url("/promotions/#{id}") |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(false) end @doc """ getPromotionByID Get promotion by provided ID ## Parameters - connection (Thinkific.Connection): Connection to server - id (float()): Id of the promotion in the form of an integer - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, %Thinkific.Model.PromotionResponse{}} on success {:error, info} on failure """ @spec get_promotion_by_id(Tesla.Env.client, float(), keyword()) :: {:ok, Thinkific.Model.PromotionResponse.t} | {:error, Tesla.Env.t} def get_promotion_by_id(connection, id, _opts \\ []) do %{} |> method(:get) |> url("/promotions/#{id}") |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%Thinkific.Model.PromotionResponse{}) end @doc """ Get Promotion associated with the provided Coupon code. Find a Promotion by Coupon Code and Product ## Parameters - connection (Thinkific.Connection): Connection to server - product_id (float()): The id of the Product to which the promotion applies. - coupon_code (String.t): The Coupon code to be used as search critieria. - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, %Thinkific.Model.PromotionResponse{}} on success {:error, info} on failure """ @spec get_promotionassociatedwiththeprovided_couponcode_(Tesla.Env.client, float(), String.t, keyword()) :: {:ok, Thinkific.Model.PromotionResponse.t} | {:error, Tesla.Env.t} def get_promotionassociatedwiththeprovided_couponcode_(connection, product_id, coupon_code, _opts \\ []) do %{} |> method(:get) |> url("/promotions/by_coupon") |> add_param(:query, :"product_id", product_id) |> add_param(:query, :"coupon_code", coupon_code) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%Thinkific.Model.PromotionResponse{}) end @doc """ getPromotions List promotions ## Parameters - connection (Thinkific.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :page (float()): The page within the collection to fetch - :limit (float()): The number of items to be returned ## Returns {:ok, %Thinkific.Model.GetPromotionsResponse{}} on success {:error, info} on failure """ @spec get_promotions(Tesla.Env.client, keyword()) :: {:ok, Thinkific.Model.GetPromotionsResponse.t} | {:error, Tesla.Env.t} def get_promotions(connection, opts \\ []) do optional_params = %{ :"page" => :query, :"limit" => :query } %{} |> method(:get) |> url("/promotions") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%Thinkific.Model.GetPromotionsResponse{}) end @doc """ updatePromotionByID Update promotion by provided ID ## Parameters - connection (Thinkific.Connection): Connection to server - id (float()): Id of the promotion in the form of an integer - opts (KeywordList): [optional] Optional parameters - :body (PromotionRequest): Promotion attributes ## Returns {:ok, %Thinkific.Model.PromotionResponse{}} on success {:error, info} on failure """ @spec update_promotion_by_id(Tesla.Env.client, float(), keyword()) :: {:ok, Thinkific.Model.PromotionResponse.t} | {:error, Tesla.Env.t} def update_promotion_by_id(connection, id, opts \\ []) do optional_params = %{ :"body" => :body } %{} |> method(:put) |> url("/promotions/#{id}") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%Thinkific.Model.PromotionResponse{}) end end