Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with serializing related entites #11

Open
TheFifthFreedom opened this issue Oct 25, 2019 · 0 comments
Open

Issue with serializing related entites #11

TheFifthFreedom opened this issue Oct 25, 2019 · 0 comments

Comments

@TheFifthFreedom
Copy link

@kirillshevch I'm using version 1.0.5, and there seems to be an issue with serializing related entities - here's a quick and dirty example with the Stripe API:

module StripeApi
  module Entities
    class Person < ApiStruct::Entity
      client_service StripeApi::Clients::Persons

      attr_entity :id,
                  :first_name,
                  :last_name

      has_entity :verification, as: StripeApi::Entities::Verification
    end
  end
end
module StripeApi
  module Entities
    class Verification < ApiStruct::Entity
      client_service StripeApi::Clients::Persons

      attr_entity :status,
                  :details,
                  :details_code
    end
  end
end

With those two serializers in place, when I call StripeApi::Entities::Person.show <params>, here's what I get:

#<Hashie::Mash first_name="John" id="person_<HIDDEN>" last_name="Doe" verification=#<Hashie::Mash additional_document=#<Hashie::Mash back=nil details=nil details_code=nil front=nil> details=nil details_code=nil document=#<Hashie::Mash back=nil details=nil details_code=nil front=nil> status="unverified">>

Essentially the verification field on the Person entity gets deserialized as if it was a attr_entity :verification - the Verification entity fails to exclude all params except status, details and details_code. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant