app_manager 1.2.5 → 1.2.6

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: b8b130ade59cce66eefb10134bca05802a6f7911e59123a1f8885789547a6c5f
4
- data.tar.gz: d3fb70f8010e1d70dc1042c28322d5eeb7696cdecef9bd29fdd09e80a9a02e9d
3
+ metadata.gz: cba2a8e2159e68da401fd6ac3e3442b4b9e45e417544f69f0db476c86afcdb40
4
+ data.tar.gz: 16e80be01398355ff3c8d844a52ba9f95581ae9d2f5de9f0ad10a194771d630d
5
5
  SHA512:
6
- metadata.gz: 3fbef0b8ce7194394d942bbf2fd93d1aa52c7b9035be8a98a09ab080c33d047c8e8fe213f66d5cc1396aa326f7d4881d0db47077ffae42a01b1558f8a8c3febc
7
- data.tar.gz: e2138c8801189e683ae7db8703dbe2703eedfdedca2a87c0a6f00528bb49bcd28436e457aeb77dca3113993599459b25632e190ee85e95521332d43fe018a4a1
6
+ metadata.gz: 0c926ddee98d8311397d52d9a27d263c33da079c9971aacd6dbd29020022b38042b772d3195ff60e83e22ecb0b2f6af14e21023ffd4b9541c2315dd9be9a585b
7
+ data.tar.gz: b723e7e8d3d8ba97780220140508188c14547037e88e6f5d77110c2cea5dc57c202d3ac9ca64015ebf4df73e1afa74fa856e2f87f88073ddf207cc02525a715b
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_manager (1.2.5)
4
+ app_manager (1.2.6)
5
5
  httparty
6
6
  kaminari (>= 0.16.3)
7
7
  rails (>= 5.2.0)
8
- sqlite3 (~> 1.3.0)
8
+ sqlite3 (~> 1.4.4)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
@@ -192,7 +192,7 @@ GEM
192
192
  diff-lcs (>= 1.2.0, < 2.0)
193
193
  rspec-support (~> 3.11.0)
194
194
  rspec-support (3.11.0)
195
- sqlite3 (1.3.13)
195
+ sqlite3 (1.4.4)
196
196
  strscan (3.0.3)
197
197
  thor (1.2.1)
198
198
  timeout (0.3.0)
@@ -16,6 +16,7 @@ module AppManager
16
16
  active_charge = nil
17
17
  default_plan_id = nil
18
18
  choose_later = false
19
+ trial_activated_at = nil
19
20
  plan_obj = AppManager::Client.new
20
21
  plans = []
21
22
  if params[:shop_domain].present? && !AppManager.configuration.plan_features.nil?
@@ -66,7 +67,7 @@ module AppManager
66
67
  'plan' => plan,
67
68
  'default_plan_id' => default_plan_id,
68
69
  'choose_later' => choose_later,
69
- 'has_active_charge' => (!active_charge['active_charge'].nil? ? true : false)
70
+ 'has_active_charge' => (((active_charge && active_charge.any? && !active_charge['active_charge'].nil?) or !trial_activated_at) ? true : false)
70
71
  }
71
72
  render json: response
72
73
  end
data/app_manager.gemspec CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency "httparty"
34
34
  spec.add_dependency "rails", '>= 5.2.0'
35
35
  spec.add_dependency "kaminari", '>= 0.16.3'
36
- spec.add_dependency "sqlite3", '~> 1.3.0'
36
+ spec.add_dependency "sqlite3", '~> 1.4.4'
37
37
  # For more information and examples about making a new gem, checkout our
38
38
  # guide at: https://bundler.io/guides/creating_gem.html
39
39
  end
@@ -38,6 +38,10 @@ module AppManager
38
38
  get("/get-status", options)
39
39
  end
40
40
 
41
+ def has_plan(shop_domain,plan_id,trial_activated_at,grandfathered)
42
+ get("/has-plan?shop_domain=#{shop_domain}&plan_id=#{plan_id}&trial_activated_at=#{trial_activated_at}&grandfathered=#{grandfathered}")
43
+ end
44
+
41
45
 
42
46
  end
43
47
  end
@@ -61,10 +61,8 @@ module AppManager
61
61
  trial_days = plan['trial_days'] || 0
62
62
 
63
63
  if shop && shop.shopify_domain && trial_days
64
- trial_activated_at_field = AppManager.configuration.field_names['trial_activated_at'] rescue nil
65
- trial_activated_at = shop[trial_activated_at] rescue nil
66
- plan_field = AppManager.configuration.plan_id_or_name_field rescue nil
67
- plan_id_field = shop[@plan_field] rescue nil
64
+ trial_activated_at = shop[AppManager.configuration.field_names['trial_activated_at']] rescue nil
65
+ plan_id_field = shop[AppManager.configuration.plan_id_or_name_field] rescue nil
68
66
  remaining_obj = AppManager::Client.new
69
67
  remaining = remaining_obj.get_remaining_days(shop.shopify_domain,trial_activated_at,plan_id_field)
70
68
  trial_days = !remaining.nil? ? remaining : trial_days
@@ -5,7 +5,7 @@ module AppManager
5
5
  @@remaining_cache_key = "get_remaining_days_key"
6
6
  @@get_charge_key = "get_charge_key"
7
7
 
8
- def has_plan
8
+ def has_plan_old
9
9
  if !self[AppManager.configuration.plan_id_or_name_field]
10
10
  return false;
11
11
  end
@@ -28,6 +28,20 @@ module AppManager
28
28
  return active_charge && active_charge['active_charge'].present? && !active_charge['active_charge'].nil? ? true : false
29
29
  end
30
30
 
31
+ def has_plan
32
+ plan_id = self[AppManager.configuration.plan_id_or_name_field]
33
+ if !plan_id
34
+ return false;
35
+ end
36
+ grandfathered = self[AppManager.configuration.field_names['grandfathered']]
37
+ grandfathered = grandfathered ? 1 : 0
38
+ shop_domain = self[AppManager.configuration.shopify_domain_field]
39
+ trial_activated_at_field = AppManager.configuration.field_names['trial_activated_at']
40
+ trial_activated_at_val = self[trial_activated_at_field]
41
+ plan_obj = AppManager::Client.new
42
+ response = plan_obj.has_plan(shop_domain,plan_id,trial_activated_at_val,grandfathered)
43
+ return (response && response['has_plan']) || false
44
+ end
31
45
 
32
46
 
33
47
  def plan_features
@@ -51,7 +65,7 @@ module AppManager
51
65
 
52
66
 
53
67
  def has_feature(slug)
54
- self.plan_features.select{|x| x['slug'].to_s == slug }.size > 0
68
+ self.plan_features.any? && self.plan_features.select{|x| x['slug'].to_s == slug }.size > 0 ? true : false
55
69
  end
56
70
 
57
71
 
@@ -67,17 +81,14 @@ module AppManager
67
81
  end
68
82
 
69
83
  def get_remaining_days
70
- begin
71
84
  shop_domain = self[AppManager.configuration.shopify_domain_field]
72
85
  trial_activated_at_field = AppManager.configuration.field_names['trial_activated_at']
73
86
  trial_activated_at_val = self[trial_activated_at_field]
74
87
  plan_field = AppManager.configuration.field_names['plan_id']
75
88
  plan_id = self[plan_field]
76
89
  plan_obj = AppManager::Client.new
77
- return shop_domain ? plan_obj.get_remaining_days(shop_domain,trial_activated_at_val,plan_id) : 0
78
- rescue Exception => e
79
- return "#{e.inspect}"
80
- end
90
+ res = plan_obj.get_remaining_days(shop_domain,trial_activated_at_val,plan_id)
91
+ return (res && !res.nil?) ? res : 0
81
92
  end
82
93
 
83
94
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppManager
4
- VERSION = "1.2.5"
4
+ VERSION = "1.2.6"
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: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hulkapps
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-07 00:00:00.000000000 Z
11
+ date: 2022-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.3.0
61
+ version: 1.4.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.3.0
68
+ version: 1.4.4
69
69
  description: Provides helper function to access AppManager API
70
70
  email: rahul.t@hulkapps.com
71
71
  executables: []