diff --git a/CHANGELOG.md b/CHANGELOG.md index b0be8d0..152cea6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 3a7c3be..ec12e0b 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/boleto_payment/boleto_payment.ex b/lib/boleto_payment/boleto_payment.ex index 0dc60fd..5b7a547 100644 --- a/lib/boleto_payment/boleto_payment.ex +++ b/lib/boleto_payment/boleto_payment.ex @@ -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. diff --git a/lib/brcode_payment/brcode_payment.ex b/lib/brcode_payment/brcode_payment.ex index f5c6db9..3b74a43 100644 --- a/lib/brcode_payment/brcode_payment.ex +++ b/lib/brcode_payment/brcode_payment.ex @@ -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] @@ -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. diff --git a/lib/dict_key/dict_key.ex b/lib/dict_key/dict_key.ex index c05ee54..69b3a84 100644 --- a/lib/dict_key/dict_key.ex +++ b/lib/dict_key/dict_key.ex @@ -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, @@ -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. diff --git a/lib/starkbank.ex b/lib/starkbank.ex index 232df61..307e05b 100644 --- a/lib/starkbank.ex +++ b/lib/starkbank.ex @@ -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, diff --git a/lib/transfer/transfer.ex b/lib/transfer/transfer.ex index 26ed61d..4e6634e 100644 --- a/lib/transfer/transfer.ex +++ b/lib/transfer/transfer.ex @@ -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" @@ -43,6 +45,8 @@ defmodule StarkBank.Transfer do :bank_code, :branch_code, :account_number, + :account_type, + :external_id, :scheduled, :transaction_ids, :fee, @@ -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], diff --git a/lib/workspace/workspace.ex b/lib/workspace/workspace.ex index 8d3076b..f11c992 100644 --- a/lib/workspace/workspace.ex +++ b/lib/workspace/workspace.ex @@ -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, diff --git a/test/transfer_test.exs b/test/transfer_test.exs index c02d67e..0bcb6b0 100644 --- a/test/transfer_test.exs +++ b/test/transfer_test.exs @@ -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