app_manager 1.1.3 → 1.1.6
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 -2
- data/README.md +2 -2
- data/app/controllers/app_manager/plans_controller.rb +18 -3
- data/lib/app_manager/client/connection.rb +3 -3
- data/lib/app_manager/fail_safe.rb +46 -8
- data/lib/app_manager/model.rb +3 -3
- data/lib/app_manager/version.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: 3c7139d80f35a011691ed85a8f0d62f164210fc1a2e1ab830bdd29820f0dff49
|
4
|
+
data.tar.gz: 7ea3211619b2e2ff457bc87929bf3879dafe5471aa3771427137251f33f386f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fccc462df489a3ddfcd71a371b0ab41ca35e0358fcbc0220f1ef477d8fabf6419036b5ce4b37d4d33f3f93b2426987c0ef8588b6a9cce5d3025dc98330d28d02
|
7
|
+
data.tar.gz: af2479eee70e4bcb9be2503b45fa09a70eae273c8f46357642000dc7f8d9dc5b821e7c5393caba6f1b87245c8b72fcf0d75ee07253d4f25b2214f038874da68e
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
app_manager (1.1.
|
4
|
+
app_manager (1.1.6)
|
5
5
|
httparty
|
6
6
|
kaminari (>= 0.16.3)
|
7
7
|
rails (>= 5.2.0)
|
@@ -147,7 +147,7 @@ GEM
|
|
147
147
|
public_suffix (4.0.6)
|
148
148
|
racc (1.6.0)
|
149
149
|
rack (2.2.3.1)
|
150
|
-
rack-test (2.0.
|
150
|
+
rack-test (2.0.2)
|
151
151
|
rack (>= 1.3)
|
152
152
|
rails (7.0.3)
|
153
153
|
actioncable (= 7.0.3)
|
data/README.md
CHANGED
@@ -168,9 +168,9 @@ and then you can use follwing methods with your shop objects.
|
|
168
168
|
|
169
169
|
@shop.get_remaining_days # return integer based on trial activated date.
|
170
170
|
|
171
|
-
@shop.get_plan # return
|
171
|
+
@shop.get_plan # return current plan hash
|
172
172
|
|
173
|
-
@shop.get_charge # return
|
173
|
+
@shop.get_charge # return current charge hash
|
174
174
|
```
|
175
175
|
|
176
176
|
|
@@ -70,12 +70,27 @@ module AppManager
|
|
70
70
|
|
71
71
|
def users
|
72
72
|
if model
|
73
|
-
|
73
|
+
|
74
74
|
search = params[:search]
|
75
|
+
sort = params[:sort] || AppManager.configuration.field_names['created_at']
|
76
|
+
order = params[:order] || 'asc'
|
77
|
+
plans = params[:plans] || nil
|
78
|
+
plans = plans.values if !plans.nil?
|
79
|
+
shopify_plans = params[:shopify_plans] || nil
|
80
|
+
shopify_plans = shopify_plans.values if !shopify_plans.nil?
|
81
|
+
items_per_page = params[:itemsPerPage] || 25
|
75
82
|
@shopify_email = AppManager.configuration.field_names['shopify_email']
|
76
|
-
|
83
|
+
@shopify_plan_name_field = AppManager.configuration.field_names['shopify_plan']
|
84
|
+
data = model
|
85
|
+
if params[:search]
|
86
|
+
data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%")
|
87
|
+
data = data.where(@plan_field => plans) if !plans.nil?
|
88
|
+
data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
|
89
|
+
data = data.page(params[:page]).per(items_per_page)
|
77
90
|
else
|
78
|
-
data = model.
|
91
|
+
data = model.where(@plan_field => plans) if !plans.nil?
|
92
|
+
data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
|
93
|
+
data = data.page(params[:page]).per(items_per_page)
|
79
94
|
end
|
80
95
|
users = {
|
81
96
|
"current_page" => data && data.current_page ? data.current_page : 0,
|
@@ -60,9 +60,9 @@ module AppManager
|
|
60
60
|
@fs = AppManager::FailSafe.new
|
61
61
|
case path
|
62
62
|
when "static-contents"
|
63
|
-
return @fs.get_local_app_structures
|
63
|
+
return @fs.get_local_app_structures
|
64
64
|
when 'plans'
|
65
|
-
return @fs.get_local_plans(params)
|
65
|
+
return @fs.get_local_plans(params)
|
66
66
|
when 'plan'
|
67
67
|
return @fs.get_local_plan(params)
|
68
68
|
when 'store-charge'
|
@@ -70,7 +70,7 @@ module AppManager
|
|
70
70
|
when 'cancel-charge'
|
71
71
|
return @fs.store_cancel_charge(params,options)
|
72
72
|
when 'get-remaining-days'
|
73
|
-
return @fs.get_local_remaining_days(params,options)
|
73
|
+
return @fs.get_local_remaining_days(params,options)
|
74
74
|
when 'get-charge'
|
75
75
|
return @fs.get_local_charge(params,options)
|
76
76
|
else
|
@@ -1,13 +1,23 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'date'
|
3
3
|
require 'time'
|
4
|
+
require "fileutils"
|
5
|
+
|
4
6
|
module AppManager
|
5
7
|
|
6
8
|
class FailSafe
|
7
9
|
|
8
10
|
def initialize(db_name='app_manager_local')
|
9
11
|
@apm_db = SQLite3::Database.open "db/#{db_name}.db"
|
12
|
+
FileUtils.chmod 0755, "db/#{db_name}.db"
|
10
13
|
@apm_db.results_as_hash = true
|
14
|
+
create_plan_table
|
15
|
+
create_charges_table
|
16
|
+
create_apps_table
|
17
|
+
create_app_structures_table
|
18
|
+
create_discount_plans_table
|
19
|
+
create_extend_trials_table
|
20
|
+
create_plan_users_table
|
11
21
|
end
|
12
22
|
|
13
23
|
def save_api_data(params)
|
@@ -50,7 +60,7 @@ module AppManager
|
|
50
60
|
|
51
61
|
def save_api_plans(plans)
|
52
62
|
@apm_db.execute("DROP TABLE IF EXISTS plans;")
|
53
|
-
|
63
|
+
create_plan_table
|
54
64
|
|
55
65
|
if plans.any?
|
56
66
|
plans.each do |plan|
|
@@ -75,7 +85,7 @@ module AppManager
|
|
75
85
|
|
76
86
|
def save_api_charges(charges)
|
77
87
|
@apm_db.execute("DROP TABLE IF EXISTS charges;")
|
78
|
-
|
88
|
+
create_charges_table
|
79
89
|
if charges.any?
|
80
90
|
charges.each do |charge|
|
81
91
|
charge_test = charge['test'] ? 1 : 0
|
@@ -87,7 +97,7 @@ module AppManager
|
|
87
97
|
|
88
98
|
def save_api_apps(apps)
|
89
99
|
@apm_db.execute("DROP TABLE IF EXISTS apps;")
|
90
|
-
|
100
|
+
create_apps_table
|
91
101
|
if apps.any?
|
92
102
|
apps.each do |app|
|
93
103
|
@apm_db.execute("INSERT INTO apps (id ,name ,slug ,url ,image ,api_token ,slack , created_at , updated_at ) VALUES (?,?,?,?,?,?,?,?,?)", app['id'],app['name'],app['slug'],app['url'],app['image'],app['api_token'],app['slack'],app['created_at'],app['updated_at'])
|
@@ -98,15 +108,15 @@ module AppManager
|
|
98
108
|
|
99
109
|
def save_api_app_structures(app_structures)
|
100
110
|
@apm_db.execute("DROP TABLE IF EXISTS app_structures;")
|
101
|
-
|
111
|
+
create_app_structures_table
|
102
112
|
if !app_structures.nil?
|
103
113
|
@apm_db.execute("INSERT INTO app_structures (banners) VALUES (?)", "#{app_structures.to_h}")
|
104
114
|
end
|
105
115
|
end
|
106
116
|
|
107
117
|
def save_api_discount_plans(discount_plans)
|
108
|
-
|
109
|
-
|
118
|
+
@apm_db.execute("DROP TABLE IF EXISTS discount_plans;")
|
119
|
+
create_discount_plans_table
|
110
120
|
if discount_plans.any?
|
111
121
|
discount_plans.each do |discount_plan|
|
112
122
|
@apm_db.execute("INSERT INTO discount_plans (id ,discount ,shop_domain ,cycle_count ,plan_id , created_by ,created_at ,updated_at ,app_id ,discount_type ) VALUES (?,?,?,?,?,?,?,?,?,?)", discount_plan['id'],discount_plan['discount'],discount_plan['shop_domain'],discount_plan['cycle_count'],discount_plan['plan_id'],discount_plan['created_by'],discount_plan['created_at'],discount_plan['updated_at'],discount_plan['app_id'],discount_plan['discount_type'])
|
@@ -116,7 +126,7 @@ module AppManager
|
|
116
126
|
|
117
127
|
def save_api_extend_trials(extend_trials)
|
118
128
|
@apm_db.execute("DROP TABLE IF EXISTS extend_trials;")
|
119
|
-
|
129
|
+
create_extend_trials_table
|
120
130
|
if extend_trials.any?
|
121
131
|
extend_trials.each do |extend_trial|
|
122
132
|
@apm_db.execute("INSERT INTO extend_trials (id ,shop_domain ,plan_id ,app_id ,days ,created_by ,created_at ,updated_at ,extend_trial_start_at ) VALUES (?,?,?,?,?,?,?,?,?)", extend_trial['id'], extend_trial['shop_domain'], extend_trial['plan_id'], extend_trial['app_id'], extend_trial['days'], extend_trial['created_by'], extend_trial['created_at'], extend_trial['updated_at'], extend_trial['extend_trial_start_at'])
|
@@ -126,7 +136,7 @@ module AppManager
|
|
126
136
|
|
127
137
|
def save_api_plan_users(plan_users)
|
128
138
|
@apm_db.execute("DROP TABLE IF EXISTS plan_users;")
|
129
|
-
|
139
|
+
create_plan_users_table
|
130
140
|
if plan_users.any?
|
131
141
|
plan_users.each do |plan_user|
|
132
142
|
@apm_db.execute("INSERT INTO plan_users (id ,shop_domain, plan_id, created_by, created_at, updated_at ) VALUES (?,?,?,?,?,?)", plan_user['id'], plan_user['shop_domain'], plan_user['plan_id'], plan_user['created_by'], plan_user['created_at'], plan_user['updated_at'])
|
@@ -150,6 +160,34 @@ module AppManager
|
|
150
160
|
return app_structures
|
151
161
|
end
|
152
162
|
|
163
|
+
def create_plan_table
|
164
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS plans(id integer,type varchar(255), name varchar(255), price float, offer_text varchar(255), description varchar(255), interval text, shopify_plans text, trial_days integer, test boolean, on_install integer, is_custom boolean, app_id integer, base_plan integer, created_at datetime, updated_at datetime, public boolean, discount integer, cycle_count integer, store_base_plan boolean, choose_later_plan boolean, discount_type varchar(255), affiliate text, features text, deleted_at datetime)"
|
165
|
+
end
|
166
|
+
|
167
|
+
def create_charges_table
|
168
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS charges(id INTEGER PRIMARY KEY,charge_id varchar(255),test boolean, status varchar(255),name varchar(255), type varchar(255), price float,interval varchar(255),trial_days integer,billing_on datetime,activated_on datetime,trial_ends_on datetime,cancelled_on datetime, expires_on datetime,plan_id integer,description text,shop_domain varchar(255),created_at datetime, updated_at datetime, app_id integer, sync boolean DEFAULT 0,process_type varchar(255))"
|
169
|
+
end
|
170
|
+
|
171
|
+
def create_apps_table
|
172
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS apps(id integer,name varchar(255),slug varchar(255),url varchar(255),image varchar(255),api_token varchar(255),slack varchar(255), created_at datetime, updated_at datetime)"
|
173
|
+
end
|
174
|
+
|
175
|
+
def create_app_structures_table
|
176
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS app_structures(banners text)"
|
177
|
+
end
|
178
|
+
|
179
|
+
def create_discount_plans_table
|
180
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS discount_plans(id integer,discount integer,shop_domain varchar(255),cycle_count integer,plan_id integer, created_by integer,created_at datetime,updated_at datetime,app_id integer,discount_type varchar(255))"
|
181
|
+
end
|
182
|
+
|
183
|
+
def create_extend_trials_table
|
184
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS extend_trials(id integer,shop_domain varchar(255),plan_id integer,app_id integer,days integer,created_by integer,created_at datetime,updated_at datetime,extend_trial_start_at datetime)"
|
185
|
+
end
|
186
|
+
|
187
|
+
def create_plan_users_table
|
188
|
+
@apm_db.execute "CREATE TABLE IF NOT EXISTS plan_users(id integer,shop_domain varchar(255),plan_id integer,created_by integer,created_at datetime,updated_at datetime)"
|
189
|
+
end
|
190
|
+
|
153
191
|
|
154
192
|
def get_local_plans(params)
|
155
193
|
plans_data = []
|
data/lib/app_manager/model.rb
CHANGED
@@ -20,9 +20,9 @@ module AppManager
|
|
20
20
|
if remaining_days > 0
|
21
21
|
return true
|
22
22
|
end
|
23
|
-
shopify_fields = @field_names = AppManager.configuration.field_names
|
24
23
|
plan_obj = AppManager::Client.new
|
25
|
-
|
24
|
+
shop_domain = self[AppManager.configuration.shopify_domain_field]
|
25
|
+
active_charge = plan_obj.get_charge(shop_domain) rescue nil
|
26
26
|
return active_charge['active_charge'].present? && !active_charge['active_charge'].nil? ? true : false
|
27
27
|
end
|
28
28
|
|
@@ -134,7 +134,7 @@ module AppManager
|
|
134
134
|
end
|
135
135
|
return plan_data
|
136
136
|
else
|
137
|
-
return
|
137
|
+
return []
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
data/lib/app_manager/version.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.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hulkapps
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|