Skip to content

Commit

Permalink
Migrate usage from Oj to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
larouxn committed Jan 8, 2025
1 parent bb23fce commit 7206c0c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
19 changes: 19 additions & 0 deletions lib/shopify_api/auth/associated_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ def ==(other)
false
end
end

sig { returns(Hash) }
def to_h
{
id: id,
first_name: first_name,
last_name: last_name,
email: email,
email_verified: email_verified,
account_owner: account_owner,
locale: locale,
collaborator: collaborator
}
end

sig { returns(String) }
def to_json
to_h.to_json
end
end
end
end
25 changes: 23 additions & 2 deletions lib/shopify_api/auth/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def from(shop:, access_token_response:)

sig { params(str: String).returns(Session) }
def deserialize(str)
Oj.load(str)
JSON.load(str)
end
end

Expand All @@ -134,7 +134,7 @@ def copy_attributes_from(other)

sig { returns(String) }
def serialize
Oj.dump(self)
JSON.dump(self)
end

alias_method :eql?, :==
Expand All @@ -156,6 +156,27 @@ def ==(other)
false
end
end

sig { returns(T::Hash[Symbol, T.untyped]) }
def to_h
{
id: id,
shop: shop,
state: state,
access_token: access_token,
scope: scope.to_a,
associated_user_scope: associated_user_scope&.to_a,
expires: expires&.to_i,
is_online: online?,
associated_user: associated_user&.to_h,
shopify_session_id: shopify_session_id,
}
end

sig { returns(String) }
def to_json
to_h.to_json
end
end
end
end

0 comments on commit 7206c0c

Please sign in to comment.