app_manager 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f73abd9405540c46eb1648419e5fcb8ba0be2a8571637e674e75147fc68280c
4
- data.tar.gz: 87b6063f633e8b27477304f3165e508fd9ed342eda56ba4396f1fe8cece30980
3
+ metadata.gz: 10891e9099aebe402bf46438060e6cd405731e44e9fb2e11e36a4e5626ff13a2
4
+ data.tar.gz: d9c572b10a0159c865e75c876501e534df067bd99662a2e9394cebc80498091f
5
5
  SHA512:
6
- metadata.gz: 875f64dbf0e20ebed6a3913d1ee42f82e05d8c61ffe4ba12e54047d2a7fa0c353ccd7acb8d22e6de6ca2b72b0c93ebbb9b5dd2b8fe5e5c5a5f33c8357e974937
7
- data.tar.gz: ba26245f102821c12ef5df4fc40d2953fc318ccbf6935ef4c1b3f63fbb1d763d5851a3c73555503f281f4a38bf660c78a422d54ff7f2df81db66f8e77c5140e0
6
+ metadata.gz: 2feefe3f19e0a1ae5316bb9853afa2a5cc077fe7546dc82597b1394399a364ec4ea844c022aa46d05a80d8a1d6b0656bdd998668d7ddbc011b0c249fbae9d39c
7
+ data.tar.gz: 70fa400868631cf7c331fdfea46f8c6f2f3956bfdd2c796166027b52fccc54ab0cb1926552ee5fe6587d3a337c860a172ed7c72315dad05951c659a9fef080d7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_manager (2.3.2)
4
+ app_manager (2.3.3)
5
5
  activerecord-import (~> 1.4)
6
6
  httparty
7
7
  kaminari (>= 0.16.3)
@@ -63,7 +63,7 @@ GEM
63
63
  activemodel (= 7.2.1)
64
64
  activesupport (= 7.2.1)
65
65
  timeout (>= 0.4.0)
66
- activerecord-import (1.8.0)
66
+ activerecord-import (1.8.1)
67
67
  activerecord (>= 4.2)
68
68
  activestorage (7.2.1)
69
69
  actionpack (= 7.2.1)
@@ -106,7 +106,7 @@ GEM
106
106
  csv
107
107
  mini_mime (>= 1.0.0)
108
108
  multi_xml (>= 0.5.2)
109
- i18n (1.14.5)
109
+ i18n (1.14.6)
110
110
  concurrent-ruby (~> 1.0)
111
111
  io-console (0.7.2)
112
112
  irb (1.14.0)
@@ -124,7 +124,7 @@ GEM
124
124
  activerecord
125
125
  kaminari-core (= 1.2.2)
126
126
  kaminari-core (1.2.2)
127
- logger (1.6.0)
127
+ logger (1.6.1)
128
128
  loofah (2.22.0)
129
129
  crass (~> 1.0.2)
130
130
  nokogiri (>= 1.12.0)
@@ -140,7 +140,7 @@ GEM
140
140
  minitest (5.25.1)
141
141
  multi_xml (0.7.1)
142
142
  bigdecimal (~> 3.1)
143
- net-imap (0.4.15)
143
+ net-imap (0.4.16)
144
144
  date
145
145
  net-protocol
146
146
  net-pop (0.1.2)
@@ -202,7 +202,7 @@ GEM
202
202
  rake (13.0.6)
203
203
  rdoc (6.7.0)
204
204
  psych (>= 4.0.0)
205
- reline (0.5.9)
205
+ reline (0.5.10)
206
206
  io-console (~> 0.5)
207
207
  rexml (3.2.5)
208
208
  rspec (3.11.0)
@@ -222,7 +222,7 @@ GEM
222
222
  rspec-support (3.11.0)
223
223
  securerandom (0.3.1)
224
224
  stringio (3.1.1)
225
- thor (1.3.1)
225
+ thor (1.3.2)
226
226
  timeout (0.4.1)
227
227
  tzinfo (2.0.6)
228
228
  concurrent-ruby (~> 1.0)
@@ -231,11 +231,11 @@ GEM
231
231
  addressable (>= 2.8.0)
232
232
  crack (>= 0.3.2)
233
233
  hashdiff (>= 0.4.0, < 2.0.0)
234
- webrick (1.8.1)
234
+ webrick (1.8.2)
235
235
  websocket-driver (0.7.6)
236
236
  websocket-extensions (>= 0.1.0)
237
237
  websocket-extensions (0.1.5)
238
- zeitwerk (2.6.17)
238
+ zeitwerk (2.6.18)
239
239
 
240
240
  PLATFORMS
241
241
  ruby
data/README.md CHANGED
@@ -209,6 +209,8 @@ and then you can use follwing methods with your shop objects.
209
209
  @shop.cancel_current_shopify_charge # It will cancel charge in shopify if there is any, if success then it will cancel charge in app manager as well using (@shop.cancel_charge ) and will make plan_id and grandfathered field to false. It will clear cache as well.
210
210
 
211
211
  @shop.active_shopfiy_charge_full #It will give shopify recurring charge graphql object with discounted price details
212
+
213
+ @shop.usage_charge_call(amount,description,shopify_charge_id #optional) #It will call usage charge API. Amount parameter must be present and should be float value. You can skip shopify_charge_id if you want to pass active shopify charge id. This method will automatically pull that, otherwise you can pass it. You have to pass descriptions as a second parameter.
212
214
  ```
213
215
 
214
216
  <a name="step4"></a>
@@ -298,6 +298,33 @@ module AppManager
298
298
 
299
299
  end
300
300
 
301
+ def usage_charge_api_call(charge_id,amount,description = '')
302
+ query = 'mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {
303
+ appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {
304
+ userErrors {
305
+ field
306
+ message
307
+ }
308
+ appUsageRecord {
309
+ id
310
+ }
311
+ }
312
+ }'
313
+
314
+ variables = {
315
+ "subscriptionLineItemId": "gid://shopify/AppSubscriptionLineItem/#{charge_id}?v=1&index=1",
316
+ "price": {
317
+ "amount": amount,
318
+ "currencyCode": "USD"
319
+ },
320
+ "description": "#{description}"
321
+ }
322
+
323
+ data = run_graph_api(query,variables)
324
+ return data
325
+ end
326
+
327
+
301
328
  end
302
329
  end
303
330
 
@@ -346,6 +346,27 @@ module AppManager
346
346
  end
347
347
  end
348
348
 
349
+ def usage_charge_call(amount, description = '', shopify_charge_id = nil)
350
+ gq_obj = AppManager::GraphqlHelper.new(shopify_domain, shopify_token)
351
+
352
+ # Validate amount is present and is a valid number
353
+ return 'Amount must be present and a positive float' if amount.blank? || !amount.is_a?(Numeric) || amount.to_f <= 0
354
+
355
+ # Use the provided shopify_charge_id if available, else use active_shopify_charge_id
356
+ charge_id = shopify_charge_id.presence || active_shopify_charge_id
357
+
358
+ # Return nil if there's no valid charge_id
359
+ return nil if charge_id.blank?
360
+
361
+ # Ensure amount is a float
362
+ amount = amount.to_f
363
+
364
+ # Make the usage charge API call
365
+ gq_obj.usage_charge_api_call(charge_id, amount, description)
366
+ end
367
+
368
+
369
+
349
370
  def config_trial_days
350
371
  @field_names = AppManager.configuration.field_names
351
372
  if !@field_names.nil? && @field_names.has_key?('total_trial_days') && !@field_names['total_trial_days'].nil? && !@field_names['total_trial_days'].blank?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppManager
4
- VERSION = "2.3.2"
4
+ VERSION = "2.3.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahul Tiwari @ Hulkapps
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-28 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty