Skip to content

Issue with serializing related entites #11

@TheFifthFreedom

Description

@TheFifthFreedom

@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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions