starkbank v0.3.0 StarkBank.Transaction View Source
Groups Transaction related functions
Link to this section Summary
Functions
A Transaction is a transfer of funds between workspaces inside Stark Bank. Transactions created by the user are only for internal transactions. Other operations (such as transfer or charge-payment) will automatically create a transaction for the user which can be retrieved for the statement. When you initialize a Transaction, the entity will not be automatically created in 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 Transaction entities for creation in the Stark Bank API
Same as create(), but it will unwrap the error tuple and raise in case of errors.
Receive a single Transaction entity 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 stream of Transaction entities 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 section Functions
A Transaction is a transfer of funds between workspaces inside Stark Bank. Transactions created by the user are only for internal transactions. Other operations (such as transfer or charge-payment) will automatically create a transaction for the user which can be retrieved for the statement. When you initialize a Transaction, the entity will not be automatically created in 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]: amount in cents to be transferred. ex: 1234 (= R$ 12.34):description
[string]: text to be displayed in the receiver and the sender statements (Min. 10 characters). ex: "funds redistribution":external_id
[string]: unique id, generated by user, to avoid duplicated transactions. ex: "transaction ABC 2020-03-30":received_id
[string]: unique id of the receiving workspace. ex: "5656565656565656"
Parameters (optional):
:tags
[list of strings]: list of strings for reference when searching transactions (may be empty). ex: ["abc", "test"]
Attributes (return-only):
:id
[string, default nil]: unique id returned when Transaction is created. ex: "7656565656565656":sender_id
[string]: unique id of the sending workspace. ex: "5656565656565656":fee
[integer, default nil]: fee charged when transfer is created. ex: 200 (= R$ 2.00):source
[string, default nil]: locator of the entity that generated the transaction. ex: "charge/18276318736" or "transfer/19381639871263/chargeback":balance
[integer, default nil]: account balance after transaction was processed. ex: 100000000 (= R$ 1,000,000.00):created
[DateTime, default nil]: creation datetime for the boleto. ex: ~U[2020-03-26 19:32:35.418698Z]
create(transactions, options \\ [])
View Sourcecreate([StarkBank.Transaction.t() | map()], [ {:user, StarkBank.User.Project.t() | nil} ]) :: {:ok, [StarkBank.Transaction.t()]} | {:error, [StarkBank.Error.t()]}
Send a list of Transaction entities for creation in the Stark Bank API
Parameters (required):
transactions
[list of Transaction entities]: list of Transaction entities 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 Transaction structs with updated attributes
create!(transactions, options \\ [])
View Sourcecreate!([StarkBank.Transaction.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.
get(id, options \\ [])
View Sourceget(binary(), [{:user, StarkBank.User.Project.t() | nil}]) :: {:ok, StarkBank.Transaction.t()} | {:error, [%StarkBank.Error{code: term(), message: term()}]}
Receive a single Transaction entity previously created in the Stark Bank API by passing its id
Parameters (required):
id
[string]: entity 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:
- Transaction struct with updated attributes
get!(id, options \\ [])
View Sourceget!(binary(), [{:user, StarkBank.User.Project.t() | nil}]) :: StarkBank.Transaction.t()
Same as get(), but it will unwrap the error tuple and raise in case of errors.
query(options \\ [])
View Sourcequery( limit: integer(), after: Date.t() | DateTime.t() | binary(), before: Date.t() | DateTime.t() | binary(), external_ids: [binary()], user: StarkBank.User.Project.t() ) :: ({:cont, {:ok, [StarkBank.Transaction.t()]}} | {:error, [StarkBank.Error.t()]} | {:halt, any()} | {:suspend, any()}, any() -> any())
Receive a stream of Transaction entities previously created in the Stark Bank API
Options:
:limit
[integer, default nil]: maximum number of entities to be retrieved. Unlimited if nil. ex: 35:after
[Date, DateTime or string, default nil]: date filter for entities created only after specified date. ex: Date(2020, 3, 10):before
[Date, DateTime or string, default nil]: date filter for entities created only before specified date. ex: Date(2020, 3, 10):external_ids
[list of strings, default nil]: list of external ids to filter retrieved entities. 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 Transaction structs with updated attributes
query!(options \\ [])
View Sourcequery!( limit: integer(), after: Date.t() | DateTime.t() | binary(), before: Date.t() | DateTime.t() | binary(), external_ids: [binary()], user: StarkBank.User.Project.t() ) :: ({:cont, [StarkBank.Transaction.t()]} | {:halt, any()} | {:suspend, any()}, any() -> any())
Same as query(), but it will unwrap the error tuple and raise in case of errors.