beam-community / stripity-stripe

An Elixir Library for Stripe
Other
965 stars 344 forks source link

Unable to retrieve test clocks from Stripe due to invalid struct name #825

Closed clandry94 closed 7 months ago

clandry94 commented 7 months ago

Existing Issue or Pull Request Verification

Package Version

3.1.1

Are you using the latest version?

Steps to Reproduce

1) Update to 3.1.1 2) Make a call to Stripe.TestHelpers.TestClock.retrieve(...) 3) The following error will be shown

[error] ** (UndefinedFunctionError) function Stripe.TestClock.__struct__/0 is undefined (module Stripe.TestClock is not available)
    Stripe.TestClock.__struct__()
    (stripity_stripe 3.1.1) lib/stripe/converter.ex:41: Stripe.Converter.convert_stripe_object/1
    (stripity_stripe 3.1.1) lib/stripe/request.ex:204: Stripe.Request.make_request/1

Expected Result

This should be parsed into the Stripe.TestHelpers.TestClock struct instead of Stripe.TestClock

Actual Result

[error] ** (UndefinedFunctionError) function Stripe.TestClock.__struct__/0 is undefined (module Stripe.TestClock is not available)
    Stripe.TestClock.__struct__()
    (stripity_stripe 3.1.1) lib/stripe/converter.ex:41: Stripe.Converter.convert_stripe_object/1
    (stripity_stripe 3.1.1) lib/stripe/request.ex:204: Stripe.Request.make_request/1

I believe this issue is related to https://github.com/beam-community/stripity-stripe/pull/792/ which made a change to how object_name_to_module parses test clocks. Line 54 added in that PR does

def object_name_to_module("test_helpers.test_clock"), do: Stripe.TestClock

instead of

def object_name_to_module("test_helpers.test_clock"), do: Stripe.TestHelpers.TestClock
Cervajz commented 7 months ago

We have the same issue

yordis commented 7 months ago

Are you able to contribute?

clandry94 commented 7 months ago

@yordis yeah I can put up a PR

maartenvanvliet commented 7 months ago

Thx for the PR, gonna close this now