Skip to content

Commit 7206c0c

Browse files
committed
Migrate usage from Oj to JSON
1 parent bb23fce commit 7206c0c

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

lib/shopify_api/auth/associated_user.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ def ==(other)
3131
false
3232
end
3333
end
34+
35+
sig { returns(Hash) }
36+
def to_h
37+
{
38+
id: id,
39+
first_name: first_name,
40+
last_name: last_name,
41+
email: email,
42+
email_verified: email_verified,
43+
account_owner: account_owner,
44+
locale: locale,
45+
collaborator: collaborator
46+
}
47+
end
48+
49+
sig { returns(String) }
50+
def to_json
51+
to_h.to_json
52+
end
3453
end
3554
end
3655
end

lib/shopify_api/auth/session.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def from(shop:, access_token_response:)
117117

118118
sig { params(str: String).returns(Session) }
119119
def deserialize(str)
120-
Oj.load(str)
120+
JSON.load(str)
121121
end
122122
end
123123

@@ -134,7 +134,7 @@ def copy_attributes_from(other)
134134

135135
sig { returns(String) }
136136
def serialize
137-
Oj.dump(self)
137+
JSON.dump(self)
138138
end
139139

140140
alias_method :eql?, :==
@@ -156,6 +156,27 @@ def ==(other)
156156
false
157157
end
158158
end
159+
160+
sig { returns(T::Hash[Symbol, T.untyped]) }
161+
def to_h
162+
{
163+
id: id,
164+
shop: shop,
165+
state: state,
166+
access_token: access_token,
167+
scope: scope.to_a,
168+
associated_user_scope: associated_user_scope&.to_a,
169+
expires: expires&.to_i,
170+
is_online: online?,
171+
associated_user: associated_user&.to_h,
172+
shopify_session_id: shopify_session_id,
173+
}
174+
end
175+
176+
sig { returns(String) }
177+
def to_json
178+
to_h.to_json
179+
end
159180
end
160181
end
161182
end

0 commit comments

Comments
 (0)