diff --git a/CHANGELOG.md b/CHANGELOG.md index 2989902..fc99cd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ Given a version number MAJOR.MINOR.PATCH, increment: - PATCH version when backwards compatible bug **fixes** are implemented. ## [Unreleased] +- Deprecated create pix infraction + ### Added - IssuingRule missing parameters ### Fixed diff --git a/lib/pix_infraction/pix_infraction.ex b/lib/pix_infraction/pix_infraction.ex index 5a0bfa1..58d5491 100644 --- a/lib/pix_infraction/pix_infraction.ex +++ b/lib/pix_infraction/pix_infraction.ex @@ -78,6 +78,7 @@ defmodule StarkInfra.PixInfraction do ) :: {:ok, [PixInfraction.t() | map]} | {:error, Error.t()} + @deprecated "Function deprecated since v0.2.0" def create(infractions, options \\ []) do Rest.post( resource(), @@ -89,16 +90,13 @@ defmodule StarkInfra.PixInfraction do @doc """ Same as create(), but it will unwrap the error tuple and raise in case of errors. """ + @deprecated "Function deprecated since v0.2.0" @spec create!( [PixInfraction.t() | map], user: Organization.t() | Project.t() | nil ) :: any def create!(infractions, options \\ []) do - Rest.post!( - resource(), - infractions, - options - ) + raise "Function deprecated since v0.2.0" end @doc """ diff --git a/test/pix_infraction_test.exs b/test/pix_infraction_test.exs index 7e0cd35..ab9beba 100644 --- a/test/pix_infraction_test.exs +++ b/test/pix_infraction_test.exs @@ -3,17 +3,15 @@ defmodule StarkInfraTest.PixInfraction do @tag :pix_infraction test "create pix infraction" do - {:ok, pix_infractions} = StarkInfra.PixInfraction.create(StarkInfraTest.Utils.PixInfraction.example_pix_infraction()) - pix_infraction = pix_infractions |> hd - {:ok, canceled_pix} = StarkInfra.PixInfraction.cancel(pix_infraction.id) - assert !is_nil(canceled_pix.id) + {:error, errors} = StarkInfra.PixInfraction.create(StarkInfraTest.Utils.PixInfraction.example_pix_infraction()) + assert Enum.any?(errors, fn error -> error.code == "routeNotFound" end) end @tag :pix_infraction test "create! pix infraction" do - pix_infraction = StarkInfra.PixInfraction.create!(StarkInfraTest.Utils.PixInfraction.example_pix_infraction()) |> hd - canceled_pix = StarkInfra.PixInfraction.cancel!(pix_infraction.id) - assert !is_nil(canceled_pix.id) + assert_raise RuntimeError, "Function deprecated since v0.2.0", fn -> + StarkInfra.PixInfraction.create!(StarkInfraTest.Utils.PixInfraction.example_pix_infraction()) + end end @tag :pix_infraction