starkbank v0.5.0 StarkBank.Boleto View Source

Groups Boleto related functions

Link to this section Summary

Functions

When you initialize a Boleto struct, the entity will not be automatically sent to the Stark Bank API. The 'create' function sends the structs to the Stark Bank API and returns the list of created structs.

Send a list of Boleto structs for creation in the Stark Bank API

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

Delete a list of Boleto entities previously created in the Stark Bank API

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

Receive a single Boleto struct previously created in the Stark Bank API by passing its id

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

Receive a single Boleto pdf file generated in the Stark Bank API by passing its id.

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

Receive a stream of Boleto structs previously created in the Stark Bank API

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

Link to this section Types

Link to this type

t()

View Source
t() :: %StarkBank.Boleto{
  amount: term(),
  bar_code: term(),
  city: term(),
  created: term(),
  descriptions: term(),
  discounts: term(),
  district: term(),
  due: term(),
  fee: term(),
  fine: term(),
  id: term(),
  interest: term(),
  line: term(),
  name: term(),
  overdue_limit: term(),
  receiver_name: term(),
  receiver_tax_id: term(),
  state_code: term(),
  status: term(),
  street_line_1: term(),
  street_line_2: term(),
  tags: term(),
  tax_id: term(),
  zip_code: term()
}

Link to this section Functions

Link to this function

%StarkBank.Boleto{}

View Source (struct)

When you initialize a Boleto struct, the entity will not be automatically sent to the Stark Bank API. The 'create' function sends the structs to the Stark Bank API and returns the list of created structs.

Parameters (required):

  • :amount [integer]: Boleto value in cents. Minimum amount = 200 (R$2,00). ex: 1234 (= R$ 12.34)
  • :name [string]: payer full name. ex: "Anthony Edward Stark"
  • :tax_id [string]: payer tax ID (CPF or CNPJ) with or without formatting. ex: "01234567890" or "20.018.183/0001-80"
  • :street_line_1 [string]: payer main address. ex: Av. Paulista, 200
  • :street_line_2 [string]: payer address complement. ex: Apto. 123
  • :district [string]: payer address district / neighbourhood. ex: Bela Vista
  • :city [string]: payer address city. ex: Rio de Janeiro
  • :state_code [string]: payer address state. ex: GO
  • :zip_code [string]: payer address zip code. ex: 01311-200

Parameters (optional):

  • :due [Date, DateTime or string, default today + 2 days]: Boleto due date in ISO format. ex: 2020-04-30
  • :fine [float, default 0.0]: Boleto fine for overdue payment in %. ex: 2.5
  • :interest [float, default 0.0]: Boleto monthly interest for overdue payment in %. ex: 5.2
  • :overdue_limit [integer, default 59]: limit in days for payment after due date. ex: 7 (max: 59)
  • :receiver_name [string]: receiver (Sacador Avalista) full name. ex: "Anthony Edward Stark"
  • :receiver_tax_id [string]: receiver (Sacador Avalista) tax ID (CPF or CNPJ) with or without formatting. ex: "01234567890" or "20.018.183/0001-80"
  • :descriptions [list of maps, default nil]: list of maps with :text (string) and :amount (int, optional) pairs
  • :discounts [list of maps, default nil]: list of maps with :percentage (float) and :date (Date or string) pairs
  • :tags [list of strings]: list of strings for tagging

Attributes (return-only):

  • :id [string, default nil]: unique id returned when Boleto is created. ex: "5656565656565656"
  • :fee [integer, default nil]: fee charged when Boleto is paid. ex: 200 (= R$ 2.00)
  • :line [string, default nil]: generated Boleto line for payment. ex: "34191.09008 63571.277308 71444.640008 5 81960000000062"
  • :bar_code [string, default nil]: generated Boleto bar-code for payment. ex: "34195819600000000621090063571277307144464000"
  • :status [string, default nil]: current Boleto status. ex: "registered" or "paid"
  • :created [DateTime, default nil]: creation datetime for the Boleto. ex: ~U[2020-03-26 19:32:35.418698Z]
Link to this function

create(boletos, options \\ [])

View Source
create([StarkBank.Boleto.t() | map()], [
  {:user, StarkBank.User.Project.t() | nil}
]) :: {:ok, [StarkBank.Boleto.t()]} | {:error, [StarkBank.Error.t()]}

Send a list of Boleto structs for creation in the Stark Bank API

Parameters (required):

  • boletos [list of Boleto structs]: list of Boleto structs to be created in the API

Options:

  • :user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

Return:

  • list of Boleto structs with updated attributes
Link to this function

create!(boletos, options \\ [])

View Source
create!([StarkBank.Boleto.t() | map()], [
  {:user, StarkBank.User.Project.t() | nil}
]) :: any()

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

Link to this function

delete(id, options \\ [])

View Source
delete(binary(), [{:user, StarkBank.User.Project.t() | nil}]) ::
  {:ok, StarkBank.Boleto.t()}
  | {:error, [%StarkBank.Error{code: term(), message: term()}]}

Delete a list of Boleto entities previously created in the Stark Bank API

Parameters (required):

  • id [string]: Boleto unique id. ex: "5656565656565656"

Options:

  • :user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

Return:

  • deleted Boleto struct with updated attributes
Link to this function

delete!(id, options \\ [])

View Source
delete!(binary(), [{:user, StarkBank.User.Project.t() | nil}]) ::
  StarkBank.Boleto.t()

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

Link to this function

get(id, options \\ [])

View Source
get(binary(), [{:user, StarkBank.User.Project.t() | nil}]) ::
  {:ok, StarkBank.Boleto.t()}
  | {:error, [%StarkBank.Error{code: term(), message: term()}]}

Receive a single Boleto struct previously created in the Stark Bank API by passing its id

Parameters (required):

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

Options:

  • :user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

Return:

  • Boleto struct with updated attributes
Link to this function

get!(id, options \\ [])

View Source
get!(binary(), [{:user, StarkBank.User.Project.t() | nil}]) ::
  StarkBank.Boleto.t()

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

Link to this function

pdf(id, options \\ [])

View Source
pdf(binary(), layout: binary(), user: StarkBank.User.Project.t() | nil) ::
  {:ok, binary()} | {:error, [%StarkBank.Error{code: term(), message: term()}]}

Receive a single Boleto pdf file generated in the Stark Bank API by passing its id.

Parameters (required):

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

Options:

  • :layout [string]: Layout specification. Available options are "default" and "booklet".
  • :user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

Return:

  • Boleto pdf file content
Link to this function

pdf!(id, options \\ [])

View Source
pdf!(binary(), layout: binary(), user: StarkBank.User.Project.t() | nil) ::
  binary()

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

Link to this function

query(options \\ [])

View Source
query(
  limit: integer(),
  after: Date.t() | DateTime.t() | binary(),
  before: Date.t() | DateTime.t() | binary(),
  status: binary(),
  tags: [binary()],
  ids: [binary()],
  user: StarkBank.User.Project.t()
) ::
  ({:cont, {:ok, [StarkBank.Boleto.t()]}}
   | {:error, [StarkBank.Error.t()]}
   | {:halt, any()}
   | {:suspend, any()},
   any() ->
     any())

Receive a stream of Boleto structs previously created in the Stark Bank API

Options:

  • :limit [integer, default nil]: maximum number of structs to be retrieved. Unlimited if nil. ex: 35
  • :after [Date, DateTime or string, default nil]: date filter for structs created only after specified date. ex: ~D[2020-03-25]
  • :before [Date, DateTime or string, default nil]: date filter for structs created only before specified date. ex: ~D[2020-03-25]
  • :status [string, default nil]: filter for status of retrieved structs. ex: "paid" or "registered"
  • :tags [list of strings, default nil]: tags to filter retrieved structs. ex: ["tony", "stark"]
  • :ids [list of strings, default nil]: list of ids to filter retrieved structs. ex: ["5656565656565656", "4545454545454545"]
  • :user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

Return:

  • stream of Boleto structs with updated attributes
Link to this function

query!(options \\ [])

View Source
query!(
  limit: integer(),
  after: Date.t() | DateTime.t() | binary(),
  before: Date.t() | DateTime.t() | binary(),
  status: binary(),
  tags: [binary()],
  ids: [binary()],
  user: StarkBank.User.Project.t()
) ::
  ({:cont, [StarkBank.Boleto.t()]}
   | {:halt, any()}
   | {:suspend, any()},
   any() ->
     any())

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