app_manager 1.2.7 → 1.3.0

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.
@@ -1,210 +1,213 @@
1
1
  require_dependency "app_manager/application_controller"
2
2
 
3
3
  module AppManager
4
- class PlansController < ApplicationController
5
- cache_response_for :plans
6
- cache_response_for :index
7
- cache_response_for :users
8
- skip_before_action :verify_authenticity_token, :only => [:active_without_plan,:burst_cache,:fail_safe_backup]
9
- def index
10
- render :json => {"features" => AppManager.configuration.plan_features || []}
11
- end
12
-
13
-
14
- def plans
15
- active_plan_id_or_name = shopify_plan = plan = nil
16
- active_charge = nil
17
- default_plan_id = nil
18
- choose_later = false
19
- trial_activated_at = nil
20
- plan_obj = AppManager::Client.new
21
- plans = []
22
- if params[:shop_domain].present? && !AppManager.configuration.plan_features.nil?
23
- @shop = shop_data
24
- if !@shop.nil?
25
- active_plan_id_or_name = @shop[@plan_field] rescue nil
26
- plans = plan_obj.get_plans(params[:shop_domain],active_plan_id_or_name)
27
- if !@field_names.nil? && @field_names.has_key?('shopify_plan') && !@field_names.nil?
28
- shopify_plan_field = AppManager.configuration.field_names['shopify_plan']
29
- shopify_plan = @shop[shopify_plan_field] rescue nil
30
- plan = plans && plans.any? && !active_plan_id_or_name.nil? ? (plans.find{|x| x["id"] == active_plan_id_or_name}.present? ? plans.find{|x| x["id"] == active_plan_id_or_name} : nil ) : nil
31
-
32
- @trial_activated_field = AppManager.configuration.field_names['trial_activated_at']
33
- trial_activated_at = @shop[@trial_activated_field] rescue nil
34
- active_charge = plan_obj.get_charge(params[:shop_domain])
35
- if active_charge && active_charge.any? && active_charge['active_charge'].nil? && active_charge['cancelled_charge'].nil? && !trial_activated_at && !plan
36
- choose_later = true
37
- end
38
-
39
- end
40
- else
41
- Rails.logger.info "APP MANAGER >>>> Either model is defined wrong or config.plan_id_or_name_field is nil in initializer ==="
42
- end
43
- else
44
- Rails.logger.info "APP MANAGER >>>> Either params missing store_domain or config.plan_features is nil in initializer ==="
45
- end
46
-
47
-
48
- plans = plan_obj.get_plans(params[:shop_domain]) if plans && plans.blank?
49
- default_plan_data = plans.select{|x| x['choose_later_plan'] == true }
50
- if default_plan_data.any?
51
- if default_plan_data.select{|x| x['store_base_plan'] == true }.size > 0
52
- shopify_plans = plans.select{|x| x['interval'] == 'EVERY_30_DAYS' }
53
- shopify_plans.each do |shp|
54
- if shp && shp["shopify_plans"].include?(shopify_plan)
55
- default_plan_id = shp["id"]
56
- break
57
- end
58
- end
59
- else
60
- default_plan_id = default_plan_data.map{|e| e['id']}.first if default_plan_data.any? rescue nil
61
- end
62
- end
63
-
64
- response = {
65
- 'plans' => plans,
66
- 'shopify_plan' => shopify_plan,
67
- 'plan' => plan,
68
- 'default_plan_id' => default_plan_id,
69
- 'choose_later' => choose_later,
70
- 'has_active_charge' => (((active_charge && active_charge.any? && !active_charge['active_charge'].nil?) or !trial_activated_at) ? true : false)
71
- }
72
- render json: response
73
- end
74
-
75
- def users
76
- if model
77
-
78
- search = params[:search]
79
- sort = params[:sort] || AppManager.configuration.field_names['created_at']
80
- order = params[:order] || 'asc'
81
- plans = params[:plans] || nil
82
- plans = plans.values if !plans.nil?
83
- shopify_plans = params[:shopify_plans] || nil
84
- shopify_plans = shopify_plans.values if !shopify_plans.nil?
85
- items_per_page = params[:itemsPerPage] || 25
86
- @shopify_email = AppManager.configuration.field_names['shopify_email']
87
- @shopify_plan_name_field = AppManager.configuration.field_names['shopify_plan']
88
- data = model
89
- if params[:search]
90
- data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%")
91
- data = data.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)
94
- else
95
- data = model.where(@plan_field => plans) if !plans.nil?
96
- data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
97
- data = data.page(params[:page]).per(items_per_page)
98
- end
99
- users = {
100
- "current_page" => data && data.current_page ? data.current_page : 0,
101
- "data" => data ? data.collect{|st| @field_names.map{ |key, value| [key, "#{st[value]}"] }.to_h } : [],
102
- "first_page_url" => "#{app_url}/api/app-manager/users?page=1",
103
- "from" => data && data.total_pages ? 1 : 0,
104
- "last_page" => data && data.total_pages ? data.total_pages : 0,
105
- "last_page_url" => data && data.total_pages ? "#{app_url}/api/app-manager/users?page=#{data.total_pages}" : nil,
106
- "links"=> '',
107
- "next_page_url" => data && data.next_page ? "#{app_url}/api/app-manager/users?page=#{data.next_page}" : nil,
108
- "path" => "#{app_url}/api/app-manager/users",
109
- "per_page" => 1,
110
- "prev_page_url" => data && data.prev_page ? "#{app_url}/api/app-manager/users?page=#{data.prev_page}" : nil,
111
- "to" => data && data.total_pages ? data.total_pages : 0,
112
- "total" => data && data.total_pages ? data.total_pages : 0,
113
- }
114
- render json: users
115
-
116
- else
117
- render json: nil
118
- end
119
- end
120
-
121
- def active_without_plan
122
- if params[:shop_domain].present? && params[:plan_id].present? && model
123
- @shop = shop_data
124
- @trial_activated_field = AppManager.configuration.field_names['trial_activated_at']
125
- if @shop.update(@plan_field => params[:plan_id],@trial_activated_field => DateTime.now)
126
- begin
127
- plan_obj = AppManager::Client.new
128
- plan_data = plan_obj.get_plan(params[:plan_id],params[:shop_domain]) rescue nil
129
- AppManager::EventHandler.new('charge_created',{
130
- "plan" => plan_data,
131
- "charge" => nil,
132
- "previous_charge" => nil,
133
- "choose_later" => true,
134
- "shopify_domain" => params[:shop_domain]
135
- })
136
- rescue Exception => e
137
- Rails.logger.info "APP MANAGER >>>> #{e.inspect}"
138
- end
139
- render json: {'status' => true}
140
- else
141
- render json: {'status' => false,'error' => "#{@shop.errors.full_messages.to_sentence}"}, status: 422
142
- end
143
- else
144
- render json: {'status' => false,'error' => 'Shop not found or missing shop'}, status: 422
145
- end
146
- end
147
-
148
-
149
- def burst_cache
150
- AppManager.clear_cache
151
- head :ok
152
- end
153
-
154
-
155
- def fail_safe_backup
156
- params_permit
157
- Thread.new do
158
- @fs = AppManager::FailSafe.new
159
- begin
160
- @fs.sync_app_manager
161
- rescue Exception => e
162
- Rails.logger.info "APP MANAGER >>>> LOCAL DB couldn't sync with POTAL DB #{e.inspect}"
163
- end
164
-
165
- begin
166
- @fs.save_api_data(params)
167
- rescue Exception => e
168
- Rails.logger.info "APP MANAGER >>>> #{e.inspect}"
169
- end
170
- AppManager.clear_cache
171
- end
172
- head :ok
173
- end
174
-
175
-
176
-
177
- private
178
-
179
- def params_permit
180
- params.permit!
181
- end
182
-
183
- def model
184
- @models = ActiveRecord::Base.connection.tables
185
- @config_table = AppManager.configuration.shopify_table_name
186
- @shopify_domain = AppManager.configuration.shopify_domain_field
187
- @plan_field = AppManager.configuration.plan_id_or_name_field
188
- @field_names = AppManager.configuration.field_names
189
- @api_version = AppManager.configuration.shopify_api_version
190
- if @models.include?(@config_table) && !@plan_field.nil?
191
- return @config_table.classify.constantize
192
- else
193
- return nil
194
- end
4
+ class PlansController < ApplicationController
5
+ cache_response_for :plans
6
+ cache_response_for :index
7
+ cache_response_for :users
8
+ skip_before_action :verify_authenticity_token, :only => [:active_without_plan, :burst_cache, :fail_safe_backup]
9
+
10
+ def index
11
+ render :json => {"features" => AppManager.configuration.plan_features || []}
12
+ end
13
+
14
+
15
+ def plans
16
+ active_plan_id_or_name = nil
17
+ shopify_plan = nil
18
+ plan = nil
19
+ active_charge = nil
20
+ default_plan_id = nil
21
+ choose_later = false
22
+ trial_activated_at = nil
23
+ plan_obj = AppManager::Client.new
24
+ plans = []
25
+ if params[:shop_domain].present? && !AppManager.configuration.plan_features.nil?
26
+ @shop = shop_data
27
+ if !@shop.nil?
28
+ active_plan_id_or_name = @shop[@plan_field] rescue nil
29
+ plans = plan_obj.get_plans(params[:shop_domain], active_plan_id_or_name)
30
+ # render json: plans and return #use this to test plan failsafe api
31
+ if !@field_names.nil? && @field_names.has_key?('shopify_plan') && !@field_names.nil?
32
+ shopify_plan_field = AppManager.configuration.field_names['shopify_plan']
33
+ shopify_plan = @shop[shopify_plan_field] rescue nil
34
+ plan = plans && plans.any? && !active_plan_id_or_name.nil? ? (plans.find { |x| x["id"] == active_plan_id_or_name }.present? ? plans.find { |x| x["id"] == active_plan_id_or_name } : nil) : nil
35
+
36
+ @trial_activated_field = AppManager.configuration.field_names['trial_activated_at']
37
+ trial_activated_at = @shop[@trial_activated_field] rescue nil
38
+ active_charge = plan_obj.get_charge(params[:shop_domain])
39
+ if active_charge && active_charge.any? && active_charge['active_charge'].nil? && active_charge['cancelled_charge'].nil? && !trial_activated_at && !plan
40
+ choose_later = true
41
+ end
42
+
43
+ end
44
+ else
45
+ Rollbar.error("APP MANAGER >>>> Either model is defined wrong or config.plan_id_or_name_field is nil in initializer ===")
195
46
  end
196
-
197
- def shop_data
198
- if model
199
- return model.where(@shopify_domain => params[:shop_domain]).first rescue nil
200
- else
201
- return nil
202
- end
203
- end
204
-
205
- def app_url
206
- AppManager.configuration.app_url
207
- end
208
-
209
- end
210
- end
47
+ else
48
+ Rollbar.error("APP MANAGER >>>> Either params missing store_domain or config.plan_features is nil in initializer ===")
49
+ end
50
+
51
+
52
+ plans = plan_obj.get_plans(params[:shop_domain]) if plans && plans.blank?
53
+ default_plan_data = plans.select { |x| x['choose_later_plan'] == true }
54
+ if default_plan_data.any?
55
+ if default_plan_data.select { |x| x['store_base_plan'] == true }.size > 0
56
+ shopify_plans = plans.select { |x| x['interval'] == 'EVERY_30_DAYS' }
57
+ shopify_plans.each do |shp|
58
+ if shp && shp["shopify_plans"].include?(shopify_plan)
59
+ default_plan_id = shp["id"]
60
+ break
61
+ end
62
+ end
63
+ else
64
+ default_plan_id = default_plan_data.map { |e| e['id'] }.first if default_plan_data.any? rescue nil
65
+ end
66
+ end
67
+
68
+ response = {
69
+ 'plans' => plans,
70
+ 'shopify_plan' => shopify_plan,
71
+ 'plan' => plan,
72
+ 'default_plan_id' => default_plan_id,
73
+ 'choose_later' => choose_later,
74
+ 'has_active_charge' => (((active_charge && active_charge.any? && !active_charge['active_charge'].nil?) or !trial_activated_at) ? true : false)
75
+ }
76
+ render json: response
77
+ end
78
+
79
+ def users
80
+ if model
81
+
82
+ search = params[:search]
83
+ sort = params[:sort] || AppManager.configuration.field_names['created_at']
84
+ order = params[:order] || 'asc'
85
+ plans = params[:plans] || nil
86
+ plans = plans.values if !plans.nil?
87
+ shopify_plans = params[:shopify_plans] || nil
88
+ shopify_plans = shopify_plans.values if !shopify_plans.nil?
89
+ items_per_page = params[:itemsPerPage] || 25
90
+ @shopify_email = AppManager.configuration.field_names['shopify_email']
91
+ @shopify_plan_name_field = AppManager.configuration.field_names['shopify_plan']
92
+ data = model
93
+ if params[:search]
94
+ data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%")
95
+ data = data.where(@plan_field => plans) if !plans.nil?
96
+ data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
97
+ data = data.page(params[:page]).per(items_per_page)
98
+ else
99
+ data = model.where(@plan_field => plans) if !plans.nil?
100
+ data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
101
+ data = data.page(params[:page]).per(items_per_page)
102
+ end
103
+ users = {
104
+ "current_page" => data && data.current_page ? data.current_page : 0,
105
+ "data" => data ? data.collect { |st| @field_names.map { |key, value| [key, "#{st[value]}"] }.to_h } : [],
106
+ "first_page_url" => "#{app_url}/api/app-manager/users?page=1",
107
+ "from" => data && data.total_pages ? 1 : 0,
108
+ "last_page" => data && data.total_pages ? data.total_pages : 0,
109
+ "last_page_url" => data && data.total_pages ? "#{app_url}/api/app-manager/users?page=#{data.total_pages}" : nil,
110
+ "links" => '',
111
+ "next_page_url" => data && data.next_page ? "#{app_url}/api/app-manager/users?page=#{data.next_page}" : nil,
112
+ "path" => "#{app_url}/api/app-manager/users",
113
+ "per_page" => 1,
114
+ "prev_page_url" => data && data.prev_page ? "#{app_url}/api/app-manager/users?page=#{data.prev_page}" : nil,
115
+ "to" => data && data.total_pages ? data.total_pages : 0,
116
+ "total" => data && data.total_pages ? data.total_pages : 0,
117
+ }
118
+ render json: users
119
+
120
+ else
121
+ render json: nil
122
+ end
123
+ end
124
+
125
+ def active_without_plan
126
+ if params[:shop_domain].present? && params[:plan_id].present? && model
127
+ @shop = shop_data
128
+ @trial_activated_field = AppManager.configuration.field_names['trial_activated_at']
129
+ if @shop.update(@plan_field => params[:plan_id], @trial_activated_field => DateTime.now)
130
+ begin
131
+ plan_obj = AppManager::Client.new
132
+ plan_data = plan_obj.get_plan(params[:plan_id], params[:shop_domain]) rescue nil
133
+ AppManager::EventHandler.new('charge_created', {
134
+ "plan" => plan_data,
135
+ "charge" => nil,
136
+ "previous_charge" => nil,
137
+ "choose_later" => true,
138
+ "shopify_domain" => params[:shop_domain]
139
+ })
140
+ rescue Exception => e
141
+ Rollbar.error("APP MANAGER Error in Active without plan method #{e}")
142
+ end
143
+ render json: {'status' => true}
144
+ else
145
+ render json: {'status' => false, 'error' => "#{@shop.errors.full_messages.to_sentence}"}, status: 422
146
+ end
147
+ else
148
+ render json: {'status' => false, 'error' => 'Shop not found or missing shop'}, status: 422
149
+ end
150
+ end
151
+
152
+
153
+ def burst_cache
154
+ AppManager.clear_cache
155
+ head :ok
156
+ end
157
+
158
+
159
+ def fail_safe_backup
160
+ params_permit
161
+ Thread.new do
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
168
+
169
+ # begin
170
+ @fs.save_api_data(params)
171
+ # rescue Exception => e
172
+ # Rails.logger.info "APP MANAGER >>>> #{e.inspect}"
173
+ # end
174
+ # AppManager.clear_cache
175
+ end
176
+ head :ok
177
+ end
178
+
179
+
180
+ private
181
+
182
+ def params_permit
183
+ params.permit!
184
+ end
185
+
186
+ def model
187
+ @models = ActiveRecord::Base.connection.tables
188
+ @config_table = AppManager.configuration.shopify_table_name
189
+ @shopify_domain = AppManager.configuration.shopify_domain_field
190
+ @plan_field = AppManager.configuration.plan_id_or_name_field
191
+ @field_names = AppManager.configuration.field_names
192
+ @api_version = AppManager.configuration.shopify_api_version
193
+ if @models.include?(@config_table) && !@plan_field.nil?
194
+ return @config_table.classify.constantize
195
+ else
196
+ return nil
197
+ end
198
+ end
199
+
200
+ def shop_data
201
+ if model
202
+ return model.where(@shopify_domain => params[:shop_domain]).first rescue nil
203
+ else
204
+ return nil
205
+ end
206
+ end
207
+
208
+ def app_url
209
+ AppManager.configuration.app_url
210
+ end
211
+
212
+ end
213
+ end
@@ -0,0 +1,5 @@
1
+ module AppManager
2
+ class App < AppManagerRecord
3
+ self.table_name = "apps"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module AppManager
2
+
3
+ class AppManagerRecord < ApplicationRecord
4
+ self.abstract_class = true
5
+ connects_to database: { writing: :app_manager }
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module AppManager
2
+ class AppStructure < AppManagerRecord
3
+ self.table_name = "app_structures"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module AppManager
2
+ class Charge < AppManagerRecord
3
+ self.inheritance_column = nil
4
+ self.table_name = "charges"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module AppManager
2
+ class DiscountPlan < AppManagerRecord
3
+ self.table_name = "discount_plans"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module AppManager
2
+ class ExtendTrial < AppManagerRecord
3
+ self.table_name = "extend_trials"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module AppManager
2
+ class Plan < AppManagerRecord
3
+ self.inheritance_column = nil
4
+ self.table_name = "plans"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module AppManager
2
+ class PlanUser < AppManagerRecord
3
+ self.table_name = "plan_users"
4
+ end
5
+ end
data/app_manager.gemspec CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency "httparty"
34
34
  spec.add_dependency "rails", '>= 5.2.0'
35
35
  spec.add_dependency "kaminari", '>= 0.16.3'
36
- spec.add_dependency "sqlite3", '~> 1.4.4'
36
+ # spec.add_dependency "sqlite3", '~> 1.3.0'
37
37
  # For more information and examples about making a new gem, checkout our
38
38
  # guide at: https://bundler.io/guides/creating_gem.html
39
39
  end
@@ -23,7 +23,6 @@ module AppManager
23
23
  private
24
24
 
25
25
  def request(http_method, path, options)
26
- begin
27
26
  if http_method.to_s == 'get'
28
27
  response = response_from_cache_for_api(http_method, path, options)
29
28
  else
@@ -38,15 +37,12 @@ module AppManager
38
37
  if response.code.to_s.start_with?('2') or response.code.to_s.start_with?('4')
39
38
  data = response.parsed_response
40
39
  data = parse_data(response.parsed_response)
41
- # data = response_from_failsafe(path,options)
40
+ data = response_from_failsafe(path,options)
42
41
  else
43
42
  data = response_from_failsafe(path,options)
44
43
  end
45
44
  end
46
- rescue Exception => e
47
- data = response_from_failsafe(path,options)
48
- end
49
- end
45
+ end
50
46
 
51
47
  def response_from_cache_for_api(http_method, path, options)
52
48
  cache_key = "app-manager-cache/#{path}"
@@ -92,7 +88,9 @@ module AppManager
92
88
  when 'get-remaining-days'
93
89
  return @fs.get_local_remaining_days(params,options)
94
90
  when 'get-charge'
95
- return @fs.get_local_charge(params,options)
91
+ return @fs.get_local_charge(params,options)
92
+ when 'has-plan'
93
+ return @fs.get_local_has_plan(params, options)
96
94
  else
97
95
  return nil
98
96
  end
@@ -1,48 +1,48 @@
1
1
  module AppManager
2
- class Client
3
- module Plans
2
+ class Client
3
+ module Plans
4
4
 
5
- def get_plans(shop_domain,active_plan_id=nil)
6
- get("/plans?shop_domain=#{shop_domain}&active_plan_id=#{active_plan_id}")
7
- end
5
+ def get_plans(shop_domain, active_plan_id = nil)
6
+ get("/plans?shop_domain=#{shop_domain}&active_plan_id=#{active_plan_id}")
7
+ end
8
8
 
9
- def get_plan(plan_id,shop_domain=nil)
10
- get("/plan?plan_id=#{plan_id}&shop_domain=#{shop_domain}")
11
- end
9
+ def get_plan(plan_id, shop_domain = nil)
10
+ get("/plan?plan_id=#{plan_id}&shop_domain=#{shop_domain}")
11
+ end
12
12
 
13
- def store_charge(options = {})
14
- post("/store-charge", options)
15
- end
13
+ def store_charge(options = {})
14
+ post("/store-charge", options)
15
+ end
16
16
 
17
- def cancel_charge(shop_domain,plan_id)
18
- post("/cancel-charge", {shop_domain: shop_domain,plan_id: plan_id})
19
- end
17
+ def cancel_charge(shop_domain, plan_id)
18
+ post("/cancel-charge", {shop_domain: shop_domain, plan_id: plan_id})
19
+ end
20
20
 
21
- def update_charge(shop_domain,plan_id)
22
- post("/update-charge", {shop_domain: shop_domain,plan_id: plan_id})
23
- end
21
+ def update_charge(shop_domain, plan_id)
22
+ post("/update-charge", {shop_domain: shop_domain, plan_id: plan_id})
23
+ end
24
24
 
25
- def sync_charge(options = {})
26
- post("/sync-charge", options)
27
- end
25
+ def sync_charge(options = {})
26
+ post("/sync-charge", options)
27
+ end
28
28
 
29
- def get_remaining_days(shop_domain,trial_activated_at=nil,plan_id=nil)
30
- get("/get-remaining-days?shop_domain=#{shop_domain}&trial_activated_at=#{trial_activated_at}&plan_id=#{plan_id}")
31
- end
29
+ def get_remaining_days(shop_domain, trial_activated_at = nil, plan_id = nil)
30
+ get("/get-remaining-days?shop_domain=#{shop_domain}&trial_activated_at=#{trial_activated_at}&plan_id=#{plan_id}")
31
+ end
32
32
 
33
- def get_charge(shop_domain)
34
- get("/get-charge?shop_domain=#{shop_domain}")
35
- end
33
+ def get_charge(shop_domain)
34
+ get("/get-charge?shop_domain=#{shop_domain}")
35
+ end
36
36
 
37
- def get_status(options = {})
38
- get("/get-status", options)
39
- end
37
+ def get_status(options = {})
38
+ get("/get-status", options)
39
+ end
40
40
 
41
- def has_plan(shop_domain,plan_id,trial_activated_at,grandfathered)
42
- get("/has-plan?shop_domain=#{shop_domain}&plan_id=#{plan_id}&trial_activated_at=#{trial_activated_at}&grandfathered=#{grandfathered}")
43
- end
41
+ def has_plan(shop_domain, plan_id, trial_activated_at, grandfathered)
42
+ get("/has-plan?shop_domain=#{shop_domain}&plan_id=#{plan_id}&trial_activated_at=#{trial_activated_at}&grandfathered=#{grandfathered}")
43
+ end
44
44
 
45
45
 
46
- end
47
- end
46
+ end
47
+ end
48
48
  end
@@ -3,30 +3,28 @@ require "app_manager/client/banners"
3
3
  require "app_manager/client/plans"
4
4
 
5
5
  module AppManager
6
- class Client
7
- include HTTParty
8
- include AppManager::Client::Connection
9
- include AppManager::Client::Banners
10
- include AppManager::Client::Plans
11
-
12
- # debug_output $stderr if Rails.env.development?
13
- # base_uri "https://app-manager.hulkapps.com/api"
14
- format :json
15
-
16
-
17
- def initialize(access_token = nil,json_req=false)
18
- access_token ||= ENV["APP_MANAGER_ACCESS_TOKEN"]
19
- hostport = ENV['APP_MANAGER_API_URL'] || 'https://app-manager.hulkapps.com'
20
- self.class.base_uri "#{hostport}/api"
21
- header = { 'token' => "#{access_token}"}
22
- header.merge!('Content-Type' => 'application/json') if json_req
23
- self.class.default_options.merge!(headers: header)
24
- end
25
-
26
- def is_json
27
-
28
- end
6
+ class Client
7
+ include HTTParty
8
+ include AppManager::Client::Connection
9
+ include AppManager::Client::Banners
10
+ include AppManager::Client::Plans
11
+
12
+ format :json
13
+
14
+
15
+ def initialize(access_token = nil, json_req = false)
16
+ access_token ||= ENV["APP_MANAGER_ACCESS_TOKEN"]
17
+ hostport = ENV['APP_MANAGER_API_URL'] || 'https://app-manager.hulkapps.com'
18
+ self.class.base_uri "#{hostport}/api"
19
+ header = {'token' => "#{access_token}"}
20
+ header.merge!('Content-Type' => 'application/json') if json_req
21
+ self.class.default_options.merge!(headers: header)
22
+ end
23
+
24
+ def is_json
29
25
 
30
26
  end
31
27
 
28
+ end
29
+
32
30
  end