app_manager 1.2.4 → 1.2.5

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: 9c547a5aa3260006c06faf84cd242801459dc0d6557139d94797558b2e960cf3
4
- data.tar.gz: bb52538ee806521616ca899b526db05d5dfa606921c0a49874584af7d5960ed2
3
+ metadata.gz: b8b130ade59cce66eefb10134bca05802a6f7911e59123a1f8885789547a6c5f
4
+ data.tar.gz: d3fb70f8010e1d70dc1042c28322d5eeb7696cdecef9bd29fdd09e80a9a02e9d
5
5
  SHA512:
6
- metadata.gz: 0cf9d50efcfd4a72bc88a842d1ba7508a56cfe0a4eb29c3226ed526cda19a095125382292093fd2f296ea71c8cdca562039af5dda5b2ba2df34fe4ca05070f8c
7
- data.tar.gz: 6b4db1ea27b42898de5549a5fa528a3df9c759071e228d9a373075766b91086658d632b8427e5d9761382d16c3f46cb2685b5dcb8f33898f4590e3f7dd50f3f9
6
+ metadata.gz: 3fbef0b8ce7194394d942bbf2fd93d1aa52c7b9035be8a98a09ab080c33d047c8e8fe213f66d5cc1396aa326f7d4881d0db47077ffae42a01b1558f8a8c3febc
7
+ data.tar.gz: e2138c8801189e683ae7db8703dbe2703eedfdedca2a87c0a6f00528bb49bcd28436e457aeb77dca3113993599459b25632e190ee85e95521332d43fe018a4a1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_manager (1.2.4)
4
+ app_manager (1.2.5)
5
5
  httparty
6
6
  kaminari (>= 0.16.3)
7
7
  rails (>= 5.2.0)
@@ -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")
@@ -74,7 +74,7 @@ module AppManager
74
74
  plan_field = AppManager.configuration.field_names['plan_id']
75
75
  plan_id = self[plan_field]
76
76
  plan_obj = AppManager::Client.new
77
- shop_domain ? plan_obj.get_remaining_days(shop_domain,trial_activated_at_val,plan_id) : 0
77
+ return shop_domain ? plan_obj.get_remaining_days(shop_domain,trial_activated_at_val,plan_id) : 0
78
78
  rescue Exception => e
79
79
  return "#{e.inspect}"
80
80
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppManager
4
- VERSION = "1.2.4"
4
+ VERSION = "1.2.5"
5
5
  end
data/lib/app_manager.rb CHANGED
@@ -27,7 +27,11 @@ module AppManager
27
27
  end
28
28
 
29
29
  def self.clear_cache
30
- Rails.cache.delete_matched('app-manager-cache/*')
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
4
+ version: 1.2.5
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-06 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty