Skip to content

Commit

Permalink
fixes to object
Browse files Browse the repository at this point in the history
  • Loading branch information
deanpcmad committed Nov 7, 2023
1 parent 587c200 commit 02a61f1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/lemon_squeezy/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ def initialize(attributes)
attributes.delete "relationships"
attributes.delete "links"

# Add ID from response to attributes
attributes["attributes"]["id"] = attributes["id"]
attrs = {}

super to_ostruct(attributes["attributes"])
if attributes["attributes"]
# Add ID from response to attributes
attrs[:id] = attributes["id"] if attributes["id"]
attrs.merge!(attributes["attributes"])
else
attrs.merge!(attributes)
end

super to_ostruct(attrs)
end

def to_ostruct(obj)
Expand Down

0 comments on commit 02a61f1

Please sign in to comment.