Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandro Santos committed May 5, 2023
1 parent 1b113ac commit 89f6695
Show file tree
Hide file tree
Showing 61 changed files with 340 additions and 352 deletions.
4 changes: 2 additions & 2 deletions lib/credit_holmes/credit_holmes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule StarkInfra.CreditHolmes do
## Parameters (optional):
- `:competence` [binary, default 'two months before current date']: competence month of the operation verification, format: "YYYY-MM". ex: "2021-04"
- `:tags` [list of binaries]: list of binaries for reference when searching for CreditHolmes. ex: [credit", "operation"]
- `:tags` [list of binaries, default []]: list of binaries for reference when searching for CreditHolmes. ex: [credit", "operation"]
## Attributes (return-only):
- `:id` [binary]: unique id returned when CreditHolmes is created. ex: "5656565656565656"
Expand Down Expand Up @@ -130,7 +130,7 @@ defmodule StarkInfra.CreditHolmes do
limit: integer,
after: Date.t() | binary,
before: Date.t() | binary,
status: binary,
status: [binary],
tags: [binary],
ids: [binary],
user: (Organization.t() | Project.t() | nil)
Expand Down
8 changes: 4 additions & 4 deletions lib/credit_note/credit_note_log.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ defmodule StarkInfra.CreditNote.Log do
- `:limit` [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
- `:after` [Date or binary, default nil]: date filter for objects created only after specified date. ex: ~D[2020, 3, 10]
- `:before` [Date or binary, default nil]: date filter for objects created only before specified date. ex: ~D[2020, 3, 10]
- `:types` [list of binaries, default []]: filter for log event types. ex: “canceled”, “created”, “expired”, “failed”, “refunded”, “registered”, “sending”, “sent”, “signed”, “success”.
- `:note_ids` [list of binaries, default []]: list of CreditNote ids to filter logs. ex: ["5656565656565656", "4545454545454545"]
- `:types` [list of binaries, default nil]: filter for log event types. ex: “canceled”, “created”, “expired”, “failed”, “refunded”, “registered”, “sending”, “sent”, “signed”, “success”.
- `:note_ids` [list of binaries, default nil]: list of CreditNote ids to filter logs. ex: ["5656565656565656", "4545454545454545"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down Expand Up @@ -127,8 +127,8 @@ defmodule StarkInfra.CreditNote.Log do
- `:limit` [integer, default 100]: maximum number of objects to be retrieved. It must be an integer between 1 and 100. ex: 50
- `:after` [Date or binary, default nil]: date filter for objects created only after specified date. ex: ~D[2020, 3, 10]
- `:before` [Date or binary, default nil]: date filter for objects created only before specified date. ex: ~D[2020, 3, 10]
- `:types` [list of binaries, default []]: filter for log event types. ex: ["canceled", "created", "expired", "failed", "refunded", "registered", "sending", "sent", "signed", "success"]
- `:note_ids` [list of binaries, default []]: list of CreditNote ids to filter logs. ex: ["5656565656565656", "4545454545454545"]
- `:types` [list of binaries, default nil]: filter for log event types. ex: ["canceled", "created", "expired", "failed", "refunded", "registered", "sending", "sent", "signed", "success"]
- `:note_ids` [list of binaries, default nil]: list of CreditNote ids to filter logs. ex: ["5656565656565656", "4545454545454545"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down
6 changes: 3 additions & 3 deletions lib/credit_note/invoice/invoice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ defmodule StarkInfra.CreditNote.Invoice do
## Parameters (optional):
- `:due` [DateTime, Date or binary, default now + 2 days]: Invoice due date in UTC ISO format. ex: ~U[2021-03-26 19:32:35.418698Z] for immediate invoices and ~D[2020-10-28] for scheduled invoices
- `:expiration` [integer, default 5097600 (59 days)]: time interval in seconds between due date and expiration date. ex 123456789
- `:tags` [list of binaries, default nil]: list of binaries for tagging
- `:descriptions` [list of CreditNote.Invoice.Description objects or maps, default nil]: list of Descriptions
- `:tags` [list of binaries, default []]: list of binaries for tagging
- `:descriptions` [list of CreditNote.Invoice.Description objects or maps, default []]: list of Descriptions
## Attributes (return-only):
- `:id` [binary]: unique id returned when Invoice is created. ex: "5656565656565656"
Expand All @@ -31,7 +31,7 @@ defmodule StarkInfra.CreditNote.Invoice do
- `:fine_amount` [integer]: Invoice fine value calculated over nominal_amount. ex: 20000
- `:interest_amount` [integer]: Invoice interest value calculated over nominal_amount. ex: 10000
- `:discount_amount` [integer]: Invoice discount value calculated over nominal_amount. ex: 3000
- `:discounts` [list of CreditNote.Invoice.Discount objects or maps, default nil]: list of Discounts or maps with "percentage":float and "due":binary pairs
- `:discounts` [list of CreditNote.Invoice.Discount objects or maps]: list of Discounts or maps with "percentage":float and "due":binary pairs
- `:brcode` [binary]: BR Code for the Invoice payment. ex: "00020101021226800014br.gov.bcb.pix2558invoice.starkbank.com/f5333103-3279-4db2-8389-5efe335ba93d5204000053039865802BR5913Arya Stark6009Sao Paulo6220051656565656565656566304A9A0"
- `:status` [binary]: current Invoice status. ex: "registered" or "paid"
- `:fee` [integer]: fee charged by this Invoice. ex: 200 (= R$ 2.00)
Expand Down
3 changes: 1 addition & 2 deletions lib/credit_note/transfer.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defmodule StarkInfra.CreditNote.Transfer do
alias __MODULE__, as: Transfer
alias StarkInfra.Utils.Check

@moduledoc """
Groups Transfer related functions
Expand All @@ -18,7 +17,7 @@ defmodule StarkInfra.CreditNote.Transfer do
## Parameters (optional):
- `:account_type` [binary, default "checking"]: Receiver Bank account type. This parameter only has effect on Pix Transfers. ex: "checking", "savings", "salary" or "payment"
- `:tags` [list of binaries]: list of binaries for reference when searching for transfers. ex: ["employees", "monthly"]
- `:tags` [list of binaries, default []]: list of binaries for reference when searching for transfers. ex: ["employees", "monthly"]
Attributes (return-only):
- `:id` [binary]: unique id returned when Transfer is created. ex: "5656565656565656"
Expand Down
2 changes: 2 additions & 0 deletions lib/credit_preview/credit_preview.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ defmodule StarkInfra.CreditPreview do
alias __MODULE__, as: CreditPreview
alias StarkInfra.Error
alias StarkInfra.Utils.Rest
alias StarkInfra.Utils.API
alias StarkInfra.User.Project
alias StarkInfra.User.Organization
alias StarkInfra.CreditNote.Transfer

@moduledoc """
Groups CreditPreview related functions
Expand Down
4 changes: 2 additions & 2 deletions lib/dynamic_brcode/dynamic_brcode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ defmodule StarkInfra.DynamicBrcode do
- `:before` [Date or binary, default nil]: date filter for objects created only before specified date. ex: ~D[2020, 3, 10]
- `:external_ids` [list of binaries, default nil]: list of external_ids to filter retrieved objects. ex: ["my_external_id1", "my_external_id2"]
- `:uuids` [list of binaries, default nil]: list of uuids to filter retrieved objects. ex: ["901e71f2447c43c886f58366a5432c4b", "4e2eab725ddd495f9c98ffd97440702d"]
- `:tags` [list of binaries, default []]: list of tags to filter retrieved objects. ex: ["tony", "stark"]
- `:tags` [list of binaries, default nil]: list of tags to filter retrieved objects. ex: ["tony", "stark"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down Expand Up @@ -197,7 +197,7 @@ defmodule StarkInfra.DynamicBrcode do
- `:before` [Date or binary, default nil]: date filter for objects created only before specified date. ex: ~D[2020, 3, 10]
- `:external_ids` [list of binaries, default nil]: list of external_ids to filter retrieved objects. ex: ["my_external_id1", "my_external_id2"]
- `:uuids` [list of binaries, default nil]: list of uuids to filter retrieved objects. ex: ["901e71f2447c43c886f58366a5432c4b", "4e2eab725ddd495f9c98ffd97440702d"]
- `:tags` [list of binaries, default []]: list of tags to filter retrieved objects. ex: ["tony", "stark"]
- `:tags` [list of binaries, default nil]: list of tags to filter retrieved objects. ex: ["tony", "stark"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down
43 changes: 23 additions & 20 deletions lib/individual_document/individual_document.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
defmodule StarkInfra.IndividualDocument do
alias __MODULE__, as: IndividualDocument
alias StarkInfra.Error
alias StarkInfra.Utils.API
alias StarkInfra.Utils.Rest
alias StarkInfra.Utils.Check
alias StarkInfra.User.Project
alias StarkInfra.User.Organization

Expand All @@ -27,7 +25,7 @@ defmodule StarkInfra.IndividualDocument do
- `:identity_id` [integer]: Unique id of IndividualIdentity. ex: "5656565656565656"
## Parameters (optional):
- `:tags` [list of binaries, default nil]: list of binaries for reference when searching for IndividualDocuments. ex: [\"employees\", \"monthly\"]
- `:tags` [list of binaries, default []]: list of binaries for reference when searching for IndividualDocuments. ex: [\"employees\", \"monthly\"]
## Attributes (return-only):
- `:id` [binary]: unique id returned when the IndividualDocument is created. ex: "5656565656565656"
Expand Down Expand Up @@ -57,7 +55,7 @@ defmodule StarkInfra.IndividualDocument do
Send a list of IndividualDocument objects for creation in the Stark Infra API
## Parameters (required):
- `:identities` [list of IndividualDocument objects]: list of IndividualDocument objects to be created in the API
- `:documents` [list of IndividualDocument objects]: list of IndividualDocument objects to be created in the API
## Parameters (optional):
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
Expand All @@ -71,10 +69,16 @@ defmodule StarkInfra.IndividualDocument do
) ::
{:ok, [IndividualDocument.t()]} |
{:error, [Error.t()]}
def create(identities, options \\ []) do
Rest.post(
def create(documents, options \\ []) do
document = documents |> hd
payload = document |> Enum.into(Atom)
if Atom.get(payload, :content_type) != nil do
Atom.put(payload, :content, "data:" <> Atom.get(payload, :content_type) <> ";base64," <> Base.encode64(Atom.get(payload, :content)))
Atom.delete(payload, :content_type)
end
Rest.post!(
resource(),
identities,
documents,
options
)
end
Expand All @@ -86,10 +90,16 @@ defmodule StarkInfra.IndividualDocument do
[IndividualDocument.t() | map()],
user: Project.t() | Organization.t() | nil
) :: any
def create!(identities, options \\ []) do
def create!(documents, options \\ []) do
document = documents |> hd
payload = document |> Enum.into(Atom)
if Atom.get(payload, :content_type) != nil do
Atom.put(payload, :content, "data:" <> Atom.get(payload, :content_type) <> ";base64," <> Base.encode64(Atom.get(payload, :content)))
Atom.delete(payload, :content_type)
end
Rest.post!(
resource(),
identities,
documents,
options
)
end
Expand Down Expand Up @@ -132,8 +142,8 @@ defmodule StarkInfra.IndividualDocument do
- `:after` [Date or binary, default nil]: date filter for objects created only after specified date. ex: ~D[2020, 3, 10]
- `:before` [Date or binary, default nil]: date filter for objects created only before specified date. ex: ~D[2020, 3, 10]
- `:status` [binary, default nil]: filter for status of retrieved objects. ex: “canceled”, “created”, “expired”, “failed”, “processing”, “signed”, “success”.
- `:tags` [list of binaries, default []]: tags to filter retrieved objects. ex: ["tony", "stark"]
- `:ids` [list of binaries, default []]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:tags` [list of binaries, default nil]: tags to filter retrieved objects. ex: ["tony", "stark"]
- `:ids` [list of binaries, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down Expand Up @@ -188,8 +198,8 @@ defmodule StarkInfra.IndividualDocument do
- `:after` [Date or binary, default nil]: Date filter for objects created only after specified date. ex: ~D[2020-3-10]
- `:before` [Date or binary, default nil]: Date filter for objects created only before specified date. ex: ~D(2020-3-10]
- `:status` [binary, default nil]: filter for status of retrieved objects. ex: “canceled”, “created”, “expired”, “failed”, “processing”, “signed”, “success”.
- `:tags` [list of binaries, default []]: tags to filter retrieved objects. ex: ["tony", "stark"]
- `:ids` [list of binaries, default []]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:tags` [list of binaries, default nil]: tags to filter retrieved objects. ex: ["tony", "stark"]
- `:ids` [list of binaries, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down Expand Up @@ -230,13 +240,6 @@ defmodule StarkInfra.IndividualDocument do
Rest.get_page!(resource(), options)
end

defp parse_payment!(payment, payment_type) do
case payment_type do
"transfer" -> API.from_api_json(payment, &Transfer.resource_maker/1)
_ -> payment
end
end

@doc false
def resource() do
{
Expand Down
8 changes: 4 additions & 4 deletions lib/individual_document/individual_document_log.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ defmodule StarkInfra.IndividualDocument.Log do
- `:limit` [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
- `:after` [Date or binary, default nil]: date filter for objects created only after specified date. ex: ~D[2020, 3, 10]
- `:before` [Date or binary, default nil]: date filter for objects created only before specified date. ex: ~D[2020, 3, 10]
- `:types` [list of binaries, default []]: filter for log event types. ex: ["created", "canceled", "processing", "failed", "success"]
- `:document_ids` [list of binaries, default []]: list of IndividualDocument ids to filter logs. ex: ["5656565656565656", "4545454545454545"]
- `:types` [list of binaries, default nil]: filter for log event types. ex: ["created", "canceled", "processing", "failed", "success"]
- `:document_ids` [list of binaries, default nil]: list of IndividualDocument ids to filter logs. ex: ["5656565656565656", "4545454545454545"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down Expand Up @@ -127,8 +127,8 @@ defmodule StarkInfra.IndividualDocument.Log do
- `:limit` [integer, default 100]: maximum number of objects to be retrieved. It must be an integer between 1 and 100. ex: 50
- `:after` [Date or binary, default nil]: date filter for objects created only after specified date. ex: ~D[2020, 3, 10]
- `:before` [Date or binary, default nil]: date filter for objects created only before specified date. ex: ~D[2020, 3, 10]
- `:types` [list of binaries, default []]: filter for log event types. ex: ["created", "canceled", "processing", "failed", "success"]
- `:document_ids` [list of binaries, default []]: list of IndividualDocument ids to filter logs. ex: ["5656565656565656", "4545454545454545"]
- `:types` [list of binaries, default nil]: filter for log event types. ex: ["created", "canceled", "processing", "failed", "success"]
- `:document_ids` [list of binaries, default nil]: list of IndividualDocument ids to filter logs. ex: ["5656565656565656", "4545454545454545"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down
12 changes: 5 additions & 7 deletions lib/individual_identity/individual_identity.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
defmodule StarkInfra.IndividualIdentity do
alias __MODULE__, as: IndividualIdentity
alias StarkInfra.Error
alias StarkInfra.Utils.API
alias StarkInfra.Utils.Rest
alias StarkInfra.Utils.Check
alias StarkInfra.User.Project
alias StarkInfra.User.Organization

Expand All @@ -27,7 +25,7 @@ defmodule StarkInfra.IndividualIdentity do
- `:tax_id` [binary]: individual's tax ID (CPF). ex: "594.739.480-42"
## Parameters (optional):
- `:tags` [list of binaries, default nil]: list of binaries for reference when searching for IndividualIdentitys. ex: [\"employees\", \"monthly\"]
- `:tags` [list of binaries, default []]: list of binaries for reference when searching for IndividualIdentitys. ex: [\"employees\", \"monthly\"]
## Attributes (return-only):
- `:id` [binary]: unique id returned when the IndividualIdentity is created. ex: "5656565656565656"
Expand Down Expand Up @@ -128,8 +126,8 @@ defmodule StarkInfra.IndividualIdentity do
- `:after` [Date or binary, default nil]: date filter for objects created only after specified date. ex: ~D[2020, 3, 10]
- `:before` [Date or binary, default nil]: date filter for objects created only before specified date. ex: ~D[2020, 3, 10]
- `:status` [binary, default nil]: filter for status of retrieved objects. ex: ["created", "canceled", "processing", "failed", "success"]
- `:tags` [list of binaries, default []]: tags to filter retrieved objects. ex: ["tony", "stark"]
- `:ids` [list of binaries, default []]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:tags` [list of binaries, default nil]: tags to filter retrieved objects. ex: ["tony", "stark"]
- `:ids` [list of binaries, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down Expand Up @@ -184,8 +182,8 @@ defmodule StarkInfra.IndividualIdentity do
- `:after` [Date or binary, default nil]: Date filter for objects created only after specified date. ex: ~D[2020-3-10]
- `:before` [Date or binary, default nil]: Date filter for objects created only before specified date. ex: ~D(2020-3-10]
- `:status` [binary, default nil]: filter for status of retrieved objects. ex: ["created", "canceled", "processing", "failed", "success"]
- `:tags` [list of binaries, default []]: tags to filter retrieved objects. ex: ["tony", "stark"]
- `:ids` [list of binaries, default []]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:tags` [list of binaries, default nil]: tags to filter retrieved objects. ex: ["tony", "stark"]
- `:ids` [list of binaries, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
- `:user` [Organization/Project, default nil]: Organization or Project object returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.
## Return:
Expand Down
Loading

0 comments on commit 89f6695

Please sign in to comment.