Skip to content

Commit

Permalink
Merge pull request #27 from starkbank/feature/transfer-features
Browse files Browse the repository at this point in the history
Add external_id and account_type to Transfer resource
  • Loading branch information
cdottori-stark authored Jan 21, 2021
2 parents a60cff5 + d99b22f commit eb5b094
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Given a version number MAJOR.MINOR.PATCH, increment:


## [Unreleased]
### Added
- Transfer.account_type property to allow "checking", "salary" or "savings" account specification
- Transfer.external_id property to allow users to take control over duplication filters

## [2.3.0] - 2021-01-19
### Fixed
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ transfers = StarkBank.Transfer.create!(
bank_code: "341", # TED
branch_code: "1234",
account_number: "123456-7",
account_type: "salary",
external_id: "my-internal-id-12345",
tax_id: "012.345.678-90",
name: "Jon Snow",
scheduled: Date.utc_today |> Date.add(30)
Expand Down
2 changes: 1 addition & 1 deletion lib/boleto_payment/boleto_payment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ defmodule StarkBank.BoletoPayment do
- `:after` [Date or string, default nil]: date filter for structs created only after specified date. ex: ~D[2020-03-25]
- `:before` [Date or string, default nil]: date filter for structs created only before specified date. ex: ~D[2020-03-25]
- `:tags` [list of strings, default nil]: tags to filter retrieved structs. ex: ["tony", "stark"]
- `:ids` [list of strings, default null]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:ids` [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:status` [string, default nil]: filter for status of retrieved structs. ex: "paid"
- `:user` [Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Expand Down
4 changes: 2 additions & 2 deletions lib/brcode_payment/brcode_payment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule StarkBank.BrcodePayment do
- `:id` [string, default nil]: unique id returned when payment is created. ex: "5656565656565656"
- `:name` [string, default nil]: receiver name. ex: "Jon Snow"
- `:status` [string, default nil]: current payment status. ex: "success" or "failed"
- `:type` [string, default null]: brcode type. ex: "static" or "dynamic"
- `:type` [string, default nil]: brcode type. ex: "static" or "dynamic"
- `:fee` [integer, default nil]: fee charged when a brcode payment is created. ex: 200 (= R$ 2.00)
- `:created` [DateTime, default nil]: creation datetime for the payment. ex: ~U[2020-03-26 19:32:35.418698Z]
- `:updated` [DateTime, default nil]: latest update datetime for the Deposit. ex: ~U[2020-08-20 19:32:35.418698Z]
Expand Down Expand Up @@ -147,7 +147,7 @@ defmodule StarkBank.BrcodePayment do
- `:after` [Date or string, default nil]: date filter for structs created only after specified date. ex: ~D[2020-03-25]
- `:before` [Date or string, default nil]: date filter for structs created only before specified date. ex: ~D[2020-03-25]
- `:tags` [list of strings, default nil]: tags to filter retrieved structs. ex: ["tony", "stark"]
- `:ids` [list of strings, default null]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:ids` [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:status` [string, default nil]: filter for status of retrieved structs. ex: "paid"
- `:user` [Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Expand Down
6 changes: 3 additions & 3 deletions lib/dict_key/dict_key.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ defmodule StarkBank.DictKey do
- `:account_type` [string, default nil]: bank account type associated with the DICT key. ex: "checking", "saving" e "salary"
- `:status` [string, default nil]: current DICT key status. ex: "created", "registered", "canceled" or "failed"
- `:account_created` [datetime.datetime, default nil]: creation datetime of the bank account associated with the DICT key. ex: datetime.date(2020, 1, 12, 11, 14, 8)
- `:owned` [DateTime, default null]: datetime since when the current owner hold this DICT key. ex: ~U[2020-11-26 17:31:45.482618Z]
- `:created` [DateTime, default null]: creation datetime for the DICT key. ex: ~U[2020-11-26 17:31:45.482618Z]
- `:owned` [DateTime, default nil]: datetime since when the current owner hold this DICT key. ex: ~U[2020-11-26 17:31:45.482618Z]
- `:created` [DateTime, default nil]: creation datetime for the DICT key. ex: ~U[2020-11-26 17:31:45.482618Z]
"""
defstruct [
:id,
Expand Down Expand Up @@ -81,7 +81,7 @@ defmodule StarkBank.DictKey do
- `:type` [string, default nil]: DictKey type. ex: "cpf", "cnpj", "phone", "email" or "evp"
- `:after` [Date or string, default nil]: date filter for structs created only after specified date. ex: ~D[2020-03-25]
- `:before` [Date or string, default nil]: date filter for structs created only before specified date. ex: ~D[2020-03-25]
- `:ids` [list of strings, default null]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:ids` [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:status` [string, default nil]: filter for status of retrieved structs. ex: "registered"
- `:user` [Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Expand Down
2 changes: 1 addition & 1 deletion lib/starkbank.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ defmodule StarkBank do
- `:private_key` [EllipticCurve.Organization()]: PEM string of the private key linked to the organization. ex: "-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----"
## Parameters (optional):
- `:workspace_id` [string]: unique id of the accessed Workspace, if any. ex: None or "4848484848484848"
- `:workspace_id` [string]: unique id of the accessed Workspace, if any. ex: nil or "4848484848484848"
"""
@spec organization(
environment: :production | :sandbox,
Expand Down
10 changes: 8 additions & 2 deletions lib/transfer/transfer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ defmodule StarkBank.Transfer do
- `:tax_id` [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: "01234567890" or "20.018.183/0001-80"
- `:bank_code` [string]: code of the receiver bank institution in Brazil. If an ISPB (8 digits) is informed, a PIX transfer will be created, else a TED will be issued. ex: "20018183" or "341"
- `:branch_code` [string]: receiver bank account branch. Use '-' in case there is a verifier digit. ex: "1357-9"
- `:account_number` [string]: Receiver Bank Account number. Use '-' before the verifier digit. ex: "876543-2"
- `:account_number` [string]: Receiver bank account number. Use '-' before the verifier digit. ex: "876543-2"
## Parameters (optional):
- `:tags` [list of strings]: list of strings for reference when searching for transfers. ex: ["employees", "monthly"]
- `:account_type` [string, default "checking"]: Receiver bank account type. This parameter only has effect on Pix Transfers. ex: "checking", "savings" or "salary"
- `:external_id` [string, default nil]: url safe string that must be unique among all your transfers. Duplicated external_ids will cause failures. By default, this parameter will block any transfer that repeats amount and receiver information on the same date. ex: "my-internal-id-123456"
- `:scheduled` [Date, DateTime or string, default now]: date or datetime when the transfer will be processed. May be pushed to next business day if necessary. ex: ~U[2020-03-26 19:32:35.418698Z]
- `:tags` [list of strings]: list of strings for reference when searching for transfers. ex: ["employees", "monthly"]
Attributes (return-only):
- `:id` [string, default nil]: unique id returned when Transfer is created. ex: "5656565656565656"
Expand All @@ -43,6 +45,8 @@ defmodule StarkBank.Transfer do
:bank_code,
:branch_code,
:account_number,
:account_type,
:external_id,
:scheduled,
:transaction_ids,
:fee,
Expand Down Expand Up @@ -242,6 +246,8 @@ defmodule StarkBank.Transfer do
bank_code: json[:bank_code],
branch_code: json[:branch_code],
account_number: json[:account_number],
account_type: json[:account_type],
external_id: json[:external_id],
scheduled: json[:scheduled] |> Check.datetime(),
transaction_ids: json[:transaction_ids],
fee: json[:fee],
Expand Down
2 changes: 1 addition & 1 deletion lib/workspace/workspace.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule StarkBank.Workspace do
- `:name` [string]: Full name that identifies the Workspace. This name will appear when people access the Workspace on our platform, for example. Ex: "Stark Bank Workspace"
## Attributes (return-only):
- `:id` [string, default None]: unique id returned when the workspace is created. ex: "5656565656565656"
- `:id` [string, default nil]: unique id returned when the workspace is created. ex: "5656565656565656"
"""
@enforce_keys [
:username,
Expand Down
4 changes: 3 additions & 1 deletion test/transfer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ defmodule StarkBankTest.Transfer do
:crypto.rand_uniform(0, 99999)
|> to_string
|> String.pad_leading(5, "0")
|> (fn s -> s <> "-#{:crypto.rand_uniform(0, 9)}" end).()
|> (fn s -> s <> "-#{:crypto.rand_uniform(0, 9)}" end).(),
account_type: ["checking", "savings", "salary"] |> Enum.random(),
external_id: "elixir-#{:crypto.rand_uniform(0, 9999999999)}"
}
end
end

0 comments on commit eb5b094

Please sign in to comment.