Current section
Files
Jump to
Current section
Files
lib/thinkific/api/coupons.ex
# 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.Coupons do
@moduledoc """
API calls for all endpoints tagged `Coupons`.
"""
alias Thinkific.Connection
import Thinkific.RequestBuilder
@doc """
bulkCreateCoupons
Bulk Create Coupons
## Parameters
- connection (Thinkific.Connection): Connection to server
- promotion_id (float()): The ID of the Promotion for which to bulk create the Coupons.
- body (BulkCreateCouponRequest): New Coupon attributes
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Thinkific.Model.CreateBulkCouponResponse{}} on success
{:error, info} on failure
"""
@spec bulk_create_coupons(Tesla.Env.client, float(), Thinkific.Model.BulkCreateCouponRequest.t, keyword()) :: {:ok, Thinkific.Model.CreateBulkCouponResponse.t} | {:error, Tesla.Env.t}
def bulk_create_coupons(connection, promotion_id, body, _opts \\ []) do
%{}
|> method(:post)
|> url("/coupons/bulk_create")
|> add_param(:query, :"promotion_id", promotion_id)
|> add_param(:body, :"body", body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.CreateBulkCouponResponse{})
end
@doc """
createCoupon
Create a Coupon
## Parameters
- connection (Thinkific.Connection): Connection to server
- promotion_id (float()): ID of the Promotion to add the Coupon to in the form of an integer.
- body (CreateCouponRequest): New Coupon attributes
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Thinkific.Model.CouponResponse{}} on success
{:error, info} on failure
"""
@spec create_coupon(Tesla.Env.client, float(), Thinkific.Model.CreateCouponRequest.t, keyword()) :: {:ok, Thinkific.Model.CouponResponse.t} | {:error, Tesla.Env.t}
def create_coupon(connection, promotion_id, body, _opts \\ []) do
%{}
|> method(:post)
|> url("/coupons")
|> add_param(:query, :"promotion_id", promotion_id)
|> add_param(:body, :"body", body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.CouponResponse{})
end
@doc """
deleteCouponByID
Deletes a coupon identified by the provided id
## Parameters
- connection (Thinkific.Connection): Connection to server
- id (float()): The ID of the Coupon in the form of an integer.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %{}} on success
{:error, info} on failure
"""
@spec delete_coupon_by_id(Tesla.Env.client, float(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
def delete_coupon_by_id(connection, id, _opts \\ []) do
%{}
|> method(:delete)
|> url("/coupons/#{id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(false)
end
@doc """
getCouponByID
Retrieve a Coupon
## Parameters
- connection (Thinkific.Connection): Connection to server
- id (float()): The ID of the Coupon in the form of an integer.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Thinkific.Model.CouponResponse{}} on success
{:error, info} on failure
"""
@spec get_coupon_by_id(Tesla.Env.client, float(), keyword()) :: {:ok, Thinkific.Model.CouponResponse.t} | {:error, Tesla.Env.t}
def get_coupon_by_id(connection, id, _opts \\ []) do
%{}
|> method(:get)
|> url("/coupons/#{id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.CouponResponse{})
end
@doc """
getCoupons
Retrieve a list of all Coupons
## Parameters
- connection (Thinkific.Connection): Connection to server
- promotion_id (float()): The ID of the Promotion for which to get the Coupons in the form of an integer.
- 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.GetCouponResponse{}} on success
{:error, info} on failure
"""
@spec get_coupons(Tesla.Env.client, float(), keyword()) :: {:ok, Thinkific.Model.GetCouponResponse.t} | {:error, Tesla.Env.t}
def get_coupons(connection, promotion_id, opts \\ []) do
optional_params = %{
:"page" => :query,
:"limit" => :query
}
%{}
|> method(:get)
|> url("/coupons")
|> add_param(:query, :"promotion_id", promotion_id)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.GetCouponResponse{})
end
@doc """
updateCoupon
Update an existing Coupon
## Parameters
- connection (Thinkific.Connection): Connection to server
- id (float()): The ID of the Coupon in the form of an integer.
- body (UpdateCoupon): Update an existing coupon
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Thinkific.Model.CouponResponse{}} on success
{:error, info} on failure
"""
@spec update_coupon(Tesla.Env.client, float(), Thinkific.Model.UpdateCoupon.t, keyword()) :: {:ok, Thinkific.Model.CouponResponse.t} | {:error, Tesla.Env.t}
def update_coupon(connection, id, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/coupons/#{id}")
|> add_param(:body, :"body", body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.CouponResponse{})
end
end