Current section
Files
Jump to
Current section
Files
lib/thinkific/api/products.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.Products do
@moduledoc """
API calls for all endpoints tagged `Products`.
"""
alias Thinkific.Connection
import Thinkific.RequestBuilder
@doc """
getProductByID
Returns the Product identified by the provided id.
## Parameters
- connection (Thinkific.Connection): Connection to server
- id (float()): Id of the product in the form of an integer
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Thinkific.Model.ProductResponse{}} on success
{:error, info} on failure
"""
@spec get_product_by_id(Tesla.Env.client, float(), keyword()) :: {:ok, Thinkific.Model.ProductResponse.t} | {:error, Tesla.Env.t}
def get_product_by_id(connection, id, _opts \\ []) do
%{}
|> method(:get)
|> url("/products/#{id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.ProductResponse{})
end
@doc """
getProducts
List products
## 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.GetProductsResponse{}} on success
{:error, info} on failure
"""
@spec get_products(Tesla.Env.client, keyword()) :: {:ok, Thinkific.Model.GetProductsResponse.t} | {:error, Tesla.Env.t}
def get_products(connection, opts \\ []) do
optional_params = %{
:"page" => :query,
:"limit" => :query
}
%{}
|> method(:get)
|> url("/products")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.GetProductsResponse{})
end
@doc """
getRelatedProductByProductID
Returns a list of products that are related to the Product identified by the provided id.
## Parameters
- connection (Thinkific.Connection): Connection to server
- id (float()): Id of the product 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.GetProductsResponse{}} on success
{:error, info} on failure
"""
@spec get_related_product_by_product_id(Tesla.Env.client, float(), keyword()) :: {:ok, Thinkific.Model.GetProductsResponse.t} | {:error, Tesla.Env.t}
def get_related_product_by_product_id(connection, id, opts \\ []) do
optional_params = %{
:"page" => :query,
:"limit" => :query
}
%{}
|> method(:get)
|> url("/products/#{id}/related")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.GetProductsResponse{})
end
end