app_manager 1.2.4 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Gemfile.lock +4 -8
- data/app/controllers/app_manager/plans_controller.rb +3 -2
- data/app_manager.gemspec +1 -1
- data/lib/app_manager/client/connection.rb +20 -0
- data/lib/app_manager/client/plans.rb +4 -0
- data/lib/app_manager/graphql_helper.rb +2 -4
- data/lib/app_manager/model.rb +18 -7
- data/lib/app_manager/version.rb +1 -1
- data/lib/app_manager.rb +5 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 559b2673d956bf393a0182e6bce25468802af17e39d6f3144a4ffdc6b78c8746
|
4
|
+
data.tar.gz: 698af4708cb8956733e8c6430fd4a280547411263ffac2f92dadd3e6fc3be8a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc4d093387cbf91f43cc6e303b5829f9aa30e8f4e80299419edcc324a9902a34cf26e39f6a1bfc8770da596efd34fa746be692f5ca9d7d9f0b688f1e41a96e17
|
7
|
+
data.tar.gz: cb61ff896ea8f84cd97305a711befc02dfd2ebd56da8d0d652b251d0ff9c55a20ab8992ada75854e7fb8f81e58b22314e8af8ac198064a4d66f0add031b19ca5
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
app_manager (1.2.
|
4
|
+
app_manager (1.2.7)
|
5
5
|
httparty
|
6
6
|
kaminari (>= 0.16.3)
|
7
7
|
rails (>= 5.2.0)
|
8
|
-
sqlite3 (~> 1.
|
8
|
+
sqlite3 (~> 1.4.4)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
@@ -93,7 +93,7 @@ GEM
|
|
93
93
|
httparty (0.20.0)
|
94
94
|
mime-types (~> 3.0)
|
95
95
|
multi_xml (>= 0.5.2)
|
96
|
-
i18n (1.
|
96
|
+
i18n (1.11.0)
|
97
97
|
concurrent-ruby (~> 1.0)
|
98
98
|
kaminari (1.2.2)
|
99
99
|
activesupport (>= 4.1.0)
|
@@ -118,7 +118,6 @@ GEM
|
|
118
118
|
mime-types-data (~> 3.2015)
|
119
119
|
mime-types-data (3.2022.0105)
|
120
120
|
mini_mime (1.1.2)
|
121
|
-
mini_portile2 (2.8.0)
|
122
121
|
minitest (5.16.2)
|
123
122
|
multi_xml (0.6.0)
|
124
123
|
net-imap (0.2.3)
|
@@ -136,9 +135,6 @@ GEM
|
|
136
135
|
net-protocol
|
137
136
|
timeout
|
138
137
|
nio4r (2.5.8)
|
139
|
-
nokogiri (1.13.6)
|
140
|
-
mini_portile2 (~> 2.8.0)
|
141
|
-
racc (~> 1.4)
|
142
138
|
nokogiri (1.13.6-x86_64-linux)
|
143
139
|
racc (~> 1.4)
|
144
140
|
pry (0.14.1)
|
@@ -192,7 +188,7 @@ GEM
|
|
192
188
|
diff-lcs (>= 1.2.0, < 2.0)
|
193
189
|
rspec-support (~> 3.11.0)
|
194
190
|
rspec-support (3.11.0)
|
195
|
-
sqlite3 (1.
|
191
|
+
sqlite3 (1.4.4)
|
196
192
|
strscan (3.0.3)
|
197
193
|
thor (1.2.1)
|
198
194
|
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?
|
@@ -31,7 +32,7 @@ module AppManager
|
|
31
32
|
@trial_activated_field = AppManager.configuration.field_names['trial_activated_at']
|
32
33
|
trial_activated_at = @shop[@trial_activated_field] rescue nil
|
33
34
|
active_charge = plan_obj.get_charge(params[:shop_domain])
|
34
|
-
if active_charge && active_charge.any? && active_charge['active_charge'].nil? && active_charge['cancelled_charge'].nil? && !trial_activated_at
|
35
|
+
if active_charge && active_charge.any? && active_charge['active_charge'].nil? && active_charge['cancelled_charge'].nil? && !trial_activated_at && !plan
|
35
36
|
choose_later = true
|
36
37
|
end
|
37
38
|
|
@@ -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.
|
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
|
@@ -24,7 +24,11 @@ module AppManager
|
|
24
24
|
|
25
25
|
def request(http_method, path, options)
|
26
26
|
begin
|
27
|
+
if http_method.to_s == 'get'
|
28
|
+
response = response_from_cache_for_api(http_method, path, options)
|
29
|
+
else
|
27
30
|
response = self.class.send(http_method, path, { body: options, timeout: 10 })
|
31
|
+
end
|
28
32
|
if path.include? "/get-status"
|
29
33
|
data = response
|
30
34
|
elsif path.include? "/sync-charge"
|
@@ -44,6 +48,22 @@ module AppManager
|
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
51
|
+
def response_from_cache_for_api(http_method, path, options)
|
52
|
+
cache_key = "app-manager-cache/#{path}"
|
53
|
+
if fetch_static_cached_response(cache_key).present?
|
54
|
+
return fetch_static_cached_response(cache_key)
|
55
|
+
end
|
56
|
+
response = self.class.send(http_method, path, { body: options, timeout: 10 })
|
57
|
+
Rails.cache.write(cache_key, response, expires_in: AppManager.configuration.expires_in)
|
58
|
+
return response
|
59
|
+
end
|
60
|
+
|
61
|
+
def fetch_static_cached_response(cache_key)
|
62
|
+
if Rails.cache.read(cache_key).present?
|
63
|
+
return Rails.cache.read(cache_key)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
47
67
|
def parse_data(original_data)
|
48
68
|
return unless original_data
|
49
69
|
if (original_data.class == Hash) && original_data.key?("headers") && original_data.key?("footers") && original_data.key?("modal")
|
@@ -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
|
-
|
65
|
-
|
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
|
data/lib/app_manager/model.rb
CHANGED
@@ -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
|
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
|
-
|
78
|
-
|
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
|
|
data/lib/app_manager/version.rb
CHANGED
data/lib/app_manager.rb
CHANGED
@@ -27,7 +27,11 @@ module AppManager
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.clear_cache
|
30
|
-
|
30
|
+
begin
|
31
|
+
Rails.cache.delete_matched('app-manager-cache/*')
|
32
|
+
rescue Exception => e
|
33
|
+
Rails.logger.info "APP MANAGER >>>> #{e.inspect}"
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
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.
|
4
|
+
version: 1.2.7
|
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-
|
11
|
+
date: 2022-07-11 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.
|
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.
|
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: []
|