Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandro Santos committed May 4, 2023
1 parent f7f8d4b commit 1b113ac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
19 changes: 1 addition & 18 deletions lib/static_brcode/static_brcode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule StarkInfra.StaticBrcode do
:amount,
:reconciliation_id,
:cashier_bank_code,
:description
:description,
:tags,
:id,
:uuid,
Expand Down Expand Up @@ -91,23 +91,6 @@ defmodule StarkInfra.StaticBrcode do
@spec create!(
[StaticBrcode.t() | map()],
user: Project.t() | Organization.t() | nil
) ::
{:ok, [StaticBrcode.t()]} |
{:error, [error: Error.t()]}
def create!(brcodes, options \\ []) do
Rest.post!(
resource(),
brcodes,
options
)
end

@doc """
Same as create(), but it will unwrap the error tuple and raise in case of errors.
"""
@spec create(
[StaticBrcode.t() | map()],
user: Project.t() | Organization.t() | nil
) :: any
def create!(brcodes, options \\ []) do
Rest.post!(
Expand Down
15 changes: 8 additions & 7 deletions test/brcode_preview_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@ defmodule StarkInfraTest.BrcodePreview do
@tag :brcode_preview
test "create brcode preview" do

{:ok, preview} = StarkInfra.BrcodePreview.create([brcodes_examples()])
|> Enum.take(1)
|> hd
{:ok, previews} = StarkInfra.BrcodePreview.create([brcodes_examples()])
preview = previews |> hd
assert !is_nil(preview)

assert !is_nil(preview.id)
end

defp get_brcode() do
brcodes = StarkInfra.StaticBrcode.query!(limit: 1)
dynamics = StarkInfra.DynamicBrcode.query!(limit: 2)
|> Enum.take(1)
|> hd

assert !is_nil(brcode.id)
IO.puts(brcode.id)
assert !is_nil(dynamics.id)
IO.puts(dynamics.id)
end

defp brcodes_examples() do
%StarkInfra.BrcodePreview{
id: get_brcode(),
payer_id: "123.456.789-10"
end_to_end_id: "E355477532023050423035uWBNV2BxGd",
payer_id: "20.018.183/0001-80"
}
end
end
4 changes: 2 additions & 2 deletions test/static_brcode_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule StarkInfraTest.StaticBrcode do
|> Enum.take(1)
|> hd

{:ok, brcode} = StarkInfra.StaticBrcode.get(brcodes.id)
{:ok, brcode} = StarkInfra.StaticBrcode.get(brcodes.uuid)

assert !is_nil(brcode.id)
end
Expand All @@ -19,7 +19,7 @@ defmodule StarkInfraTest.StaticBrcode do
|> Enum.take(1)
|> hd

brcode = StarkInfra.StaticBrcode.get!(brcodes.id)
brcode = StarkInfra.StaticBrcode.get!(brcodes.uuid)

assert !is_nil(brcode.id)
end
Expand Down
2 changes: 1 addition & 1 deletion test/utils/issuing_holder.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule StarkInfraTest.Utils.IssuingHolder do
%StarkInfra.IssuingHolder{
name: "Iron Bank S.A.",
external_id: random_string(15),
tax_id: "012.345.678-90",
tax_id: "20.018.183/0001-80",
tags: ["Traveler Employee"]
}
end
Expand Down

0 comments on commit 1b113ac

Please sign in to comment.