app_manager 1.3.0 → 1.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: ccc14af26b2bc149bba059ef2c7d45e58bc0d8460f02141d26edce1ba465aaeb
4
- data.tar.gz: 51da1f98e7d8bb114e3adbf80cfe510fd66caa7965525adf0cb98c8ad4fa5ca0
3
+ metadata.gz: 9b43df1c21cb67c078b9a24c4152573750ffcaf7e13e9748380c642ebe62a7f1
4
+ data.tar.gz: 1d0e8f8dff11ff42024d85999189384408b663b6d196798d415ba6eed1ff606f
5
5
  SHA512:
6
- metadata.gz: 13238860ae46955c3c6fa71e304d0be8e29b30c2940d29ff07e8b31e724bf887349f4148c452e137b4b5d0f551e1e047f9ca16a413cb09788795dacc304dbc75
7
- data.tar.gz: 18d9de82d48bcaa9dd9dff5a4cc8473d704c06096228e3a2148a26d2022ef6b8c71a6bb45cf877f9296ed391e33508fa7368ecc0b77eac8ed77c2dc25d100129
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.0)
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
- # 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
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
- # begin
169
+ begin
170
170
  @fs.save_api_data(params)
171
- # rescue Exception => e
172
- # Rails.logger.info "APP MANAGER >>>> #{e.inspect}"
173
- # end
174
- # AppManager.clear_cache
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
- if http_method.to_s == 'get'
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
- data = response_from_failsafe(path,options)
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
- Rails.cache.write(cache_key, response, expires_in: AppManager.configuration.expires_in)
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 {:has_plan => true}
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 {:has_plan => true}
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 {:has_plan => true}
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 {:has_plan => true}
414
+ return {"has_plan" => true}
416
415
  end
417
416
 
418
- return {:has_plan => false}
417
+ return {"has_plan" => false}
419
418
 
420
419
  end
421
420
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppManager
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hulkapps