Current section

Files

Jump to
fortnox_ex lib fortnox_ex api default.ex
Raw

lib/fortnox_ex/api/default.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 FortnoxEx.Api.Default do
@moduledoc """
API calls for all endpoints tagged `Default`.
"""
alias FortnoxEx.Connection
import FortnoxEx.RequestBuilder
@doc """
Get customer by customer number
## Parameters
- connection (FortnoxEx.Connection): Connection to server
- customer_number (String.t): The customer number
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %FortnoxEx.Model.Customer{}} on success
{:error, info} on failure
"""
@spec get_customer_by_customer_number(Tesla.Env.client, String.t, keyword()) :: {:ok, FortnoxEx.Model.Customer.t} | {:error, Tesla.Env.t}
def get_customer_by_customer_number(connection, customer_number, _opts \\ []) do
%{}
|> method(:get)
|> url("/customers/#{customer_number}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %FortnoxEx.Model.Customer{}}
])
end
@doc """
List customers
## Parameters
- connection (FortnoxEx.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :financialyeardate (String.t): Selects by date, what financial year that should be used
- :financialyear (String.t): Selects what financial year that should be used
- :fromdate (String.t): Defines a selection based on a start date. Only available for invoices, orders, offers and vouchers.
- :lastmodified (String.t): Retrieves all records since the provided timestamp.
- :limit (integer()): Limit per page. Default 100, from 1 to 500 are valid options.
- :offset (integer()): Offset
- :page (integer()): Page, with 1 beeing the first page
- :sortby (String.t): A result can be sorted, either ascending or descending, by specific fields. These fields are listed in the table under the section “Fields” in the documentation for each resource. This is made in the same way as the search and the filter, by adding GET parameters. Apart from the filters and the search, sorting uses two parameters. One named “sortby”, which specifies the field that the result should be sorted by and one named “sortorder”, which specifies the order in which the sorting should be made.
- :sortorder (String.t): Sorting order
- :todate (String.t): Defines a selection based on an end date. Only available for invoices, orders, offers and vouchers
- :filter (String.t): Filters on active and inactive customers
## Returns
{:ok, %FortnoxEx.Model.CustomerList{}} on success
{:error, info} on failure
"""
@spec list_customers(Tesla.Env.client, keyword()) :: {:ok, FortnoxEx.Model.CustomerList.t} | {:error, Tesla.Env.t}
def list_customers(connection, opts \\ []) do
optional_params = %{
:"financialyeardate" => :query,
:"financialyear" => :query,
:"fromdate" => :query,
:"lastmodified" => :query,
:"limit" => :query,
:"offset" => :query,
:"page" => :query,
:"sortby" => :query,
:"sortorder" => :query,
:"todate" => :query,
:"filter" => :query
}
%{}
|> method(:get)
|> url("/customers")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %FortnoxEx.Model.CustomerList{}}
])
end
end