app_manager 1.3.0 → 1.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 +4 -4
- data/Gemfile.lock +2 -4
- data/app/controllers/app_manager/plans_controller.rb +10 -10
- data/lib/app_manager/client/connection.rb +18 -5
- data/lib/app_manager/fail_safe.rb +5 -6
- data/lib/app_manager/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b43df1c21cb67c078b9a24c4152573750ffcaf7e13e9748380c642ebe62a7f1
|
4
|
+
data.tar.gz: 1d0e8f8dff11ff42024d85999189384408b663b6d196798d415ba6eed1ff606f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15cb229b021268ad6a36ac708cdb50a5305db6e654ec34317b0685c91cbde3515789ab84d57f13118313b7355be7d1084c43b2ae60dbc84098d5e72f04d47ae3
|
7
|
+
data.tar.gz: 126d03e0ce67248128236fde8cbd4c98d246f012358965b5b8fd000df7bb396e5e75125b42e3d0552b7cd8177e49ffdd0cd73d931af769a6606400953b657afc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
app_manager (1.3.
|
4
|
+
app_manager (1.3.3)
|
5
5
|
httparty
|
6
6
|
kaminari (>= 0.16.3)
|
7
7
|
rails (>= 5.2.0)
|
@@ -117,7 +117,6 @@ GEM
|
|
117
117
|
mime-types-data (~> 3.2015)
|
118
118
|
mime-types-data (3.2022.0105)
|
119
119
|
mini_mime (1.1.2)
|
120
|
-
mini_portile2 (2.8.0)
|
121
120
|
minitest (5.16.2)
|
122
121
|
multi_xml (0.6.0)
|
123
122
|
net-imap (0.2.3)
|
@@ -135,8 +134,7 @@ GEM
|
|
135
134
|
net-protocol
|
136
135
|
timeout
|
137
136
|
nio4r (2.5.8)
|
138
|
-
nokogiri (1.13.6)
|
139
|
-
mini_portile2 (~> 2.8.0)
|
137
|
+
nokogiri (1.13.6-x86_64-linux)
|
140
138
|
racc (~> 1.4)
|
141
139
|
pry (0.14.1)
|
142
140
|
coderay (~> 1.1)
|
@@ -160,18 +160,18 @@ module AppManager
|
|
160
160
|
params_permit
|
161
161
|
Thread.new do
|
162
162
|
@fs = AppManager::FailSafe.new
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
163
|
+
begin
|
164
|
+
@fs.sync_app_manager
|
165
|
+
rescue Exception => e
|
166
|
+
Rails.logger.info "APP MANAGER >>>> LOCAL DB couldn't sync with POTAL DB #{e.inspect}"
|
167
|
+
end
|
168
168
|
|
169
|
-
|
169
|
+
begin
|
170
170
|
@fs.save_api_data(params)
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
171
|
+
rescue Exception => e
|
172
|
+
Rails.logger.info "APP MANAGER >>>> #{e.inspect}"
|
173
|
+
end
|
174
|
+
AppManager.clear_cache
|
175
175
|
end
|
176
176
|
head :ok
|
177
177
|
end
|
@@ -23,8 +23,10 @@ module AppManager
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def request(http_method, path, options)
|
26
|
-
|
26
|
+
failsafe_or_caching_done = false
|
27
|
+
if http_method.to_s == 'get' && !path.include?("/get-status") && !path.include?("/sync-charge")
|
27
28
|
response = response_from_cache_for_api(http_method, path, options)
|
29
|
+
failsafe_or_caching_done = true
|
28
30
|
else
|
29
31
|
response = self.class.send(http_method, path, { body: options, timeout: 10 })
|
30
32
|
end
|
@@ -34,12 +36,19 @@ module AppManager
|
|
34
36
|
data = response.parsed_response
|
35
37
|
data = parse_data(response.parsed_response)
|
36
38
|
else
|
37
|
-
if response.code.to_s.start_with?('2') or response.code.to_s.start_with?('4')
|
39
|
+
if response.class.to_s == "HTTParty::Response" && (response.code.to_s.start_with?('2') or response.code.to_s.start_with?('4')) && (response.code.to_s != '429')
|
38
40
|
data = response.parsed_response
|
39
41
|
data = parse_data(response.parsed_response)
|
40
|
-
data = response_from_failsafe(path,options)
|
42
|
+
# data = response_from_failsafe(path,options) #uncomment to test failsafe
|
43
|
+
return data
|
41
44
|
else
|
42
|
-
|
45
|
+
if failsafe_or_caching_done == true
|
46
|
+
data = response
|
47
|
+
return data
|
48
|
+
else
|
49
|
+
data = response_from_failsafe(path,options)
|
50
|
+
return data
|
51
|
+
end
|
43
52
|
end
|
44
53
|
end
|
45
54
|
end
|
@@ -50,7 +59,11 @@ module AppManager
|
|
50
59
|
return fetch_static_cached_response(cache_key)
|
51
60
|
end
|
52
61
|
response = self.class.send(http_method, path, { body: options, timeout: 10 })
|
53
|
-
|
62
|
+
if response.class.to_s == "HTTParty::Response" && (response.code.to_s.start_with?('2') or response.code.to_s.start_with?('4')) && (response.code.to_s != '429')
|
63
|
+
Rails.cache.write(cache_key, response, expires_in: AppManager.configuration.expires_in)
|
64
|
+
else
|
65
|
+
response = response_from_failsafe(path,options)
|
66
|
+
end
|
54
67
|
return response
|
55
68
|
end
|
56
69
|
|
@@ -399,23 +399,22 @@ module AppManager
|
|
399
399
|
|
400
400
|
def get_local_has_plan(params, options)
|
401
401
|
if params["grandfathered"].present? && params["grandfathered"] == 1
|
402
|
-
return {
|
402
|
+
return {"has_plan" => true}
|
403
403
|
end
|
404
404
|
plans = AppManager::Plan.where(id: params["plan_id"])
|
405
405
|
if plans.any? && plans.first.price == 0
|
406
|
-
return {
|
406
|
+
return {"has_plan" => true}
|
407
407
|
end
|
408
408
|
@remaining_days = get_local_remaining_days(params, options)
|
409
|
-
puts @remaining_days.inspect
|
410
409
|
if (@remaining_days && @remaining_days > 0)
|
411
|
-
return {
|
410
|
+
return {"has_plan" => true}
|
412
411
|
end
|
413
412
|
active_charge = AppManager::Charge.where(status: 'active', shop_domain: params["shop_domain"])
|
414
413
|
if active_charge.any?
|
415
|
-
return {
|
414
|
+
return {"has_plan" => true}
|
416
415
|
end
|
417
416
|
|
418
|
-
return {
|
417
|
+
return {"has_plan" => false}
|
419
418
|
|
420
419
|
end
|
421
420
|
|
data/lib/app_manager/version.rb
CHANGED