app_manager 1.0.2 → 1.0.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 +1 -1
- data/README.md +55 -29
- data/app/controllers/app_manager/plans_controller.rb +16 -9
- data/lib/app_manager/api_cache_handler.rb +4 -4
- data/lib/app_manager/fail_safe.rb +30 -6
- data/lib/app_manager/version.rb +1 -1
- data/lib/app_manager.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4ac086c11bd0f15ee5cc2a4227d9a46c0ea87b835339fb02c9f038c8076ce78
|
4
|
+
data.tar.gz: 1240086895ddad3029dd4faf5609099e56f371ffa771529898e4a2f31c828445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d13d4a9a5de30801b4eadde5fa98880509c1965867a3dc9edaa87cf940f2b10ef9c815b9fe48f0177f8e5cb5fc5696172f77c4b0dcdbdb534d46044f6fa3c1d8
|
7
|
+
data.tar.gz: 10bb4cbdecba1ccd6bdde4d33cf03af33adc7c3d39a49df0a21cff55ae829a25cceb1b3ed7bd3eaa56b8122f77a891ef81b7e93f4e7bc2b1d9c6a2560e681ecf
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,23 +2,55 @@
|
|
2
2
|
|
3
3
|
Welcome to the new gem of Hulkapps.com ! An API wrapper of Hulkapps.com's AppManager portal.
|
4
4
|
|
5
|
-
|
5
|
+
* [Installation](#step1)
|
6
|
+
* [Configuration](#step2)
|
7
|
+
* [Usage](#step3)
|
8
|
+
* [Extras](#step4)
|
6
9
|
|
7
|
-
|
10
|
+
|
11
|
+
<a name="step1"></a>
|
12
|
+
### Installation
|
13
|
+
|
14
|
+
* Add following line to your application's Gemfile:
|
8
15
|
|
9
16
|
```ruby
|
10
17
|
gem 'app_manager'
|
11
18
|
```
|
12
19
|
|
13
|
-
|
20
|
+
* Execute following in terminal:
|
14
21
|
|
22
|
+
```
|
15
23
|
bundle install
|
24
|
+
```
|
25
|
+
```
|
26
|
+
rails g app_manager:install
|
27
|
+
```
|
16
28
|
|
29
|
+
this install command will mount routes in your rails route and will create a config file at ```config/initializers/app_manager.rb```
|
17
30
|
|
18
|
-
rails g app_manager:install
|
19
31
|
|
32
|
+
<a name="step2"></a>
|
33
|
+
### Configuration
|
34
|
+
|
35
|
+
* Set Shopify API version to 2022-04 as app_manager is best compatible with this version.
|
36
|
+
|
37
|
+
|
38
|
+
* Please check the 'shops' table that must have 'plan_id' as int/bigint and 'trial_activated_at' as datetime otherwise add its migration like following example:
|
39
|
+
|
40
|
+
```
|
41
|
+
class AddPlanIdToShops < ActiveRecord::Migration[5.2]
|
42
|
+
def change
|
43
|
+
add_column :shops, :plan_id, :bigint
|
44
|
+
add_column :shops, :trial_activated_at, :datetime
|
45
|
+
end
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
and map these new fields in 'config.field_names' in below initializer file which is generated by install command. Please note: this is important step.
|
50
|
+
|
51
|
+
|
52
|
+
* Please update blank fields in initializer file. Please copy 'uuid' from this [file](https://docs.google.com/spreadsheets/d/1cw2nSKxAHTGn4Cfa98RNdtfHT3zdtwu9bQD7s7hErXc/edit#gid=0) and paste in the following file and make sure that is unique per feature. After copying put your 'app name' next to 'uuid' column in this [file](https://docs.google.com/spreadsheets/d/1cw2nSKxAHTGn4Cfa98RNdtfHT3zdtwu9bQD7s7hErXc/edit#gid=0).
|
20
53
|
|
21
|
-
this install command will mount routes in your rails route and will create a config file at ```config/initializers/app_manager.rb```
|
22
54
|
|
23
55
|
```
|
24
56
|
AppManager.configure do |config|
|
@@ -85,24 +117,15 @@ end
|
|
85
117
|
```
|
86
118
|
|
87
119
|
|
88
|
-
|
89
|
-
|
90
|
-
class AddPlanIdToShops < ActiveRecord::Migration[5.2]
|
91
|
-
def change
|
92
|
-
add_column :shops, :plan_id, :bigint
|
93
|
-
add_column :shops, :trial_activated_at, :datetime
|
94
|
-
end
|
95
|
-
end
|
96
|
-
```
|
97
|
-
|
98
|
-
and map these new fields in 'config.field_names' in above initializer file.
|
99
|
-
|
100
|
-
Step 3) You must have to set ENV variable with key 'APP_MANAGER_ACCESS_TOKEN' in your application.yml or .env file like this:
|
120
|
+
|
121
|
+
* You must have to set ENV variable with key 'APP_MANAGER_ACCESS_TOKEN' in your application.yml or .env file like this:
|
101
122
|
|
123
|
+
```
|
102
124
|
APP_MANAGER_ACCESS_TOKEN: 'XXXXXXXXXXXXXXXXXXX'
|
103
125
|
APP_MANAGER_API_URL: 'https://XXXXXXXX.com'
|
126
|
+
```
|
104
127
|
|
105
|
-
|
128
|
+
* App Manager provides a rake task that must needs to include in your existing app cron for every 10 minutes. Like if you are using [whenever](https://github.com/javan/whenever) gem then you MUST need to include following rake take in your 'schedule.rb' (created by whenever gem)
|
106
129
|
|
107
130
|
```
|
108
131
|
every 10.minutes do
|
@@ -110,7 +133,12 @@ every 10.minutes do
|
|
110
133
|
end
|
111
134
|
```
|
112
135
|
|
113
|
-
|
136
|
+
|
137
|
+
<a name="step3"></a>
|
138
|
+
### Usage
|
139
|
+
|
140
|
+
|
141
|
+
* App Manager provides a helper module which needs to include in your 'shop' model something like below
|
114
142
|
|
115
143
|
```
|
116
144
|
class Shop < ActiveRecord::Base
|
@@ -118,10 +146,7 @@ class Shop < ActiveRecord::Base
|
|
118
146
|
end
|
119
147
|
```
|
120
148
|
|
121
|
-
|
122
|
-
## Usage
|
123
|
-
|
124
|
-
Using above 5th step you can access following methods from your shop object.
|
149
|
+
and then you can use follwing methods with your shop objects.
|
125
150
|
|
126
151
|
```
|
127
152
|
@shop.has_plan # return true or false
|
@@ -137,11 +162,10 @@ Using above 5th step you can access following methods from your shop object.
|
|
137
162
|
```
|
138
163
|
|
139
164
|
|
165
|
+
<a name="step4"></a>
|
166
|
+
### Extras
|
140
167
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
Then, initialize app_manager instance like with App Manager Portal access:
|
168
|
+
* To view the app_manager ruby gem is working in your rails app you can use rails console and initialize app_manager instance like with App Manager Portal access:
|
145
169
|
|
146
170
|
```ruby
|
147
171
|
ob = AppManager::Client.new(ENV['APP_MANAGER_ACCESS_TOKEN'])
|
@@ -152,13 +176,15 @@ To get banners use this command:
|
|
152
176
|
ob.get_banners
|
153
177
|
```
|
154
178
|
|
155
|
-
|
179
|
+
|
180
|
+
* For Vue UI Library in Rails Project:
|
156
181
|
|
157
182
|
Please make sure you have following line in your route file otherwise add this manually.
|
158
183
|
|
159
184
|
mount AppManager::Engine, at: "/"
|
160
185
|
|
161
186
|
|
187
|
+
|
162
188
|
## Development
|
163
189
|
|
164
190
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -63,21 +63,27 @@ module AppManager
|
|
63
63
|
|
64
64
|
def users
|
65
65
|
if model
|
66
|
+
if params[:search]
|
67
|
+
search = params[:search]
|
68
|
+
@shopify_email = AppManager.configuration.field_names['shopify_email']
|
69
|
+
data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%").page(params[:page]).per(10)
|
70
|
+
else
|
66
71
|
data = model.page(params[:page]).per(10)
|
72
|
+
end
|
67
73
|
users = {
|
68
|
-
"current_page" => data.current_page,
|
69
|
-
"data" => data.collect{|st| @field_names.map{ |key, value| [key, "#{st[value]}"] }.to_h },
|
74
|
+
"current_page" => data && data.current_page ? data.current_page : 0,
|
75
|
+
"data" => data ? data.collect{|st| @field_names.map{ |key, value| [key, "#{st[value]}"] }.to_h } : [],
|
70
76
|
"first_page_url" => "#{app_url}/api/app-manager/users?page=1",
|
71
|
-
"from" => data.total_pages ? 1 :
|
72
|
-
"last_page" => data.total_pages,
|
73
|
-
"last_page_url" => data.total_pages ? "#{app_url}/api/app-manager/users?page=#{data.total_pages}" : nil,
|
77
|
+
"from" => data && data.total_pages ? 1 : 0,
|
78
|
+
"last_page" => data && data.total_pages ? data.total_pages : 0,
|
79
|
+
"last_page_url" => data && data.total_pages ? "#{app_url}/api/app-manager/users?page=#{data.total_pages}" : nil,
|
74
80
|
"links"=> '',
|
75
|
-
"next_page_url" => data.next_page ? "#{app_url}/api/app-manager/users?page=#{data.next_page}" : nil,
|
81
|
+
"next_page_url" => data && data.next_page ? "#{app_url}/api/app-manager/users?page=#{data.next_page}" : nil,
|
76
82
|
"path" => "#{app_url}/api/app-manager/users",
|
77
83
|
"per_page" => 1,
|
78
|
-
"prev_page_url" => data.prev_page ? "#{app_url}/api/app-manager/users?page=#{data.prev_page}" : nil,
|
79
|
-
"to" => data.total_pages,
|
80
|
-
"total" => data.total_pages
|
84
|
+
"prev_page_url" => data && data.prev_page ? "#{app_url}/api/app-manager/users?page=#{data.prev_page}" : nil,
|
85
|
+
"to" => data && data.total_pages ? data.total_pages : 0,
|
86
|
+
"total" => data && data.total_pages ? data.total_pages : 0,
|
81
87
|
}
|
82
88
|
render json: users
|
83
89
|
|
@@ -104,6 +110,7 @@ module AppManager
|
|
104
110
|
|
105
111
|
|
106
112
|
def fail_safe_backup
|
113
|
+
AppManager.clear_cache
|
107
114
|
params_permit
|
108
115
|
Thread.new do
|
109
116
|
@fs = AppManager::FailSafe.new
|
@@ -56,10 +56,10 @@ module AppManager
|
|
56
56
|
body = @response_cache.body
|
57
57
|
status = @response_cache.status
|
58
58
|
headers = @response_cache.headers
|
59
|
-
headers.try(:each) do |key, value|
|
60
|
-
|
61
|
-
end
|
62
|
-
@controller.render
|
59
|
+
# headers.try(:each) do |key, value|
|
60
|
+
# @controller.response.headers[key] = value
|
61
|
+
# end
|
62
|
+
@controller.render json: body, status: status
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -12,22 +12,46 @@ module AppManager
|
|
12
12
|
|
13
13
|
def save_api_data(params)
|
14
14
|
Thread.new do
|
15
|
-
|
15
|
+
begin
|
16
|
+
save_api_plans(params["plans"])
|
17
|
+
rescue Exception => e
|
18
|
+
Rails.logger.info "APP MANGAGER >>>> #{e.inspect}"
|
19
|
+
end
|
16
20
|
end
|
17
21
|
Thread.new do
|
18
|
-
|
22
|
+
begin
|
23
|
+
save_api_charges(params["charges"])
|
24
|
+
rescue Exception => e
|
25
|
+
Rails.logger.info "APP MANGAGER >>>> #{e.inspect}"
|
26
|
+
end
|
19
27
|
end
|
20
28
|
Thread.new do
|
21
|
-
|
29
|
+
begin
|
30
|
+
save_api_apps(params["apps"])
|
31
|
+
rescue Exception => e
|
32
|
+
Rails.logger.info "APP MANGAGER >>>> #{e.inspect}"
|
33
|
+
end
|
22
34
|
end
|
23
35
|
Thread.new do
|
24
|
-
|
36
|
+
begin
|
37
|
+
save_api_app_structures(params["app_structures"])
|
38
|
+
rescue Exception => e
|
39
|
+
Rails.logger.info "APP MANGAGER >>>> #{e.inspect}"
|
40
|
+
end
|
25
41
|
end
|
26
42
|
Thread.new do
|
27
|
-
|
43
|
+
begin
|
44
|
+
save_api_discount_plans(params["discount_plans"])
|
45
|
+
rescue Exception => e
|
46
|
+
Rails.logger.info "APP MANGAGER >>>> #{e.inspect}"
|
47
|
+
end
|
28
48
|
end
|
29
49
|
Thread.new do
|
30
|
-
|
50
|
+
begin
|
51
|
+
save_api_extend_trials(params["extend_trials"])
|
52
|
+
rescue Exception => e
|
53
|
+
Rails.logger.info "APP MANGAGER >>>> #{e.inspect}"
|
54
|
+
end
|
31
55
|
end
|
32
56
|
end
|
33
57
|
|
data/lib/app_manager/version.rb
CHANGED
data/lib/app_manager.rb
CHANGED
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.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hulkapps
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|