diff --git a/lib/shopify_api/auth/associated_user.rb b/lib/shopify_api/auth/associated_user.rb index 7f7cd6e70..df8835e27 100644 --- a/lib/shopify_api/auth/associated_user.rb +++ b/lib/shopify_api/auth/associated_user.rb @@ -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 diff --git a/lib/shopify_api/auth/session.rb b/lib/shopify_api/auth/session.rb index 1fba413b0..16fe9172a 100644 --- a/lib/shopify_api/auth/session.rb +++ b/lib/shopify_api/auth/session.rb @@ -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 @@ -134,7 +134,7 @@ def copy_attributes_from(other) sig { returns(String) } def serialize - Oj.dump(self) + JSON.dump(self) end alias_method :eql?, :== @@ -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