Class: LimeLightPlatform

Inherits:
AppBase show all
Includes:
Helpers::Accessor
Defined in:
lib/lime_light_platform.rb

Overview

Author:

  • Lime Light CRM Engineers

Constant Summary collapse

URL_TEMPLATE =
'https://<APP_KEY>.limelightcrm.com/<DEV_SUB>api/v1/<METHOD>'

Constants inherited from AppBase

AppBase::BODY_F_JSON, AppBase::BODY_F_NONE, AppBase::BODY_F_QUERY_STR, AppBase::BODY_F_RAW, AppBase::BODY_F_XML, AppBase::GET, AppBase::PATCH, AppBase::POST, AppBase::PUT

Instance Attribute Summary collapse

Attributes inherited from AppBase

#debug

Instance Method Summary collapse

Methods included from Helpers::Accessor

#get_by_key, #get_if_exists, #get_response_code, #key_exists, #map_param_if_exist

Methods inherited from AppBase

#gen_http, #perform_api_call

Constructor Details

#initialize(app_key, api_username, api_password, dev_subdirectory = '', debug = false) ⇒ LimeLightPlatform

Returns a new instance of LimeLightPlatform.

Parameters:

  • app_key (String)

    The CRM app key

  • api_username (String)

    The CRM app key

  • api_password (String)

    The CRM app key

  • dev_subdirectory (String) (defaults to: '')

    Subdirectory for developer environments

  • debug (Boolean) (defaults to: false)

    Increases the log level of API requests and responses



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/lime_light_platform.rb', line 23

def initialize app_key, api_username, api_password, dev_subdirectory='', debug=false
  super debug

  if app_key.blank?
    raise ApiError.new 'App Key is required'
  end

  if api_username.blank?
    raise ApiError.new 'API username is required'
  end

  if api_password.blank?
    raise ApiError.new 'API password is required'
  end

  @app_key = app_key
  @api_username = api_username
  @api_password = api_password
  @dev_subdirectory = dev_subdirectory

  if !@dev_subdirectory.blank?
    @dev_subdirectory = @dev_subdirectory + '/'
  end
end

Instance Attribute Details

#api_passwordObject (readonly)

Returns the value of attribute api_password.



13
14
15
# File 'lib/lime_light_platform.rb', line 13

def api_password
  @api_password
end

#api_usernameObject (readonly)

Returns the value of attribute api_username.



13
14
15
# File 'lib/lime_light_platform.rb', line 13

def api_username
  @api_username
end

#app_keyObject (readonly)

Returns the value of attribute app_key.



13
14
15
# File 'lib/lime_light_platform.rb', line 13

def app_key
  @app_key
end

#dev_subdirectoryObject (readonly)

Returns the value of attribute dev_subdirectory.



13
14
15
# File 'lib/lime_light_platform.rb', line 13

def dev_subdirectory
  @dev_subdirectory
end

Instance Method Details

#authorize_payment(request = {}) ⇒ Hash

Perform an preauthorization request on a payment method

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/lime_light_platform.rb', line 51

def authorize_payment request={}
  call_params = base_call_params(__method__)
  call_params[:body] = {
    'billingFirstName'   => get_if_exists('billing_first_name', request),
    'billingLastName'    => get_if_exists('billing_last_name', request),
    'billingAddress1'    => get_if_exists('billing_address_1', request),
    'billingAddress2'    => get_if_exists('billing_address_2', request),
    'billingCity'        => get_if_exists('billing_city', request),
    'billingState'       => get_if_exists('billing_state', request),
    'billingZip'         => get_if_exists('billing_zip', request),
    'billingCountry'     => get_if_exists('billing_country', request),
    'phone'              => get_if_exists('phone', request),
    'email'              => get_if_exists('email', request),
    'creditCardType'     => get_if_exists('credit_card_type', request),
    'creditCardNumber'   => get_if_exists('credit_card_number', request),
    'expirationDate'     => get_if_exists('expiration_date', request),
    'CVV'                => get_if_exists('cvv', request),
    'ipAddress'          => get_if_exists('ip_address', request),
    'productId'          => get_if_exists('product_id', request),
    'campaignId'         => get_if_exists('campaign_id', request),
    'auth_amount'        => get_if_exists('auth_amount', request, '1.00'),
    'cascade_enabled'    => get_if_exists('cascade_enabled', request, '0'),
    'save_customer'      => get_if_exists('save_customer', request, '0'),
    'validate_only_flag' => get_if_exists('validate_only_flag', request, '0'),
    'void_flag'          => get_if_exists('void_flag', request, '0')
  }
  common_perform_post call_params
end

#billing_model_view(request = {}) ⇒ Hash

Retrieve billing model data for a specified billing model ID

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



83
84
85
# File 'lib/lime_light_platform.rb', line 83

def billing_model_view request={}
  common_optional_param_perform_post base_call_params(__method__), ['offer_id', 'billing_model_id'], request
end

#campaign_find_activeHash

Return all active campaigns ina CRM instance

Returns:

  • (Hash)

    Common response object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/lime_light_platform.rb', line 89

def campaign_find_active
  response = default_response
  api_response = perform_api_call base_call_params(__method__)
  response[:raw] = api_response

  if !api_response.blank?
    parsed = JSON.parse(api_response)
    response_code = get_response_code(parsed).to_i
    response[:code] = response_code
    campaigns = []

    if response_code == 100 && key_exists('campaigns', parsed)
      response[:success] = true
      parsed['campaigns'].each do |key, payload|
        campaigns << {
          'id'   => payload['campaign_id'],
          'name' => payload['campaign_name']
        }
      end
    end

    response[:data] = campaigns
  end

  response
end

#campaign_payment_router_view(campaign_id) ⇒ Hash

Retrieve payment router data for a specified campaign ID

Parameters:

  • campaign_id (Integer)

    Campaign ID from CRM instance

Returns:

  • (Hash)

    Common response object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/lime_light_platform.rb', line 126

def campaign_payment_router_view campaign_id
  campaign_view_response = campaign_view campaign_id
  combined_response = {
    success: false,
    data: {
      has_payment_router: 0,
      campaign_view_response: {},
      payment_router_view_response: {}
    },
  }

  combined_response[:data][:campaign_view_response] = campaign_view_response

  if campaign_view_response[:success]
    payment_router_id = campaign_view_response[:data]['payment_router_id']

    if !payment_router_id.blank?
      combined_response[:data][:has_payment_router] = 1
      payment_router_view_response = payment_router_view [payment_router_id]

      if payment_router_view_response[:success]
        combined_response[:success] = true
        combined_response[:data][:payment_router_view_response] = payment_router_view_response
      end
    end
  end

  combined_response
end

#campaign_view(campaign_id) ⇒ Hash

Retrieve campaign data for a specified campaign ID

Parameters:

  • campaign_id (Integer)

    Campaign ID from CRM instance

Returns:

  • (Hash)

    Common response object



119
120
121
# File 'lib/lime_light_platform.rb', line 119

def campaign_view campaign_id
  common_entity_view_perform_post base_call_params(__method__), 'campaign_id', campaign_id
end

#coupon_validate(request = {}) ⇒ Hash

Validate a coupon based on promo code and other coupon parameters

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



159
160
161
162
163
164
165
166
167
168
169
# File 'lib/lime_light_platform.rb', line 159

def coupon_validate request={}
  call_params = base_call_params __method__
  call_params[:body] = {
    'campaign_id' => get_if_exists('campaign_id', request, 0),
    'shipping_id' => get_if_exists('shipping_id', request, 0),
    'email' => get_if_exists('email', request),
    'promo_code' => get_if_exists('promo_code', request),
    'products' => get_if_exists('products', request)
  }
  common_perform_post call_params
end

#customer_view(customer_id) ⇒ Hash

Retrieve customer data for a specified customer ID

Parameters:

  • customer_id (Integer)

    Customer ID from CRM instance

Returns:

  • (Hash)

    Common response object



174
175
176
# File 'lib/lime_light_platform.rb', line 174

def customer_view customer_id
  common_entity_view_perform_post base_call_params(__method__), 'customer_id', customer_id
end

#gateway_view(gateway_id) ⇒ Hash

Retrieve gateway data for a specified gateway ID

Parameters:

  • gateway_id (Integer)

    Gateway ID from CRM instance

Returns:

  • (Hash)

    Common response object



181
182
183
# File 'lib/lime_light_platform.rb', line 181

def gateway_view gateway_id
  common_entity_view_perform_post base_call_params(__method__), 'gateway_id', gateway_id
end

#get_alternative_provider(request = {}) ⇒ Hash

Retrieve alternative provider parameters (paypal, icepay)

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/lime_light_platform.rb', line 188

def get_alternative_provider request={}
  call_params = base_call_params __method__
  call_params[:body] = {
    'campaign_id' => get_if_exists('campaign_id', request, 0),
    'alt_pay_type' => get_if_exists('alt_pay_type', request),
    'return_url' => get_if_exists('return_url', request),
    'cancel_url' => get_if_exists('cancel_url', request),
    'amount' => get_if_exists('amount', request),
    'shipping_id' => get_if_exists('shipping_id', request),
    'bill_country' => get_if_exists('bill_country', request), # icepay only
    'products' => get_if_exists('products', request)
  }
  common_perform_post call_params
end

#new_order(request = {}) ⇒ Hash

Create and process a new order

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



206
207
208
# File 'lib/lime_light_platform.rb', line 206

def new_order request={}
  common_new_order_request __method__, request
end

#new_order_card_on_file(request = {}) ⇒ Hash

Create and process a new order based upon an existing order

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



213
214
215
# File 'lib/lime_light_platform.rb', line 213

def new_order_card_on_file request={}
  common_new_order_request __method__, request
end

#new_order_with_prospect(request = {}) ⇒ Hash

Create and process a new order based upon an existing prospect record

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



220
221
222
# File 'lib/lime_light_platform.rb', line 220

def new_order_with_prospect request={}
  common_new_order_request __method__, request
end

#new_prospect(request = {}) ⇒ Hash

Create a prospect record

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/lime_light_platform.rb', line 227

def new_prospect request={}
  call_params = base_call_params(camel_case_name(__method__))
  body = {
    'campaignId' => get_if_exists('campaign_id', request),
    'email' => get_if_exists('email', request),
    'ipAddress' => get_if_exists('ip_address', request)
  }
  optional_params = {
    'first_name' => 'firstName',
    'last_name'  => 'lastName',
    'address_1'  => 'address1',
    'address_2'  => 'address2',
    'city'       => 'city',
    'state'      => 'state',
    'zip'        => 'zip',
    'country'    => 'country',
    'phone'      => 'phone',
    'afid'       => 'AFID',
    'sid'        => 'SID',
    'affid'      => 'AFFID',
    'c1'         => 'C1',
    'c2'         => 'C2',
    'c3'         => 'C3',
    'aid'        => 'AID',
    'opt'        => 'OPT',
    'click_id'   => 'click_id',
    'notes'      => 'notes',
  }
  body = map_param_if_exist optional_params, request, body
  call_params[:body] = body
  common_perform_post call_params
end

#offer_view(request = {}) ⇒ Hash

Retrieve offer data according to offer ID and/or campaign ID

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



263
264
265
# File 'lib/lime_light_platform.rb', line 263

def offer_view request={}
  common_optional_param_perform_post base_call_params(__method__), ['offer_id', 'campaign_id'], request
end

#order_find(request = {}) ⇒ Hash

Search for one or more order records according to criteria

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/lime_light_platform.rb', line 270

def order_find request={}
  call_params = base_call_params __method__
  date_times = default_date_times
  call_params[:body] = {
    'campaign_id' => get_if_exists('campaign_id', request, 'all'),
    'start_date' => get_if_exists('start_date', request, date_times[:today]),
    'end_date' => get_if_exists('end_date', request, date_times[:today]),
    'start_time' => get_if_exists('start_time', request, date_times[:start_time]),
    'end_time' => get_if_exists('end_time', request, date_times[:end_time]),
    'search_type' => get_if_exists('search_type', request, 'any'), # could be all
    'return_type' => 'order_view' # always order_view
  }

  if key_exists('product_ids', request)
    call_params[:body]['product_ids'] = request['product_ids']
  end

  if key_exists('member_token', request)
    call_params[:body]['member_token'] = request['member_token']
  end

  if key_exists('criteria', request)
    call_params[:body]['criteria'] = request['criteria']
  end

  common_perform_post call_params
end

#order_find_updated(request = {}) ⇒ Hash

Search for one or more order records according to criteria

Criteria is based on several updated statuses

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/lime_light_platform.rb', line 302

def order_find_updated request={}
  call_params = base_call_params __method__
  date_times = default_date_times
  call_params[:body] = {
    'campaign_id' => get_if_exists('campaign_id', request),
    'start_date' => get_if_exists('start_date', request, date_times[:today]),
    'end_date' => get_if_exists('end_date', request, date_times[:today]),
    'start_time' => get_if_exists('start_time', request, date_times[:start_time]),
    'end_time' => get_if_exists('end_time', request, date_times[:end_time]),
    'group_keys' => get_if_exists('group_keys', request)
  }
  common_perform_post call_params
end

#order_force_bill(request = {}) ⇒ Hash

Force rebill an exist order

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/lime_light_platform.rb', line 319

def order_force_bill request={}
  call_params = base_call_params __method__
  call_params[:body] = {
    'order_id' => get_if_exists('order_id', request)
  }

  if key_exists('force_gateway_id', request)
    call_params[:body]['forceGatewayId'] = request['force_gateway_id']
  end

  if key_exists('preserve_force_gateway', request)
    call_params[:body]['preserve_force_gateway'] = request['preserve_force_gateway']
  end

  common_perform_post call_params
end

#order_reprocess(order_id) ⇒ Hash

Reprocess a declined order

Parameters:

  • order_id (Integer)

    The order ID from CRM instance

Returns:

  • (Hash)

    Common response object



339
340
341
342
343
# File 'lib/lime_light_platform.rb', line 339

def order_reprocess order_id
  call_params = base_call_params __method__
  call_params[:body] = { 'order_id' => order_id }
  common_perform_post call_params
end

#order_update(request = {}) ⇒ Hash

Updates an order record according to various criteria

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/lime_light_platform.rb', line 360

def order_update request={}
  call_params = base_call_params __method__
  call_params[:body] = { 'sync_all' => get_if_exists('sync_all', request, 0) }
  update_options = [
    'confirmation_status',
    'blacklist',
    'fraud',
    'chargeback',
    'notes',
    'first_name',
    'last_name',
    'email',
    'phone',
    'shipping_method',
    'shipping_address1',
    'shipping_address2',
    'shipping_city',
    'shipping_zip',
    'shipping_state',
    'shipping_country',
    'billing_address1',
    'billing_address2',
    'billing_city',
    'billing_zip',
    'billing_state',
    'billing_country',
    'rebill_discount',
    'next_rebill_product',
    'cc_number',
    'check_routing',
    'check_account',
    'check_ssn',
    'cc_expiration_date',
    'cc_payment_type',
    'recurring_date',
    'stop_recurring_next_success',
    'rma',
    'return',
    'tracking_number',
    'payment_received',
    'subscription_override',
    'afid',
    'affid',
    'aid',
    'sid',
    'c1',
    'c2',
    'c3',
    'opt'
  ]
  common_update_perform_post call_params, request, 'order_id', update_options
end

#order_update_recurring(request = {}) ⇒ Hash

Update the recurring properties of an order on an active subscription

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



348
349
350
351
352
353
354
355
# File 'lib/lime_light_platform.rb', line 348

def order_update_recurring request={}
  call_params = base_call_params __method__
  call_params[:body] = {
    'order_id' => get_if_exists('order_id', request, 0),
    'status' => get_if_exists('status', request)
  }
  common_perform_post call_params
end

#order_view(request = {}) ⇒ Hash

Retrieve order data based upon one or more order IDs

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



416
417
418
419
420
# File 'lib/lime_light_platform.rb', line 416

def order_view request={}
  call_params = base_call_params __method__
  call_params[:body] = { 'order_id' => get_if_exists('order_id', request, []) }
  common_perform_post call_params
end

#payment_router_view(payment_router_id = []) ⇒ Hash

Retrieve payment router data based upon one or more payment router IDs

Parameters:

  • payment_router_id (Array) (defaults to: [])

    Payment router IDs

Returns:

  • (Hash)

    Common response object



425
426
427
# File 'lib/lime_light_platform.rb', line 425

def payment_router_view payment_router_id=[]
  common_entity_view_perform_post base_call_params(__method__), 'payment_router_id', payment_router_id
end

#product_attribute_index(request = {}) ⇒ Hash

Retrieve the product variant attributes

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



432
433
434
435
436
# File 'lib/lime_light_platform.rb', line 432

def product_attribute_index request={}
  call_params = base_call_params __method__
  call_params[:body] = { 'product_id' => get_if_exists('product_id', request, []) }
  common_perform_post call_params
end

#product_bundle_indexHash

Return all product bundles in a CRM instance

Returns:

  • (Hash)

    Common response object



440
441
442
# File 'lib/lime_light_platform.rb', line 440

def product_bundle_index
  common_perform_post base_call_params(__method__)
end

#product_bundle_view(product_id) ⇒ Hash

Retrieve product bundle data for a specified product ID

This product must be a bundle

Parameters:

  • product_id (Integer)

    Product ID from CRM instance

Returns:

  • (Hash)

    Common response object



448
449
450
# File 'lib/lime_light_platform.rb', line 448

def product_bundle_view product_id
  common_entity_view_perform_post base_call_params(__method__), 'product_id', product_id
end

#product_copy(request = {}) ⇒ Hash

Copy a product record

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



455
456
457
458
459
460
461
462
463
464
# File 'lib/lime_light_platform.rb', line 455

def product_copy request={}
  call_params = base_call_params __method__
  call_params[:body] = { 'product_id' => get_if_exists('product_id', request, 0) }

  if key_exists('new_name', request)
    call_params[:body]['new_name'] = request['new_name']
  end

  common_perform_post call_params
end

#product_create(request = {}) ⇒ Hash

Create a product record

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/lime_light_platform.rb', line 469

def product_create request={}
  call_params = base_call_params __method__
  call_params[:body] = {
    'customer_purchase_limit' => get_if_exists('customer_purchase_limit', request, 0),
    'taxable'                 => get_if_exists('taxable', request, 0),
    'shippable'               => get_if_exists('shippable', request, 0),
    'signature_confirmation'  => get_if_exists('signature_confirmation', request, 0),
    'delivery_confirmation'   => get_if_exists('delivery_confirmation', request, 0),
    'preserve_quantity'       => get_if_exists('preserve_quantity', request, 0),
    'collections'             => get_if_exists('collections', request, 0),
    'shipping_declared_value' => get_if_exists('shipping_declared_value', request, 0),
    'product_price'           => get_if_exists('product_price', request, 0),
    'product_restocking_fee'  => get_if_exists('product_restocking_fee', request, 0),
    'shipping_weight'         => get_if_exists('shipping_weight', request, 0),
    'product_sku'             => get_if_exists('product_sku', request),
    'shipping_digital_url'    => get_if_exists('shipping_digital_url', request),
    'recurring_discount_max'  => get_if_exists('recurring_discount_max', request, 0),
    'product_name'            => get_if_exists('product_name', request),
    'product_description'     => get_if_exists('product_description', request),
    'category_id'             => get_if_exists('category_id', request, 0),
    'vertical_id'             => get_if_exists('vertical_id', request, 0),
    'cost_of_goods_sold'      => get_if_exists('cost_of_goods_sold', request, 0),
    'product_max_quantity'    => get_if_exists('product_max_quantity', request, 1)
  }
  common_perform_post call_params
end

#product_delete(product_id) ⇒ Hash

Delete a product record

Parameters:

  • product_id (Integer)

    Product ID from CRM instance

Returns:

  • (Hash)

    Common response object



499
500
501
# File 'lib/lime_light_platform.rb', line 499

def product_delete product_id
  common_entity_view_perform_post base_call_params(__method__), 'product_id', product_id
end

#product_update(request = {}) ⇒ Hash

Update a product record

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/lime_light_platform.rb', line 506

def product_update request={}
  call_params = base_call_params __method__
  update_options = [
    'customer_purchase_limit',
    'taxable',
    'shippable',
    'signature_confirmation',
    'delivery_confirmation',
    'preserve_quantity',
    'collections',
    'shipping_declared_value',
    'product_price',
    'product_restocking_fee',
    'shipping_weight',
    'product_sku',
    'shipping_digital_url',
    'recurring_discount_max',
    'product_name',
    'product_description',
    'category_id',
    'vertical_id',
    'cost_of_goods_sold',
    'product_max_quantity'
  ]
  common_update_perform_post call_params, request, 'product_id', update_options
end

#prospect_find(request = {}) ⇒ Hash

Search for a prospect record according to one or more criteria

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
# File 'lib/lime_light_platform.rb', line 536

def prospect_find request={}
  call_params = base_call_params __method__
  date_times = default_date_times
  call_params[:body] = {
    'campaign_id' => get_if_exists('campaign_id', request, 'all'),
    'start_date' => get_if_exists('start_date', request, date_times[:today]),
    'end_date' => get_if_exists('end_date', request, date_times[:today]),
    'start_time' => get_if_exists('start_time', request, date_times[:start_time]),
    'end_time' => get_if_exists('end_time', request, date_times[:end_time]),
    'search_type' => get_if_exists('search_type', request, 'any'), # could be all
  }

  if key_exists('criteria', request)
    call_params[:body]['criteria'] = request['criteria']
  end

  common_perform_post call_params
end

#prospect_update(request = {}) ⇒ Hash

Update a prospect record

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
# File 'lib/lime_light_platform.rb', line 558

def prospect_update request={}
  call_params = base_call_params __method__
  update_options = [
    'first_name',
    'last_name',
    'address',
    'address2',
    'city',
    'state',
    'zip',
    'country',
    'phone',
    'email',
    'notes'
  ]
  common_update_perform_post call_params, request, 'prospect_id', update_options
end

#prospect_view(request = {}) ⇒ Hash

Retrieve prospect data for a specified prospect ID

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



579
580
581
582
583
584
585
# File 'lib/lime_light_platform.rb', line 579

def prospect_view request={}
  call_params = base_call_params __method__
  call_params[:body] = {
    'prospect_id' => get_if_exists('prospect_id', request, [])
  }
  common_perform_post call_params
end

#repost_to_fulfillment(order_id) ⇒ Hash

Attempt to send an order to fulfillment

Parameters:

  • order_id (Integer)

    The order ID from CRM instance

Returns:

  • (Hash)

    Common response object



590
591
592
# File 'lib/lime_light_platform.rb', line 590

def repost_to_fulfillment order_id
  common_entity_view_perform_post base_call_params(__method__), 'order_id', order_id
end

#shipping_method_find(request = {}) ⇒ Hash

Retrieve shipping method data based upon criteria

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



597
598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'lib/lime_light_platform.rb', line 597

def shipping_method_find request={}
  call_params = base_call_params __method__
  call_params[:body] = {
    'campaign_id' => get_if_exists('campaign_id', request, 'all'),
    'search_type' => get_if_exists('search_type', request, 'any') # could be all
  }

  # criteria options: code, name, group
  if key_exists('criteria', request)
    call_params[:body]['criteria'] = request['criteria']
  end

  common_perform_post call_params
end

#shipping_method_view(shipping_id) ⇒ Hash

Retrieve shipping method data for a specified shipping ID

Parameters:

  • shipping_id (Integer)

    The shipping method ID from CRM instance

Returns:

  • (Hash)

    Common response object



615
616
617
# File 'lib/lime_light_platform.rb', line 615

def shipping_method_view shipping_id
  common_entity_view_perform_post base_call_params(__method__), 'shipping_id', shipping_id
end

#skip_next_billing(subscription_id) ⇒ Hash

Skips the next billing cycle on a recurring subscription by updating the recurring date

according to billing model configurations

Parameters:

  • subscription_id (String)

    Subscription ID on the order

Returns:

  • (Hash)

    Common response object



623
624
625
# File 'lib/lime_light_platform.rb', line 623

def skip_next_billing subscription_id
  common_entity_view_perform_post base_call_params(__method__), 'subscription_id', subscription_id
end

#subscription_order_update(request = {}) ⇒ Hash

Update one or more dynamic properties on a recurring subscription

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/lime_light_platform.rb', line 630

def subscription_order_update request={}
  call_params = base_call_params __method__
  call_params[:body]['order_id'] = get_if_exists 'order_id', request
  optional_params = [
    'additional_product_id',
    'quantity',
    'product_id',
    'new_recurring_product_id',
    'children',
    'new_recurring_price',
    'new_recurring_date',
    'billing_model_id'
  ]
  common_optional_param_perform_post call_params, optional_params, request
end

#subscription_update(request = {}) ⇒ Hash

Stop, start, or reset a subscription

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



649
650
651
652
653
# File 'lib/lime_light_platform.rb', line 649

def subscription_update request={}
  call_params = base_call_params __method__
  call_params[:body] = { 'subscription_id' => get_if_exists('subscription_id', request, {}) }
  common_perform_post call_params
end

#three_d_redirect(order_id) ⇒ Hash

Provide data necessary to redirect the customer

to their personal bank URL for 3D Secure payments

Parameters:

  • order_id (Integer)

    The order ID from CRM instance

Returns:

  • (Hash)

    Common response object



659
660
661
# File 'lib/lime_light_platform.rb', line 659

def three_d_redirect order_id
  common_entity_view_perform_post base_call_params(__method__), 'order_id', order_id
end

#upsell_stop_recurring(request = {}) ⇒ Hash

Stops the recurring status of an upsell product on a subscriptions

Parameters:

  • request (Hash) (defaults to: {})

    Request payload hash

Returns:

  • (Hash)

    Common response object



666
667
668
669
670
671
672
673
# File 'lib/lime_light_platform.rb', line 666

def upsell_stop_recurring request={}
  call_params = base_call_params __method__
  call_params[:body] = {
    'order_id' => get_if_exists('order_id', request),
    'product_id' => get_if_exists('product_id', request)
  }
  common_perform_post call_params
end

#validate_credentialsHash

Validates the API user username and password

Returns:

  • (Hash)

    Common response object



677
678
679
# File 'lib/lime_light_platform.rb', line 677

def validate_credentials
  common_perform_post(base_call_params(__method__))
end