app_manager 2.3.1 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b31e9471677527b7f6face01beac639469cab8dc2ff202978da8817466cad8cb
4
- data.tar.gz: '08708078a2e0fc375969590f7542946102754c8d01c9e321a84f8bb172c9e956'
3
+ metadata.gz: 10891e9099aebe402bf46438060e6cd405731e44e9fb2e11e36a4e5626ff13a2
4
+ data.tar.gz: d9c572b10a0159c865e75c876501e534df067bd99662a2e9394cebc80498091f
5
5
  SHA512:
6
- metadata.gz: 803859a49d8698a6f6f1e706ce54c7505f992c8fde1974e505f37fa5113ffdcd553d1efb52c42774ae50a33d0b8808015171b739fe1442a4001c89d913b4e022
7
- data.tar.gz: bb3e910739a76c982f5510cb1bdd4610a20854f55f969fde0916550005da5da525c7f83e7ca0331e8090d2a35d591dce40b6f3233d55870a93fbe7ca50fec239
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.1)
4
+ app_manager (2.3.3)
5
5
  activerecord-import (~> 1.4)
6
6
  httparty
7
7
  kaminari (>= 0.16.3)
@@ -10,82 +10,78 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actioncable (7.1.4)
14
- actionpack (= 7.1.4)
15
- activesupport (= 7.1.4)
13
+ actioncable (7.2.1)
14
+ actionpack (= 7.2.1)
15
+ activesupport (= 7.2.1)
16
16
  nio4r (~> 2.0)
17
17
  websocket-driver (>= 0.6.1)
18
18
  zeitwerk (~> 2.6)
19
- actionmailbox (7.1.4)
20
- actionpack (= 7.1.4)
21
- activejob (= 7.1.4)
22
- activerecord (= 7.1.4)
23
- activestorage (= 7.1.4)
24
- activesupport (= 7.1.4)
25
- mail (>= 2.7.1)
26
- net-imap
27
- net-pop
28
- net-smtp
29
- actionmailer (7.1.4)
30
- actionpack (= 7.1.4)
31
- actionview (= 7.1.4)
32
- activejob (= 7.1.4)
33
- activesupport (= 7.1.4)
34
- mail (~> 2.5, >= 2.5.4)
35
- net-imap
36
- net-pop
37
- net-smtp
19
+ actionmailbox (7.2.1)
20
+ actionpack (= 7.2.1)
21
+ activejob (= 7.2.1)
22
+ activerecord (= 7.2.1)
23
+ activestorage (= 7.2.1)
24
+ activesupport (= 7.2.1)
25
+ mail (>= 2.8.0)
26
+ actionmailer (7.2.1)
27
+ actionpack (= 7.2.1)
28
+ actionview (= 7.2.1)
29
+ activejob (= 7.2.1)
30
+ activesupport (= 7.2.1)
31
+ mail (>= 2.8.0)
38
32
  rails-dom-testing (~> 2.2)
39
- actionpack (7.1.4)
40
- actionview (= 7.1.4)
41
- activesupport (= 7.1.4)
33
+ actionpack (7.2.1)
34
+ actionview (= 7.2.1)
35
+ activesupport (= 7.2.1)
42
36
  nokogiri (>= 1.8.5)
43
37
  racc
44
- rack (>= 2.2.4)
38
+ rack (>= 2.2.4, < 3.2)
45
39
  rack-session (>= 1.0.1)
46
40
  rack-test (>= 0.6.3)
47
41
  rails-dom-testing (~> 2.2)
48
42
  rails-html-sanitizer (~> 1.6)
49
- actiontext (7.1.4)
50
- actionpack (= 7.1.4)
51
- activerecord (= 7.1.4)
52
- activestorage (= 7.1.4)
53
- activesupport (= 7.1.4)
43
+ useragent (~> 0.16)
44
+ actiontext (7.2.1)
45
+ actionpack (= 7.2.1)
46
+ activerecord (= 7.2.1)
47
+ activestorage (= 7.2.1)
48
+ activesupport (= 7.2.1)
54
49
  globalid (>= 0.6.0)
55
50
  nokogiri (>= 1.8.5)
56
- actionview (7.1.4)
57
- activesupport (= 7.1.4)
51
+ actionview (7.2.1)
52
+ activesupport (= 7.2.1)
58
53
  builder (~> 3.1)
59
54
  erubi (~> 1.11)
60
55
  rails-dom-testing (~> 2.2)
61
56
  rails-html-sanitizer (~> 1.6)
62
- activejob (7.1.4)
63
- activesupport (= 7.1.4)
57
+ activejob (7.2.1)
58
+ activesupport (= 7.2.1)
64
59
  globalid (>= 0.3.6)
65
- activemodel (7.1.4)
66
- activesupport (= 7.1.4)
67
- activerecord (7.1.4)
68
- activemodel (= 7.1.4)
69
- activesupport (= 7.1.4)
60
+ activemodel (7.2.1)
61
+ activesupport (= 7.2.1)
62
+ activerecord (7.2.1)
63
+ activemodel (= 7.2.1)
64
+ activesupport (= 7.2.1)
70
65
  timeout (>= 0.4.0)
71
- activerecord-import (1.7.0)
66
+ activerecord-import (1.8.1)
72
67
  activerecord (>= 4.2)
73
- activestorage (7.1.4)
74
- actionpack (= 7.1.4)
75
- activejob (= 7.1.4)
76
- activerecord (= 7.1.4)
77
- activesupport (= 7.1.4)
68
+ activestorage (7.2.1)
69
+ actionpack (= 7.2.1)
70
+ activejob (= 7.2.1)
71
+ activerecord (= 7.2.1)
72
+ activesupport (= 7.2.1)
78
73
  marcel (~> 1.0)
79
- activesupport (7.1.4)
74
+ activesupport (7.2.1)
80
75
  base64
81
76
  bigdecimal
82
- concurrent-ruby (~> 1.0, >= 1.0.2)
77
+ concurrent-ruby (~> 1.0, >= 1.3.1)
83
78
  connection_pool (>= 2.2.5)
84
79
  drb
85
80
  i18n (>= 1.6, < 2)
81
+ logger (>= 1.4.2)
86
82
  minitest (>= 5.1)
87
- mutex_m
88
- tzinfo (~> 2.0)
83
+ securerandom (>= 0.3)
84
+ tzinfo (~> 2.0, >= 2.0.5)
89
85
  addressable (2.8.0)
90
86
  public_suffix (>= 2.0.2, < 5.0)
91
87
  base64 (0.2.0)
@@ -110,7 +106,7 @@ GEM
110
106
  csv
111
107
  mini_mime (>= 1.0.0)
112
108
  multi_xml (>= 0.5.2)
113
- i18n (1.14.5)
109
+ i18n (1.14.6)
114
110
  concurrent-ruby (~> 1.0)
115
111
  io-console (0.7.2)
116
112
  irb (1.14.0)
@@ -128,6 +124,7 @@ GEM
128
124
  activerecord
129
125
  kaminari-core (= 1.2.2)
130
126
  kaminari-core (1.2.2)
127
+ logger (1.6.1)
131
128
  loofah (2.22.0)
132
129
  crass (~> 1.0.2)
133
130
  nokogiri (>= 1.12.0)
@@ -141,9 +138,9 @@ GEM
141
138
  mini_mime (1.1.5)
142
139
  mini_portile2 (2.8.7)
143
140
  minitest (5.25.1)
144
- multi_xml (0.6.0)
145
- mutex_m (0.2.0)
146
- net-imap (0.3.7)
141
+ multi_xml (0.7.1)
142
+ bigdecimal (~> 3.1)
143
+ net-imap (0.4.16)
147
144
  date
148
145
  net-protocol
149
146
  net-pop (0.1.2)
@@ -153,9 +150,11 @@ GEM
153
150
  net-smtp (0.5.0)
154
151
  net-protocol
155
152
  nio4r (2.7.3)
156
- nokogiri (1.15.6)
153
+ nokogiri (1.16.7)
157
154
  mini_portile2 (~> 2.8.2)
158
155
  racc (~> 1.4)
156
+ nokogiri (1.16.7-x86_64-linux)
157
+ racc (~> 1.4)
159
158
  pry (0.14.1)
160
159
  coderay (~> 1.1)
161
160
  method_source (~> 1.0)
@@ -171,20 +170,20 @@ GEM
171
170
  rackup (2.1.0)
172
171
  rack (>= 3)
173
172
  webrick (~> 1.8)
174
- rails (7.1.4)
175
- actioncable (= 7.1.4)
176
- actionmailbox (= 7.1.4)
177
- actionmailer (= 7.1.4)
178
- actionpack (= 7.1.4)
179
- actiontext (= 7.1.4)
180
- actionview (= 7.1.4)
181
- activejob (= 7.1.4)
182
- activemodel (= 7.1.4)
183
- activerecord (= 7.1.4)
184
- activestorage (= 7.1.4)
185
- activesupport (= 7.1.4)
173
+ rails (7.2.1)
174
+ actioncable (= 7.2.1)
175
+ actionmailbox (= 7.2.1)
176
+ actionmailer (= 7.2.1)
177
+ actionpack (= 7.2.1)
178
+ actiontext (= 7.2.1)
179
+ actionview (= 7.2.1)
180
+ activejob (= 7.2.1)
181
+ activemodel (= 7.2.1)
182
+ activerecord (= 7.2.1)
183
+ activestorage (= 7.2.1)
184
+ activesupport (= 7.2.1)
186
185
  bundler (>= 1.15.0)
187
- railties (= 7.1.4)
186
+ railties (= 7.2.1)
188
187
  rails-dom-testing (2.2.0)
189
188
  activesupport (>= 5.0.0)
190
189
  minitest
@@ -192,10 +191,10 @@ GEM
192
191
  rails-html-sanitizer (1.6.0)
193
192
  loofah (~> 2.21)
194
193
  nokogiri (~> 1.14)
195
- railties (7.1.4)
196
- actionpack (= 7.1.4)
197
- activesupport (= 7.1.4)
198
- irb
194
+ railties (7.2.1)
195
+ actionpack (= 7.2.1)
196
+ activesupport (= 7.2.1)
197
+ irb (~> 1.13)
199
198
  rackup (>= 1.0.0)
200
199
  rake (>= 12.2)
201
200
  thor (~> 1.0, >= 1.2.2)
@@ -203,7 +202,7 @@ GEM
203
202
  rake (13.0.6)
204
203
  rdoc (6.7.0)
205
204
  psych (>= 4.0.0)
206
- reline (0.5.9)
205
+ reline (0.5.10)
207
206
  io-console (~> 0.5)
208
207
  rexml (3.2.5)
209
208
  rspec (3.11.0)
@@ -221,20 +220,22 @@ GEM
221
220
  diff-lcs (>= 1.2.0, < 2.0)
222
221
  rspec-support (~> 3.11.0)
223
222
  rspec-support (3.11.0)
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)
229
+ useragent (0.16.10)
229
230
  webmock (3.14.0)
230
231
  addressable (>= 2.8.0)
231
232
  crack (>= 0.3.2)
232
233
  hashdiff (>= 0.4.0, < 2.0.0)
233
- webrick (1.8.1)
234
+ webrick (1.8.2)
234
235
  websocket-driver (0.7.6)
235
236
  websocket-extensions (>= 0.1.0)
236
237
  websocket-extensions (0.1.5)
237
- zeitwerk (2.6.17)
238
+ zeitwerk (2.6.18)
238
239
 
239
240
  PLATFORMS
240
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>
@@ -48,7 +48,7 @@ module AppManager
48
48
  end
49
49
 
50
50
  def check_and_activate_global_plan(shop_domain)
51
- get("/activate-global-plan?shop_domain=#{shop_domain}")
51
+ post("/activate-global-plan", {shop_domain: shop_domain})
52
52
  end
53
53
 
54
54
  def get_promotional_discount(shop_domain = nil,code)
@@ -729,7 +729,8 @@ module AppManager
729
729
  charges.each do |charge|
730
730
  if charge
731
731
  if !charge["cancelled_on"].nil?
732
- charge["cancelled_on"] = Date.parse(charge["cancelled_on"])
732
+ charge["cancelled_on"] = charge["cancelled_on"].to_s if charge["cancelled_on"].is_a?(ActiveSupport::TimeWithZone)
733
+ charge["cancelled_on"] = Date.parse(charge["cancelled_on"]) if charge["cancelled_on"].is_a?(String)
733
734
  end
734
735
  plan_ob = AppManager::Client.new(nil, json_req = true)
735
736
  res = plan_ob.sync_charge(charge.to_json)
@@ -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.1"
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.1
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-23 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
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.1.2
150
+ rubygems_version: 3.4.10
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: An API wrapper of Hulkapps AppManager portal