lime_light_platform 1.0.0.5 → 1.0.0.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/lib/lime_light_platform.rb +28 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ced5ca404f910c625be5cedccdacb2862b234899e032c6bc44bf32db0a3d45a
|
4
|
+
data.tar.gz: 7311f73d4d35b16668f7e18de03b7c3774ed854a73913855f01661774473bdfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 167f3101a5441c458b703cc98ccc2d26f228da4a276a2401d53137cfaca7507d71e1fdb81edd383878ec2c7d8dd86cace08c23fd7e24fb644a1d0d9da1cb548d
|
7
|
+
data.tar.gz: b3720b74da807573f312b1752f1364db66ff686bf31e700a518227ec97cf5adea54c0883da701687fb6124a89de1a87deea7aa950dd72588f91c072ead265ecc
|
data/lib/lime_light_platform.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
require 'lime_light_platform/api_error'
|
4
|
+
require 'lime_light_platform/app_base'
|
5
|
+
require 'lime_light_platform/helpers/accessor'
|
6
|
+
|
1
7
|
class LimeLightPlatform < AppBase
|
2
8
|
include Helpers::Accessor
|
3
9
|
|
4
|
-
URL_TEMPLATE = 'https://<APP_KEY>.limelightcrm.com/<DEV_SUB>api/v1/<METHOD
|
10
|
+
URL_TEMPLATE = 'https://<APP_KEY>.limelightcrm.com/<DEV_SUB>api/v1/<METHOD>'
|
5
11
|
|
6
12
|
attr_reader :app_key,
|
7
13
|
:api_username,
|
@@ -34,10 +40,11 @@ class LimeLightPlatform < AppBase
|
|
34
40
|
def campaign_find_active
|
35
41
|
response = default_response
|
36
42
|
api_response = perform_api_call base_call_params(__method__)
|
43
|
+
response[:raw] = api_response
|
37
44
|
|
38
45
|
if !api_response.blank?
|
39
|
-
parsed = JSON.parse(
|
40
|
-
response_code = parsed
|
46
|
+
parsed = JSON.parse(api_response)
|
47
|
+
response_code = get_response_code(parsed).to_i
|
41
48
|
response[:code] = response_code
|
42
49
|
campaigns = []
|
43
50
|
|
@@ -145,9 +152,7 @@ class LimeLightPlatform < AppBase
|
|
145
152
|
call_params = base_call_params __method__
|
146
153
|
|
147
154
|
if key_exists('product_id', request)
|
148
|
-
call_params[:body]['
|
149
|
-
call_params[:body]['actions'] = []
|
150
|
-
call_params[:body]['values'] = []
|
155
|
+
call_params[:body]['product_id'] = {}
|
151
156
|
keys = [
|
152
157
|
'customer_purchase_limit',
|
153
158
|
'taxable',
|
@@ -174,20 +179,21 @@ class LimeLightPlatform < AppBase
|
|
174
179
|
# only update what is present
|
175
180
|
keys.each do |key|
|
176
181
|
if key_exists(key, request)
|
177
|
-
call_params[:body]['
|
178
|
-
call_params[:body]['
|
179
|
-
call_params[:body]['values'] << get_by_key(key)
|
182
|
+
call_params[:body]['product_id'][request['product_id'].to_s] = {}
|
183
|
+
call_params[:body]['product_id'][request['product_id'].to_s][key] = get_by_key(key, request)
|
180
184
|
end
|
181
185
|
end
|
182
186
|
|
183
|
-
if !call_params[:body]['
|
187
|
+
if !call_params[:body]['product_id'].empty?
|
184
188
|
api_response = perform_api_call call_params
|
189
|
+
response[:raw] = api_response
|
185
190
|
|
186
191
|
if !api_response.nil?
|
187
192
|
parsed = JSON.parse(api_response)
|
193
|
+
response_code = get_response_code(parsed)
|
188
194
|
|
189
|
-
if !
|
190
|
-
response_code =
|
195
|
+
if !response_code.blank?
|
196
|
+
response_code = response_code.to_i
|
191
197
|
response[:code] = response_code
|
192
198
|
|
193
199
|
if response_code == 100
|
@@ -234,25 +240,30 @@ class LimeLightPlatform < AppBase
|
|
234
240
|
{
|
235
241
|
url: crm_url(method.to_s),
|
236
242
|
proto: POST,
|
237
|
-
format:
|
238
|
-
headers: [
|
243
|
+
format: BODY_F_JSON,
|
244
|
+
headers: [
|
245
|
+
{ name: 'Authorization', value: 'Basic ' + Base64.strict_encode64("#{@api_username}:#{@api_password}") },
|
246
|
+
{ name: 'Content-Type', value: 'application/json' }
|
247
|
+
],
|
239
248
|
body: {}
|
240
249
|
}
|
241
250
|
end
|
242
251
|
|
243
252
|
def default_response
|
244
|
-
{ success: false, code: nil, data: [] }
|
253
|
+
{ success: false, code: nil, data: [], raw: '' }
|
245
254
|
end
|
246
255
|
|
247
256
|
def common_perform_post call_params
|
248
257
|
response = default_response
|
249
258
|
api_response = perform_api_call call_params
|
259
|
+
response[:raw] = api_response
|
250
260
|
|
251
261
|
if !api_response.nil?
|
252
262
|
parsed = JSON.parse(api_response)
|
263
|
+
response_code = get_response_code parsed
|
253
264
|
|
254
|
-
if !
|
255
|
-
response_code =
|
265
|
+
if !response_code.blank?
|
266
|
+
response_code = response_code.to_i
|
256
267
|
response[:code] = response_code
|
257
268
|
|
258
269
|
if response_code == 100
|