Skip to content

Commit acb314a

Browse files
committed
Add current methods for shop and charges
1 parent c60a49b commit acb314a

41 files changed

Lines changed: 589 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
77
- [#1327](https://github.com/Shopify/shopify-api-ruby/pull/1327) Support `?debug=true` parameter in GraphQL client requests
88
- [#1308](https://github.com/Shopify/shopify-api-ruby/pull/1308) Support hash_with_indifferent_access when creating REST objects from Shopify responses. Closes #1296
99
- [#1332](https://github.com/Shopify/shopify-api-ruby/pull/1332) Fixed an issue where `Customer` REST API PUT requests didn't send all of the fields in the `email_marketing_consent` attribute
10+
- [#1335](https://github.com/Shopify/shopify-api-ruby/pull/1335) Add back the `current` methods for `Shop` and `RecurringApplicationCharge` resources
1011

1112
## 14.4.0
1213

lib/shopify_api/rest/resources/2022_04/recurring_application_charge.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ def all(
149149
T.cast(response, T::Array[RecurringApplicationCharge])
150150
end
151151

152+
sig do
153+
params(session: Auth::Session)
154+
.returns(T.nilable(RecurringApplicationCharge))
155+
end
156+
def current(session: ShopifyAPI::Context.active_session)
157+
charges = all(session: session)
158+
charges.select { |charge| charge.status == "active" }.first
159+
end
160+
152161
end
153162

154163
sig do

lib/shopify_api/rest/resources/2022_04/shop.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ def all(
216216
T.cast(response, T::Array[Shop])
217217
end
218218

219+
sig do
220+
params(
221+
fields: T.untyped,
222+
session: Auth::Session,
223+
).returns(T.nilable(Shop))
224+
end
225+
def current(fields: nil, session: ShopifyAPI::Context.active_session)
226+
all(session: session, fields: fields).first
227+
end
228+
219229
end
220230

221231
end

lib/shopify_api/rest/resources/2022_07/recurring_application_charge.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ def all(
149149
T.cast(response, T::Array[RecurringApplicationCharge])
150150
end
151151

152+
sig do
153+
params(session: Auth::Session)
154+
.returns(T.nilable(RecurringApplicationCharge))
155+
end
156+
def current(session: ShopifyAPI::Context.active_session)
157+
charges = all(session: session)
158+
charges.select { |charge| charge.status == "active" }.first
159+
end
160+
152161
end
153162

154163
sig do

lib/shopify_api/rest/resources/2022_07/shop.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ def all(
216216
T.cast(response, T::Array[Shop])
217217
end
218218

219+
sig do
220+
params(
221+
fields: T.untyped,
222+
session: Auth::Session,
223+
).returns(T.nilable(Shop))
224+
end
225+
def current(fields: nil, session: ShopifyAPI::Context.active_session)
226+
all(session: session, fields: fields).first
227+
end
228+
219229
end
220230

221231
end

lib/shopify_api/rest/resources/2022_10/recurring_application_charge.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ def all(
149149
T.cast(response, T::Array[RecurringApplicationCharge])
150150
end
151151

152+
sig do
153+
params(session: Auth::Session)
154+
.returns(T.nilable(RecurringApplicationCharge))
155+
end
156+
def current(session: ShopifyAPI::Context.active_session)
157+
charges = all(session: session)
158+
charges.select { |charge| charge.status == "active" }.first
159+
end
160+
152161
end
153162

154163
sig do

lib/shopify_api/rest/resources/2022_10/shop.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ def all(
216216
T.cast(response, T::Array[Shop])
217217
end
218218

219+
sig do
220+
params(
221+
fields: T.untyped,
222+
session: Auth::Session,
223+
).returns(T.nilable(Shop))
224+
end
225+
def current(fields: nil, session: ShopifyAPI::Context.active_session)
226+
all(session: session, fields: fields).first
227+
end
228+
219229
end
220230

221231
end

lib/shopify_api/rest/resources/2023_01/recurring_application_charge.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ def all(
149149
T.cast(response, T::Array[RecurringApplicationCharge])
150150
end
151151

152+
sig do
153+
params(session: Auth::Session)
154+
.returns(T.nilable(RecurringApplicationCharge))
155+
end
156+
def current(session: ShopifyAPI::Context.active_session)
157+
charges = all(session: session)
158+
charges.select { |charge| charge.status == "active" }.first
159+
end
160+
152161
end
153162

154163
sig do

lib/shopify_api/rest/resources/2023_01/shop.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ def all(
216216
T.cast(response, T::Array[Shop])
217217
end
218218

219+
sig do
220+
params(
221+
fields: T.untyped,
222+
session: Auth::Session,
223+
).returns(T.nilable(Shop))
224+
end
225+
def current(fields: nil, session: ShopifyAPI::Context.active_session)
226+
all(session: session, fields: fields).first
227+
end
228+
219229
end
220230

221231
end

lib/shopify_api/rest/resources/2023_04/recurring_application_charge.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ def all(
149149
T.cast(response, T::Array[RecurringApplicationCharge])
150150
end
151151

152+
sig do
153+
params(session: Auth::Session)
154+
.returns(T.nilable(RecurringApplicationCharge))
155+
end
156+
def current(session: ShopifyAPI::Context.active_session)
157+
charges = all(session: session)
158+
charges.select { |charge| charge.status == "active" }.first
159+
end
160+
152161
end
153162

154163
sig do

0 commit comments

Comments
 (0)