View Source StarkInfra.CreditNote (starkinfra v0.1.0)

Groups CreditNote related functions

Link to this section Summary

Functions

CreditNotes are used to generate CCB contracts between you and your customers. When you initialize a CreditNote, the entity will not be automatically created in the Stark Infra API. The 'create' function sends the structs to the Stark Infra API and returns the list of created structs.

Same as cancel(), but it will unwrap the error tuple and raise in case of errors.

Cancel a CreditNote entity previously created in the Stark Infra API

Same as create(), but it will unwrap the error tuple and raise in case of errors.

Send a list of CreditNote structs for creation in the Stark Infra API

Same as get(), but it will unwrap the error tuple and raise in case of errors.

Receive a single CreditNote struct previously created in the Stark Infra API by its id

Same as page(), but it will unwrap the error tuple and raise in case of errors.

Receive a list of up to 100 CreditNote structs previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.

Same as query(), but it will unwrap the error tuple and raise in case of errors.

Receive a stream of CreditNote structs previously created in the Stark Infra API

Link to this section Types

@type t() :: %StarkInfra.CreditNote{
  amount: term(),
  city: term(),
  created: term(),
  district: term(),
  document_id: term(),
  expiration: term(),
  external_id: term(),
  id: term(),
  interest: term(),
  invoices: term(),
  name: term(),
  nominal_amount: term(),
  payment: term(),
  payment_type: term(),
  rebate_amount: term(),
  scheduled: term(),
  signers: term(),
  state_code: term(),
  status: term(),
  street_line_1: term(),
  street_line_2: term(),
  tags: term(),
  tax_amount: term(),
  tax_id: term(),
  template_id: term(),
  transaction_ids: term(),
  updated: term(),
  workspace_id: term(),
  zip_code: term()
}

Link to this section Functions

Link to this function

%StarkInfra.CreditNote{}

View Source (struct)

CreditNotes are used to generate CCB contracts between you and your customers. When you initialize a CreditNote, the entity will not be automatically created in the Stark Infra API. The 'create' function sends the structs to the Stark Infra API and returns the list of created structs.

parameters-required

Parameters (required):

  • :template_id [string]: ID of the contract template on which the CreditNote will be based. ex: "0123456789101112"
  • :name [string]: credit receiver's full name. ex: "Anthony Edward Stark"
  • :tax_id [string]: credit receiver's tax ID (CPF or CNPJ). ex: "20.018.183/0001-80"
  • :nominal_amount [integer]: amount in cents transferred to the credit receiver, before deductions. ex: 11234 (= R$ 112.34)
  • :scheduled [Date Datetime or string]: Date or datetime of transfer execution. ex: ~D[2020-03-10]
  • :invoices [list of Invoice structs or maps]: list of Invoice structs to be created and sent to the credit receiver. ex: [%{ due: "2023-06-25", amount: 120000, fine: 10, interest: 2}]
  • :payment [Transfer struct or map]: payment entity to be created and sent to the credit receiver. ex: %{ bankCode: "00000000", branchCode: "1234", accountNumber: "129340-1", name: "Jamie Lannister", taxId: "012.345.678-90"}
  • :signers [list of Signer objects or maps]: name and e-mail of signers that sign the contract. ex: [%{"name": "Tony Stark", "contact": "tony@starkindustries.com", "method": "link"}]
  • :external_id [string]: a string that must be unique among all your CreditNotes, used to avoid resource duplication. ex: “my-internal-id-123456”
  • :street_line_1 [string]: credit receiver main address. ex: "Av. Paulista, 200"
  • :street_line_2 [string]: credit receiver address complement. ex: "Apto. 123"
  • :district [string]: credit receiver address district / neighbourhood. ex: "Bela Vista"
  • :city [string]: credit receiver address city. ex: "Rio de Janeiro"
  • :state_code [string]: credit receiver address state. ex: "GO"
  • :zip_code [string]: credit receiver address zip code. ex: "01311-200"

parameters-conditionally-required

Parameters (conditionally required):

  • :payment_type [string]: payment type, inferred from the payment parameter if it is not a dictionary. ex: "transfer"

parameters-optional

Parameters (optional):

  • :rebate_amount [integer, default 0]: credit analysis fee deducted from lent amount. ex: 11234 (= R$ 112.34)
  • :tags [list of strings, default []]: list of strings for reference when searching for CreditNotes. ex: ["employees", "monthly"]

attributes-return-only

Attributes (return-only):

  • :id [string]: unique id returned when the CreditNote is created. ex: "5656565656565656"
  • :amount [integer]: CreditNote value in cents. ex: 1234 (= R$ 12.34)
  • :expiration [integer]: time interval in seconds between due date and expiration date. ex 123456789
  • :document_id [string]: ID of the signed document to execute this CreditNote. ex: "4545454545454545"
  • :status [string]: current status of the CreditNote. ex: "canceled", "created", "expired", "failed", "processing", "signed", "success"
  • :transaction_ids [list of strings]: ledger transaction ids linked to this CreditNote. ex: ["19827356981273"]
  • :workspace_id [string]: ID of the Workspace that generated this CreditNote. ex: "4545454545454545"
  • :tax_amount [integer]: tax amount included in the CreditNote. ex: 100
  • :interest [float]: yearly effective interest rate of the CreditNote, in percentage. ex: 12.5
  • :created [DateTime]: creation DateTime for the CreditNote. ex: ~U[2020-3-10 10:30:0:0]
  • :updated [DateTime]: latest update DateTime for the CreditNote. ex: ~U[2020-3-10 10:30:0:0]
Link to this function

cancel!(id, options \\ [])

View Source
@spec cancel!(binary(), [
  {:user, StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil}
]) ::
  t()

Same as cancel(), but it will unwrap the error tuple and raise in case of errors.

Link to this function

cancel(id, options \\ [])

View Source
@spec cancel(binary(), [
  {:user, StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil}
]) ::
  {:ok, t()} | {:error, [StarkInfra.Error.t()]}

Cancel a CreditNote entity previously created in the Stark Infra API

parameters-required

Parameters (required):

  • :id [string]: id of the CreditNote to be canceled

options

Options:

  • :user [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • canceled CreditNote struct
Link to this function

create!(notes, options \\ [])

View Source

Same as create(), but it will unwrap the error tuple and raise in case of errors.

Link to this function

create(notes, options \\ [])

View Source
@spec create([t() | map()], [
  {:user, StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil}
]) :: {:ok, [t()]} | {:error, [StarkInfra.Error.t()]}
@spec create([t() | map()], [
  {:user, StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil}
]) :: any()

Send a list of CreditNote structs for creation in the Stark Infra API

parameters-required

Parameters (required):

  • :notes [list of CreditNote structs]: list of CreditNote structs to be created in the API

options

Options:

  • :user [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • list of CreditNote structs with updated attributes
@spec get!(binary(), [
  {:user, StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil}
]) ::
  any()

Same as get(), but it will unwrap the error tuple and raise in case of errors.

@spec get(binary(), [
  {:user, StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil}
]) ::
  {:ok, [t()]} | {:error, [StarkInfra.Error.t()]}

Receive a single CreditNote struct previously created in the Stark Infra API by its id

parameters-required

Parameters (required):

  • :id [string]: struct's unique id. ex: "5656565656565656"

options

Options:

  • :user [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • CreditNote struct with updated attributes
@spec page!(
  cursor: binary(),
  limit: integer(),
  after: Date.t() | binary(),
  before: Date.t() | binary(),
  status: binary(),
  tags: [binary()],
  ids: [binary()],
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil
) :: [t()]

Same as page(), but it will unwrap the error tuple and raise in case of errors.

@spec page(
  cursor: binary(),
  limit: integer(),
  after: Date.t() | binary(),
  before: Date.t() | binary(),
  status: binary(),
  tags: [binary()],
  ids: [binary()],
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil
) :: {:ok, {binary(), [t()]}} | {:error, [StarkInfra.Error.t()]}

Receive a list of up to 100 CreditNote structs previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.

options

Options:

  • :cursor [string, default nil]: cursor returned on the previous page function call
  • :limit [integer, default 100]: maximum number of structs to be retrieved. It must be an integer between 1 and 100. ex: 50
  • :after [Date or string, default nil] Date filter for structs created only after specified date. ex: ~D[2020-3-10]
  • :before [Date or string, default nil] Date filter for structs created only before specified date. ex: ~D(2020-3-10]
  • :status [string, default nil]: filter for status of retrieved structs. Options: “canceled”, “created”, “expired”, “failed”, “processing”, “signed”, “success”.
  • :tags [list of strings, default []]: tags to filter retrieved structs. ex: ["tony", "stark"]
  • :ids [list of strings, default []]: list of ids to filter retrieved structs. ex: ["5656565656565656", "4545454545454545"]
  • :user [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • list of CreditNote structs with updated attributes
  • cursor to retrieve the next page of CreditNote structs
@spec query!(
  limit: integer(),
  after: Date.t() | binary(),
  before: Date.t() | binary(),
  status: binary(),
  tags: [binary()],
  ids: [binary()],
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil
) ::
  ({:cont, [t()]}
   | {:error, [StarkInfra.Error.t()]}
   | {:halt, any()}
   | {:suspend, any()},
   any() ->
     any())

Same as query(), but it will unwrap the error tuple and raise in case of errors.

@spec query(
  limit: integer(),
  after: Date.t() | binary(),
  before: Date.t() | binary(),
  status: binary(),
  tags: [binary()],
  ids: [binary()],
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil
) ::
  ({:cont, {:ok, [t()]}}
   | {:error, [StarkInfra.Error.t()]}
   | {:halt, any()}
   | {:suspend, any()},
   any() ->
     any())

Receive a stream of CreditNote structs previously created in the Stark Infra API

options

Options:

  • :limit [integer, default nil]: maximum number of structs to be retrieved. Unlimited if nil. ex: 35
  • :after [Date or string, default nil] date filter for structs created only after specified date. ex: ~D[2020, 3, 10]
  • :before [Date or string, default nil] date filter for structs created only before specified date. ex: ~D[2020, 3, 10]
  • :status [string, default nil]: filter for status of retrieved structs. Options: “canceled”, “created”, “expired”, “failed”, “processing”, “signed”, “success”.
  • :tags [list of strings, default []]: tags to filter retrieved structs. ex: ["tony", "stark"]
  • :ids [list of strings, default []]: list of ids to filter retrieved structs. ex: ["5656565656565656", "4545454545454545"]
  • :user [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • stream of CreditNote structs with updated attributes