lime_light_platform 1.0.0.10 → 1.0.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1273a3af9515840122742d9733e44e4801a34d8f0a3b92f6d803e9b9582bfa6
4
- data.tar.gz: 8a230f9bf1d8d5ccdeb249ac2be9254436b0a380b6ac208070d1df3551845bf2
3
+ metadata.gz: 74e567c971b5a8d52fe545346ee231b607fbdbcc6f4836ada81b7a7ba3b2057b
4
+ data.tar.gz: 0272d366b707152d7e615032692da8a951eb508fc9a2f95fb0c893961b47c2d1
5
5
  SHA512:
6
- metadata.gz: 85cd48e5c8c159a98c4efe8c6c61214c7060467217fd5578e9cfa1e17f436398563e4294cd55ccb647f0a82ea0af24ba84c513b74c5ee77d857d7d15e65bbf15
7
- data.tar.gz: 6702930d7a00992f4aa59a0cbb4cc00c5b040ef6870971f8fb1122e86ce3edf0fb2bcb3b9cecf0897dbe22766b717a10748a21e70ede8422cdc8a74d0ce68def
6
+ metadata.gz: 293b5b42057ceb7c9f12853ddffbd6d7b96d14a6ed673c5e8adcd5c968c4b09a6f076d740fe73ec3afc1c3c2434323f28e45afe0b82939870627363c21426f2a
7
+ data.tar.gz: 18436f834b51696f014ae59dfdedc53cf2828e1d4757dbe25fde3e417e37206355fcf55e479f12cb214c6cd87bf1f34682fff9cbbe65df4f40bd246edf7ae481
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+ gem 'rspec', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
3
+ gem "awesome_print"
4
+ gem "dotenv-rails"
5
+ gem "activesupport"
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lime_light_platform (1.0.0.11)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionpack (5.2.0)
10
+ actionview (= 5.2.0)
11
+ activesupport (= 5.2.0)
12
+ rack (~> 2.0)
13
+ rack-test (>= 0.6.3)
14
+ rails-dom-testing (~> 2.0)
15
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
16
+ actionview (5.2.0)
17
+ activesupport (= 5.2.0)
18
+ builder (~> 3.1)
19
+ erubi (~> 1.4)
20
+ rails-dom-testing (~> 2.0)
21
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
22
+ activesupport (5.2.0)
23
+ concurrent-ruby (~> 1.0, >= 1.0.2)
24
+ i18n (>= 0.7, < 2)
25
+ minitest (~> 5.1)
26
+ tzinfo (~> 1.1)
27
+ awesome_print (1.8.0)
28
+ builder (3.2.3)
29
+ concurrent-ruby (1.0.5)
30
+ crass (1.0.4)
31
+ diff-lcs (1.3)
32
+ dotenv (2.4.0)
33
+ dotenv-rails (2.4.0)
34
+ dotenv (= 2.4.0)
35
+ railties (>= 3.2, < 6.0)
36
+ erubi (1.7.1)
37
+ i18n (1.0.1)
38
+ concurrent-ruby (~> 1.0)
39
+ loofah (2.2.2)
40
+ crass (~> 1.0.2)
41
+ nokogiri (>= 1.5.9)
42
+ method_source (0.9.0)
43
+ mini_portile2 (2.3.0)
44
+ minitest (5.11.3)
45
+ nokogiri (1.8.2-x64-mingw32)
46
+ mini_portile2 (~> 2.3.0)
47
+ rack (2.0.5)
48
+ rack-test (1.0.0)
49
+ rack (>= 1.0, < 3)
50
+ rails-dom-testing (2.0.3)
51
+ activesupport (>= 4.2.0)
52
+ nokogiri (>= 1.6)
53
+ rails-html-sanitizer (1.0.4)
54
+ loofah (~> 2.2, >= 2.2.2)
55
+ railties (5.2.0)
56
+ actionpack (= 5.2.0)
57
+ activesupport (= 5.2.0)
58
+ method_source
59
+ rake (>= 0.8.7)
60
+ thor (>= 0.18.1, < 2.0)
61
+ rake (12.3.1)
62
+ rspec (3.7.0)
63
+ rspec-core (~> 3.7.0)
64
+ rspec-expectations (~> 3.7.0)
65
+ rspec-mocks (~> 3.7.0)
66
+ rspec-core (3.7.1)
67
+ rspec-support (~> 3.7.0)
68
+ rspec-expectations (3.7.0)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.7.0)
71
+ rspec-mocks (3.7.0)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.7.0)
74
+ rspec-support (3.7.1)
75
+ thor (0.20.0)
76
+ thread_safe (0.3.6)
77
+ tzinfo (1.2.5)
78
+ thread_safe (~> 0.1)
79
+
80
+ PLATFORMS
81
+ x64-mingw32
82
+
83
+ DEPENDENCIES
84
+ activesupport
85
+ awesome_print
86
+ dotenv-rails
87
+ lime_light_platform!
88
+ rspec
89
+
90
+ BUNDLED WITH
91
+ 1.16.1
@@ -0,0 +1,5 @@
1
+ class ApiError < StandardError
2
+ def initialize(msg = 'Unknown API error')
3
+ super
4
+ end
5
+ end
@@ -0,0 +1,74 @@
1
+ require 'net/http'
2
+ require 'openssl'
3
+
4
+ class AppBase
5
+ # map protocols
6
+ GET = 'GET'
7
+ POST = 'POST'
8
+ PATCH = 'PATCH'
9
+ PUT = 'PUT'
10
+
11
+ BODY_F_JSON = 'JSON'
12
+ BODY_F_QUERY_STR = 'HTTP_QUERY_STR'
13
+ BODY_F_XML = 'XML'
14
+ BODY_F_RAW = 'RAW'
15
+ BODY_F_NONE = 'NO_BODY'
16
+
17
+ def perform_api_call call_params
18
+ valid = true
19
+ response_body = ''
20
+ uri = URI.parse call_params[:url]
21
+ http = gen_http uri
22
+
23
+ # determine http protocol
24
+ case call_params[:proto]
25
+ when POST
26
+ api_request = Net::HTTP::Post.new uri.request_uri
27
+ when PATCH
28
+ api_request = Net::HTTP::Patch.new uri.request_uri
29
+ when GET
30
+ api_request = Net::HTTP::Get.new uri.request_uri
31
+ when PUT
32
+ api_request = Net::HTTP::Put.new uri.request_uri
33
+ else
34
+ valid = false
35
+ end
36
+
37
+ if valid
38
+ # determine headers if any
39
+ if !call_params[:headers].nil?
40
+ call_params[:headers].each do |field|
41
+ api_request.add_field field[:name], field[:value]
42
+ end
43
+ end
44
+
45
+ # add request body
46
+ case call_params[:format]
47
+ when BODY_F_JSON
48
+ api_request.body = call_params[:body].to_json
49
+ when BODY_F_XML
50
+ api_request.body = call_params[:body].to_xml(:root => call_params[:xml_root])
51
+ when BODY_F_QUERY_STR
52
+ api_request.body = call_params[:body].to_query
53
+ when BODY_F_RAW
54
+ api_request.body = call_params[:body]
55
+ when BODY_F_NONE
56
+ api_request.body = ''
57
+ end
58
+
59
+ # ap "API_REQUEST =>"
60
+ # ap api_request.body
61
+ api_response = http.request api_request
62
+ response_body = api_response.body
63
+ end
64
+
65
+ response_body
66
+ end
67
+
68
+ def gen_http uri
69
+ http = Net::HTTP.new uri.host, uri.port
70
+ http.use_ssl = true
71
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
72
+ http
73
+ end
74
+ end
@@ -0,0 +1,35 @@
1
+ module Helpers
2
+ module Accessor
3
+ def get_if_exists key, hash, default=''
4
+ value = default
5
+
6
+ if !hash[key].nil?
7
+ value = hash[key]
8
+ end
9
+
10
+ value
11
+ end
12
+
13
+ def key_exists key, hash
14
+ !hash[key].nil?
15
+ end
16
+
17
+ def get_by_key key, hash
18
+ hash[key]
19
+ end
20
+
21
+ def get_response_code hash={}
22
+ response_code = ''
23
+
24
+ if key_exists 'response_code', hash
25
+ response_code = hash['response_code']
26
+ elsif key_exists 'responseCode', hash
27
+ response_code = hash['responseCode']
28
+ elsif key_exists 'response', hash
29
+ response_code = hash['response']
30
+ end
31
+
32
+ response_code
33
+ end
34
+ end
35
+ end
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'lime_light_platform'
3
+ s.version = '1.0.0.11'
4
+ s.date = '2018-05-07'
5
+ s.summary = "Official Lime Light eCommerce Platform API Ruby Gem"
6
+ s.description = "Official Lime Light eCommerce Platform API Ruby Gem"
7
+ s.authors = ["Marvin Titus-Casseus"]
8
+ s.email = 'mtitus-casseus@limelightcrm.com'
9
+ s.files = ["lib/lime_light_platform.rb"]
10
+ s.homepage = 'https://rubygems.org/gems/lime_light_platform'
11
+ s.license = 'Lime Light CRM Inc'
12
+ s.files = Dir['**/*'].keep_if { |file| File.file?(file) }
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LimeLightPlatform, "#billing_model_view" do
4
+ context "Lime Light Platform - Membership API - billing_model_view" do
5
+ it "Returns all the data for a given set of billing model(s)" do
6
+ lime_light = LimeLightPlatform.new(ENV['APP_KEY'], ENV['API_USERNAME'], ENV['API_PASSWORD'], ENV['DEV_SUB'])
7
+ response = lime_light.billing_model_view ENV['TEST_OFFER_ID_1']
8
+
9
+ if !response[:success]
10
+ ap 'TEST FAILED - API RESPONSE'
11
+ ap response
12
+ end
13
+
14
+ expect(response[:success]).to eq true
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LimeLightPlatform, "#campaign_find_active" do
4
+ context "Lime Light Platform - Membership API - campaign_find_active" do
5
+ it "Returns all active campaigns for the CRM instance" do
6
+ lime_light = LimeLightPlatform.new(ENV['APP_KEY'], ENV['API_USERNAME'], ENV['API_PASSWORD'], ENV['DEV_SUB'])
7
+ response = lime_light.campaign_find_active
8
+
9
+ if !response[:success]
10
+ ap 'TEST FAILED - API RESPONSE'
11
+ ap response
12
+ end
13
+
14
+ expect(response[:success]).to eq true
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LimeLightPlatform, "#campaign_view" do
4
+ context "Lime Light Platform - Membership API - campaign_view" do
5
+ it "Returns data that describes a given campaign" do
6
+ lime_light = LimeLightPlatform.new(ENV['APP_KEY'], ENV['API_USERNAME'], ENV['API_PASSWORD'], ENV['DEV_SUB'])
7
+ response = lime_light.campaign_view ENV['TEST_CAMPAIGNID']
8
+
9
+ if !response[:success]
10
+ ap 'TEST FAILED - API RESPONSE'
11
+ ap response
12
+ end
13
+
14
+ expect(response[:success]).to eq true
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LimeLightPlatform, "#gateway_view" do
4
+ context "Lime Light Platform - Membership API - gateway_view" do
5
+ it "Returns data that describes a given gateway" do
6
+ lime_light = LimeLightPlatform.new(ENV['APP_KEY'], ENV['API_USERNAME'], ENV['API_PASSWORD'], ENV['DEV_SUB'])
7
+ response = lime_light.gateway_view ENV['TEST_GATEWAY_ID_2']
8
+
9
+ if !response[:success]
10
+ ap 'TEST FAILED - API RESPONSE'
11
+ ap response
12
+ end
13
+
14
+ expect(response[:success]).to eq true
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LimeLightPlatform, "#campaign_find_active" do
4
+ context "Lime Light Platform - Transaction API - NewOrder" do
5
+ it "Places a new order using billing model configuration" do
6
+ lime_light = LimeLightPlatform.new(ENV['APP_KEY'], ENV['API_USERNAME'], ENV['API_PASSWORD'], ENV['DEV_SUB'])
7
+ response = lime_light.new_order({
8
+ 'first_name' => ENV['TEST_FIRSTNAME'],
9
+ 'last_name' => ENV['TEST_LASTNAME'],
10
+ 'shipping_address_1' => ENV['TEST_SHIPPINGADDRESS1'],
11
+ 'shipping_address_2' => ENV['TEST_SHIPPINGADDRESS2'],
12
+ 'shipping_city' => ENV['TEST_SHIPPINGCITY'],
13
+ 'shipping_state' => ENV['TEST_SHIPPINGSTATE'],
14
+ 'shipping_zip' => ENV['TEST_SHIPPINGZIP'],
15
+ 'shipping_country' => ENV['TEST_SHIPPINGCOUNTRY'],
16
+ 'billing_first_name' => ENV['TEST_BILLINGFIRSTNAME'],
17
+ 'billing_last_name' => ENV['TEST_BILLINGLASTNAME'],
18
+ 'billing_address_1' => ENV['TEST_BILLINGADDRESS1'],
19
+ 'billing_address_2' => ENV['TEST_BILLINGADDRESS2'],
20
+ 'billing_city' => ENV['TEST_BILLINGCITY'],
21
+ 'billing_state' => ENV['TEST_BILLINGSTATE'],
22
+ 'billing_zip' => ENV['TEST_BILLINGZIP'],
23
+ 'billing_country' => ENV['TEST_BILLINGCOUNTRY'],
24
+ 'phone' => ENV['TEST_PHONE'],
25
+ 'email' => ENV['TEST_EMAIL'],
26
+ 'credit_card_type' => ENV['TEST_CREDITCARDTYPE'],
27
+ 'credit_card_number' => ENV['TEST_CREDITCARDNUMBER'],
28
+ 'expiration_date' => ENV['TEST_EXPIRATIONDATE'],
29
+ 'cvv' => ENV['TEST_CVV'],
30
+ 'shipping_id' => ENV['TEST_SHIPPINGID'],
31
+ 'tran_type' => ENV['TEST_TRANTYPE'],
32
+ 'ip_address' => ENV['TEST_IPADDRESS'],
33
+ 'campaign_id' => ENV['TEST_CAMPAIGNID'],
34
+ 'notes' => ENV['TEST_NOTES'],
35
+ 'utm_source' => ENV['TEST_UTM_SOURCE'],
36
+ 'utm_medium' => ENV['TEST_UTM_MEDIUM'],
37
+ 'utm_campaign' => ENV['TEST_UTM_CAMPAIGN'],
38
+ 'utm_content' => ENV['TEST_UTM_CONTENT'],
39
+ 'utm_term' => ENV['TEST_UTM_TERM'],
40
+ 'products' => {
41
+ ENV['TEST_PRODUCT_1'] => {
42
+ 'offer_id' => ENV['TEST_OFFER_ID_1'],
43
+ 'billing_model_id' => ENV['TEST_BILLING_MODEL_ID_1'],
44
+ 'quantity' => ENV['TEST_QUANTITY_1']
45
+ },
46
+ ENV['TEST_PRODUCT_2'] => {
47
+ 'offer_id' => ENV['TEST_OFFER_ID_2'],
48
+ 'billing_model_id' => ENV['TEST_BILLING_MODEL_ID_2'],
49
+ 'quantity' => ENV['TEST_QUANTITY_3']
50
+ }
51
+ }
52
+ })
53
+
54
+ if !response[:success]
55
+ ap 'TEST FAILED - API RESPONSE'
56
+ ap response
57
+ end
58
+
59
+ expect(response[:success]).to eq true
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LimeLightPlatform, "#offer_view" do
4
+ context "Lime Light Platform - Membersip API - offer_view" do
5
+ it "Returns offer data for a given campaign" do
6
+ lime_light = LimeLightPlatform.new(ENV['APP_KEY'], ENV['API_USERNAME'], ENV['API_PASSWORD'], ENV['DEV_SUB'])
7
+ response = lime_light.offer_view ENV['TEST_CAMPAIGNID']
8
+
9
+ if !response[:success]
10
+ ap 'TEST FAILED - API RESPONSE'
11
+ ap response
12
+ end
13
+
14
+ expect(response[:success]).to eq true
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LimeLightPlatform, "#product_create" do
4
+ context "Lime Light Platform - Membersip API - product_create" do
5
+ it "Creates a Lime Light Product" do
6
+ lime_light = LimeLightPlatform.new(ENV['APP_KEY'], ENV['API_USERNAME'], ENV['API_PASSWORD'], ENV['DEV_SUB'])
7
+ response = lime_light.product_create({
8
+ 'customer_purchase_limit' => ENV['TEST_CUSTOMER_PURCHASE_LIMIT'],
9
+ 'taxable' => ENV['TEST_TAXABLE'],
10
+ 'shippable' => ENV['TEST_SHIPPABLE'],
11
+ 'signature_confirmation' => ENV['TEST_SIGNATURE_CONFIRMATION'],
12
+ 'delivery_confirmation' => ENV['TEST_DELIVERY_CONFIRMATION'],
13
+ 'preserve_quantity' => ENV['TEST_PRESERVE_QUANTITY'],
14
+ 'collections' => ENV['TEST_COLLECTIONS'],
15
+ 'shipping_declared_value' => ENV['TEST_SHIPPING_DECLARED_VALUE'],
16
+ 'product_price' => ENV['TEST_PRODUCT_PRICE'],
17
+ 'product_restocking_fee' => ENV['TEST_PRODUCT_RESTOCKING_FEE'],
18
+ 'shipping_weight' => ENV['TEST_SHIPPING_WEIGHT'],
19
+ 'product_sku' => ENV['TEST_PRODUCT_SKU'] + Random.new.rand(10...1000).to_s,
20
+ 'shipping_digital_url' => ENV['TEST_SHIPPING_DIGITAL_URL'],
21
+ 'recurring_discount_max' => ENV['TEST_RECURRING_DISCOUNT_MAX'],
22
+ 'product_name' => ENV['TEST_PRODUCT_NAME'] + Random.new.rand(10...1000).to_s,
23
+ 'product_description' => ENV['TEST_PRODUCT_DESCRIPTION'] + Random.new.rand(10...1000).to_s,
24
+ 'category_id' => ENV['TEST_CATEGORY_ID'],
25
+ 'vertical_id' => ENV['TEST_VERTICAL_ID'],
26
+ 'cost_of_goods_sold' => ENV['TEST_COST_OF_GOODS_SOLD'],
27
+ 'product_max_quantity' => ENV['TEST_PRODUCT_MAX_QUANTITY']
28
+ })
29
+
30
+ if !response[:success]
31
+ ap 'TEST FAILED - API RESPONSE'
32
+ ap response
33
+ end
34
+
35
+ expect(response[:success]).to eq true
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LimeLightPlatform, "#product_update" do
4
+ context "Lime Light Platform - Membersip API - product_update" do
5
+ it "Updates a Lime Light Product" do
6
+ lime_light = LimeLightPlatform.new(ENV['APP_KEY'], ENV['API_USERNAME'], ENV['API_PASSWORD'], ENV['DEV_SUB'])
7
+ response = lime_light.product_update({
8
+ 'product_id' => ENV['TEST_UPDATE_PRODUCT_ID'],
9
+ 'product_name' => ENV['TEST_UPDATE_PRODUCT_NAME'] + Random.new.rand(10...1000).to_s,
10
+ 'product_description' => ENV['TEST_UPDATE_PRODUCT_DESC'] + Random.new.rand(10...1000).to_s
11
+ })
12
+
13
+ if !response[:success]
14
+ ap 'TEST FAILED - API RESPONSE'
15
+ ap response
16
+ end
17
+
18
+ expect(response[:success]).to eq true
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'lime_light_platform'
5
+ require 'dotenv'
6
+ require 'awesome_print'
7
+ Dotenv.load
8
+
9
+ RSpec.configure do |config|
10
+ # some (optional) config here
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lime_light_platform
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.10
4
+ version: 1.0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marvin Titus-Casseus
@@ -16,7 +16,26 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - Gemfile
20
+ - Gemfile.lock
19
21
  - lib/lime_light_platform.rb
22
+ - lib/lime_light_platform/api_error.rb
23
+ - lib/lime_light_platform/app_base.rb
24
+ - lib/lime_light_platform/helpers/accessor.rb
25
+ - lime_light_platform-1.0.0.10.gem
26
+ - lime_light_platform-1.0.0.7.gem
27
+ - lime_light_platform-1.0.0.8.gem
28
+ - lime_light_platform-1.0.0.9.gem
29
+ - lime_light_platform.gemspec
30
+ - spec/billing_model_view_spec.rb
31
+ - spec/campaign_find_active_spec.rb
32
+ - spec/campaign_view_spec.rb
33
+ - spec/gateway_view_spec.rb
34
+ - spec/new_order_spec.rb
35
+ - spec/offer_view_spec.rb
36
+ - spec/product_create_spec.rb
37
+ - spec/product_update_spec.rb
38
+ - spec/spec_helper.rb
20
39
  homepage: https://rubygems.org/gems/lime_light_platform
21
40
  licenses:
22
41
  - Lime Light CRM Inc