app_manager 2.2.0 → 2.2.2

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: f97b31c44449e934975e233f07a745d883e58abd3a29ccd30537ec0e1ba6bca2
4
- data.tar.gz: 863e6b243cd1c16839c4d5c9d7f3a3a0b1b47909ce613c9ff075e21d996ce314
3
+ metadata.gz: be4fee3fa2e98fefd78bc65eb9172801baadbc53b302b10c885fd113dfa1a508
4
+ data.tar.gz: 2c0a489b9bc8fca1f6338373d0fa48b6495d29f794fd3f4fc70c4e6a72271377
5
5
  SHA512:
6
- metadata.gz: 31f071cf42a3cfec28b0fae59cedfc72c2b24b80a85c237932acf0d118807977a961aa199ebd5435f5ddcb4f9310a27ac47589b35db953f39e61fbdd7e6d25d6
7
- data.tar.gz: 67769978a3d30041d329e02a22432dad4d936a5254ac711e118a03be50101e11260aa22929a2c210ddbec027c44b60fa807f0c51dc494e6aac92a16033b8b83d
6
+ metadata.gz: 56fa65b2c2e6972d4b0ba43fe5752068f6583b412eb29c55c46d6ee11353af3e374919384ca5d8289b0b13648c05c5cbb1a7fad80cec46a9348b175504330668
7
+ data.tar.gz: e24bc7e35e1a3046a637b6805c03fe2a0bce0e9014bb13cd34f5168abc96140aba10974da887dbfa7113a636ee4776fd224b6fa3535855d0d860cb6ad319b797
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_manager (2.2.0)
4
+ app_manager (2.2.2)
5
5
  activerecord-import (~> 1.4)
6
6
  httparty
7
7
  kaminari (>= 0.16.3)
@@ -201,7 +201,7 @@ GEM
201
201
  rake (13.0.6)
202
202
  rdoc (6.6.3.1)
203
203
  psych (>= 4.0.0)
204
- reline (0.5.1)
204
+ reline (0.5.3)
205
205
  io-console (~> 0.5)
206
206
  rexml (3.2.5)
207
207
  rspec (3.11.0)
data/README.md CHANGED
@@ -198,7 +198,9 @@ and then you can use follwing methods with your shop objects.
198
198
 
199
199
  @shop.get_active_charge_app_manager # return active charge hash from app manager otherwise nil
200
200
 
201
- @shop.update_app_manager_charge # return true if shop has shopify recurring charge but app manager doesn't then it update to app manager and return true otherwise nil
201
+ @shop.update_app_manager_charge # return true if shop has shopify recurring charge but app manager doesn't then it update to app manager and return true otherwise nil. This method also accepts current shopify charge id, so you can pass it if you already. This will reduce the extra call like this @shop.update_app_manager_charge("xx23432434")
202
+
203
+ @shop.update_app_manager_charge_with_plan_id # same as update_app_manager_charge method, the only difference is that, it will not check the plan_id in the shop table is valid from app manager. This method also accepts two parameters, first is current shopify charge id and second is plan_id .It shop table doesn't have plan_id saved then you can pass in second parameter. @shop.update_app_manager_charge_with_plan_id("xx23432434",23)
202
204
 
203
205
  @shop.get_current_shopify_charge # return active charge hash from shopify https://shopify.dev/docs/api/admin-graphql/2022-10/queries/currentAppInstallation otherwise nil
204
206
 
@@ -217,19 +219,20 @@ and then you can use follwing methods with your shop objects.
217
219
  * Update app manager gem in your project's Gemfile
218
220
 
219
221
  ```ruby
220
- gem 'app_manager', '2.0.0'
222
+ gem 'app_manager', '2.2.2'
221
223
  ```
222
224
  * In Rails project, in application.rb, add following line after require "rails/all" line
223
225
 
224
226
  ```ruby
225
- require 'app_manager/set_cookie'
227
+ require 'app_manager/set_local_storage'
226
228
  ```
227
229
 
228
230
  * In route.rb file, add following route with constraints
229
231
  ```ruby
230
232
  condition = ->(request) { request.path_info.include?('/discount/') }
233
+ plan_url = "https://admin.shopify.com/admin/apps/#{ENV['SHOPIFY_APP_SLUG']}/home/plan"
231
234
  constraints(condition) do
232
- get '/discount/*any', to: AppManager::SetCookie.new(Rails.application, condition)
235
+ get '/discount/*any', to: AppManager::SetLocalStorage.new(Rails.application, condition, plan_url)
233
236
  end
234
237
  ```
235
238
  * If updating gem from 1.6.1, then run these commands on rails root.
@@ -148,7 +148,7 @@ module AppManager
148
148
  plan_obj.cancel_charge(shop_domain, shop_plan_id)
149
149
  end
150
150
  rescue Exception => e
151
- return "#{e.inspect}"
151
+ return "#{e.inspect}-#{e.backtrace}"
152
152
  end
153
153
  end
154
154
 
@@ -170,7 +170,7 @@ module AppManager
170
170
  end
171
171
  end
172
172
  rescue Exception => e
173
- return "#{e.inspect}"
173
+ return "#{e.inspect}-#{e.backtrace}"
174
174
  end
175
175
  end
176
176
 
@@ -182,7 +182,7 @@ module AppManager
182
182
  return data["data"]["currentAppInstallation"]["activeSubscriptions"].first
183
183
  end
184
184
  rescue Exception => e
185
- Rollbar.error("Warning in APP MANAGER, trying to get_current_shopify_charge >>>> #{e.inspect}")
185
+ Rollbar.error("Warning in APP MANAGER, trying to get_current_shopify_charge >>>> #{e.inspect}-#{e.backtrace}")
186
186
  return nil
187
187
  end
188
188
  end
@@ -217,7 +217,28 @@ module AppManager
217
217
  end
218
218
  return charge_updated
219
219
  rescue Exception => e
220
- Rollbar.error("Warning in APP MANAGER, trying to get update_app_manager_charge >>>> #{e.inspect}")
220
+ Rollbar.error("Warning in APP MANAGER, trying to get update_app_manager_charge >>>> #{e.inspect}-#{e.backtrace}")
221
+ return nil
222
+ end
223
+ end
224
+
225
+ def update_app_manager_charge_with_plan_id(current_shopify_charge_id=nil,shop_custom_plan_id=nil)
226
+ charge_updated = nil
227
+ begin
228
+ shop_plan_id = self[AppManager.configuration.plan_id_or_name_field]
229
+ shop_domain = self[AppManager.configuration.shopify_domain_field]
230
+ current_charge_id = current_shopify_charge_id.present? ? current_shopify_charge_id : active_shopify_charge_id
231
+ plan_id = shop_custom_plan_id.present? ? shop_custom_plan_id : shop_plan_id
232
+ if current_charge_id.present?
233
+ if plan_id.present?
234
+ if charge_update_call(self,plan_id,current_charge_id)
235
+ charge_updated = true
236
+ end
237
+ end
238
+ end
239
+ return charge_updated
240
+ rescue Exception => e
241
+ Rollbar.error("Warning in APP MANAGER, trying to get update_app_manager_charge_with_plan_id >>>> #{e.inspect}-#{e.backtrace}")
221
242
  return nil
222
243
  end
223
244
  end
@@ -236,7 +257,7 @@ module AppManager
236
257
  return nil
237
258
  end
238
259
  rescue Exception => e
239
- Rollbar.error("Warning in APP MANAGER, trying to get active shopify charge id >>>> #{e.inspect}")
260
+ Rollbar.error("Warning in APP MANAGER, trying to get active shopify charge id >>>> #{e.inspect}-#{e.backtrace}")
240
261
  return nil
241
262
  end
242
263
  end
@@ -300,15 +321,16 @@ module AppManager
300
321
  "shopify_domain" => shop_domain
301
322
  })
302
323
  rescue Exception => e
303
- Rollbar.error("Warning in APP MANAGER model Charge Created Callback Event Fire>>>> #{e.inspect}")
324
+ Rollbar.error("Warning in APP MANAGER model Charge Created Callback Event Fire>>>> #{e.inspect}-#{e.backtrace}")
304
325
  end
326
+ Thread.exit # Terminate the thread once processing is done
305
327
  end
306
328
  end
307
329
  end
308
330
  end
309
331
  return charge_callback_done
310
332
  # rescue Exception => e
311
- # Rollbar.error("Warning in APP MANAGER model charge_callback, trying to update active shopify charge in app manager>>>> #{e.inspect}")
333
+ # Rollbar.error("Warning in APP MANAGER model charge_callback, trying to update active shopify charge in app manager>>>> #{e.inspect}-#{e.backtrace}")
312
334
  # return nil
313
335
  # end
314
336
  end
@@ -351,7 +373,7 @@ module AppManager
351
373
  self.save
352
374
  end
353
375
  rescue Exception => e
354
- return "#{e.inspect}"
376
+ return "#{e.inspect}-#{e.backtrace}"
355
377
  end
356
378
  end
357
379
 
@@ -365,10 +387,10 @@ module AppManager
365
387
  plans = plan_obj.get_plans(shop_domain)
366
388
  plans = plans.select { |x| x['interval'] == 'EVERY_30_DAYS' && x['public'] == true }
367
389
  plans.each do |plan|
368
- next if (params && !params.nil? && params == "exclude_current_plan" && !shop_plan_id.nil? && plan["id"] == shop_plan_id)
390
+ next if (params && !params.nil? && params == "exclude_current_plan" && !shop_plan_id.nil? && !plan["id"].nil? && plan["id"] == shop_plan_id)
369
391
  if plan && (plan['features'] && plan['features'].any?) && (plan['features'].values && plan['features'].values.any?) && (plan['features'].values.collect { |c| c['slug'] } && plan['features'].values.collect { |c| c['slug'] }.any?)
370
392
  plan_feature_slugs = plan['features'].values.collect { |c| c['slug'] }.sort
371
- if (feature_slugs & plan_feature_slugs).any? && ((feature_slugs & plan_feature_slugs).sort == feature_slugs.sort)
393
+ if plan_feature_slugs && (feature_slugs & plan_feature_slugs).any? && ((feature_slugs & plan_feature_slugs).sort == feature_slugs.sort)
372
394
  plan_data.push(plan)
373
395
  end
374
396
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppManager
4
- VERSION = "2.2.0"
4
+ VERSION = "2.2.2"
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.2.0
4
+ version: 2.2.2
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-04-19 00:00:00.000000000 Z
11
+ date: 2024-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty