expressly 2.0.34.rc1 → 2.0.35.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -0
- data/.rubocop.yml +1171 -0
- data/.travis.yml +4 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +11 -0
- data/README.rdoc +35 -27
- data/app/controllers/expressly/api_controller.rb +3 -4
- data/expressly.gemspec +1 -0
- data/lib/expressly.rb +5 -3
- data/lib/expressly/api.rb +22 -24
- data/lib/expressly/domain.rb +8 -8
- data/lib/expressly/util.rb +1 -2
- data/lib/expressly/version.rb +1 -1
- data/spec/expressly/api_spec.rb +117 -0
- data/spec/expressly/plugin_provider_spec.rb +45 -0
- data/spec/expressly_spec.rb +50 -5
- data/spec/spec_helper.rb +5 -1
- metadata +19 -1
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -3,10 +3,11 @@ gem 'rake'
|
|
3
3
|
|
4
4
|
group :development do
|
5
5
|
require 'rbconfig'
|
6
|
-
|
6
|
+
gem "fakeweb", "~> 1.3"
|
7
7
|
gem 'awesome_print', '~> 1.2.0'
|
8
8
|
gem 'guard-rspec'
|
9
9
|
gem 'guard'
|
10
10
|
gem "rdoc", "~> 3.12"
|
11
|
+
gem "codeclimate-test-reporter", group: :test, require: nil
|
11
12
|
#gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
12
13
|
end
|
data/Gemfile.lock
CHANGED
@@ -4,8 +4,12 @@ GEM
|
|
4
4
|
awesome_print (1.2.0)
|
5
5
|
celluloid (0.15.2)
|
6
6
|
timers (~> 1.1.0)
|
7
|
+
codeclimate-test-reporter (0.4.8)
|
8
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
7
9
|
coderay (1.1.0)
|
8
10
|
diff-lcs (1.2.5)
|
11
|
+
docile (1.1.5)
|
12
|
+
fakeweb (1.3.0)
|
9
13
|
ffi (1.9.3)
|
10
14
|
ffi (1.9.3-x64-mingw32)
|
11
15
|
formatador (0.2.4)
|
@@ -43,6 +47,11 @@ GEM
|
|
43
47
|
rspec-expectations (2.14.4)
|
44
48
|
diff-lcs (>= 1.1.3, < 2.0)
|
45
49
|
rspec-mocks (2.14.4)
|
50
|
+
simplecov (0.11.1)
|
51
|
+
docile (~> 1.1.0)
|
52
|
+
json (~> 1.8)
|
53
|
+
simplecov-html (~> 0.10.0)
|
54
|
+
simplecov-html (0.10.0)
|
46
55
|
slop (3.4.7)
|
47
56
|
thor (0.18.1)
|
48
57
|
timers (1.1.0)
|
@@ -54,6 +63,8 @@ PLATFORMS
|
|
54
63
|
DEPENDENCIES
|
55
64
|
awesome_print (~> 1.2.0)
|
56
65
|
bundler
|
66
|
+
codeclimate-test-reporter
|
67
|
+
fakeweb (~> 1.3)
|
57
68
|
guard
|
58
69
|
guard-rspec
|
59
70
|
rake
|
data/README.rdoc
CHANGED
@@ -1,27 +1,35 @@
|
|
1
|
-
{<img src="https://buyexpressly.com/assets/img/expressly-logo-sm-gray.png" alt="Expressly" />}[https://buyexpressly.com]
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
==
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
{<img src="https://buyexpressly.com/assets/img/expressly-logo-sm-gray.png" alt="Expressly" />}[https://buyexpressly.com]
|
2
|
+
|
3
|
+
= Expressly Plug-in Ruby SDK
|
4
|
+
|
5
|
+
{<img src="https://badge.fury.io/rb/expressly.svg" alt="Gem Version" />}[https://badge.fury.io/rb/expressly]
|
6
|
+
{<img src="https://api.travis-ci.org/expressly/expressly-plugin-sdk-ruby-core.png" alt="Build Status" />}[https://travis-ci.org/expressly/expressly-plugin-sdk-ruby-core]
|
7
|
+
{<img src="https://codeclimate.com/github/expressly/expressly-plugin-sdk-ruby-core/badges/gpa.svg" />}[https://codeclimate.com/github/expressly/expressly-plugin-sdk-ruby-core]
|
8
|
+
{<img src="https://codeclimate.com/github/expressly/expressly-plugin-sdk-ruby-core/coverage.png" />}[https://codeclimate.com/github/expressly/expressly-plugin-sdk-ruby-core/coverage]
|
9
|
+
|
10
|
+
The Expressly Ruby SDK provides as much of the heavy-lifting of the Expressly Network API to help developers wishing to
|
11
|
+
integrate their rails e-commerce platform with the {Expressly network}[https://buyexpressly.com].
|
12
|
+
|
13
|
+
== Getting Started
|
14
|
+
|
15
|
+
gemfile::
|
16
|
+
gem 'expressly', '~> 2.0'
|
17
|
+
|
18
|
+
install::
|
19
|
+
gem install expressly --pre
|
20
|
+
|
21
|
+
You can find a Rails reference implementation {here}[https://github.com/expressly/expressly-plugin-rails-reference-implementation]
|
22
|
+
to help you get started.
|
23
|
+
|
24
|
+
== More Info
|
25
|
+
|
26
|
+
Further resources can be found on the {Expressly developer portal}[http://developer.buyexpressly.com].
|
27
|
+
|
28
|
+
== License
|
29
|
+
|
30
|
+
Copyright (c) 2015 Expressly. See LICENSE.txt for further details.
|
31
|
+
|
32
|
+
== One-click customer acquisition
|
33
|
+
|
34
|
+
Expressly helps merchants grow by attracting new quality visitors from other online shops where people already buy,
|
35
|
+
while making it extremely convenient for them to convert to the new shop.
|
@@ -33,7 +33,6 @@ module Expressly
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def display_popup
|
36
|
-
campaign_customer_uuid = params[:campaign_customer_uuid]
|
37
36
|
provider.popup_handler(self, params[:campaign_customer_uuid])
|
38
37
|
end
|
39
38
|
|
@@ -50,7 +49,7 @@ module Expressly
|
|
50
49
|
|
51
50
|
begin
|
52
51
|
config.expressly_provider.confirm_migration_success?(campaign_customer_uuid)
|
53
|
-
rescue
|
52
|
+
rescue StandardError => e
|
54
53
|
Expressly::logger.warn(self) {
|
55
54
|
"couldn't finalise migration campaign_customer_uuid=[#{campaign_customer_uuid}], email=[#{import.primary_email}], error=[#{e.message}]"
|
56
55
|
}
|
@@ -62,9 +61,9 @@ module Expressly
|
|
62
61
|
end
|
63
62
|
|
64
63
|
def authenticate
|
65
|
-
|
64
|
+
partitioned_api_key = config.api_key.partition(':')
|
66
65
|
authenticate_or_request_with_http_basic('expressly') do |username, password|
|
67
|
-
username ==
|
66
|
+
username == partitioned_api_key[0] && password == partitioned_api_key[2]
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
data/expressly.gemspec
CHANGED
data/lib/expressly.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'logger'
|
2
|
+
require 'base64'
|
2
3
|
|
3
4
|
module Expressly
|
4
5
|
@@logger = Logger.new(STDERR)
|
@@ -6,13 +7,14 @@ module Expressly
|
|
6
7
|
|
7
8
|
def self.logger() @@logger end
|
8
9
|
def self.logger=(logger) @@logger = logger end
|
9
|
-
|
10
|
+
|
11
|
+
@@default_configuration = nil
|
10
12
|
def self.default_configuration()
|
11
13
|
@@default_configuration
|
12
14
|
end
|
13
15
|
|
14
16
|
def self.default_configuration?()
|
15
|
-
|
17
|
+
@@default_configuration != nil
|
16
18
|
end
|
17
19
|
|
18
20
|
##
|
@@ -46,7 +48,7 @@ module Expressly
|
|
46
48
|
# * +expressly_endpoint+ - the Expressly server endpoint. Defaults to the Expressly production service.
|
47
49
|
#
|
48
50
|
def initialize(api_key, merchant_plugin_provider, merchant_plugin_endpoint, merchant_metadata = {}, expressly_endpoint = 'https://prod.expresslyapp.com/api')
|
49
|
-
@api_key = api_key
|
51
|
+
@api_key = api_key.include?(":") ? api_key : Base64.strict_decode64(api_key)
|
50
52
|
@merchant_plugin_provider = merchant_plugin_provider
|
51
53
|
@merchant_plugin_endpoint = merchant_plugin_endpoint
|
52
54
|
@expressly_endpoint = expressly_endpoint
|
data/lib/expressly/api.rb
CHANGED
@@ -2,67 +2,67 @@ module Expressly
|
|
2
2
|
class Api
|
3
3
|
|
4
4
|
def initialize(apikey, endpoint = 'https://prod.expresslyapp.com/api')
|
5
|
-
|
6
|
-
@
|
7
|
-
@
|
5
|
+
partitioned_api_key = apikey.partition(':')
|
6
|
+
@merchant_uuid = partitioned_api_key[0]
|
7
|
+
@secret_key = partitioned_api_key[2]
|
8
8
|
@endpoint = endpoint
|
9
9
|
end
|
10
10
|
|
11
11
|
def ping?
|
12
12
|
response = execute('/v1/merchant/ping', 'GET')
|
13
|
-
|
13
|
+
JSON.parse(response.body)['success']
|
14
14
|
end
|
15
15
|
|
16
|
-
def install(
|
17
|
-
|
18
|
-
|
16
|
+
def install(base_url)
|
17
|
+
api_key = Base64.strict_encode64("#{@merchant_uuid}:#{@secret_key}")
|
18
|
+
execute(
|
19
19
|
'/v2/plugin/merchant',
|
20
20
|
'POST',
|
21
|
-
"{\"apiBaseUrl\":\"#{
|
21
|
+
"{\"apiBaseUrl\":\"#{base_url}\", \"apiKey\":\"#{api_key}\"}")
|
22
22
|
end
|
23
23
|
|
24
24
|
def uninstall?
|
25
25
|
response = execute(
|
26
|
-
"/v2/plugin/merchant/#{@
|
26
|
+
"/v2/plugin/merchant/#{@merchant_uuid}",
|
27
27
|
'DELETE')
|
28
|
-
|
28
|
+
JSON.parse(response.body)['success']
|
29
29
|
end
|
30
30
|
|
31
31
|
def fetch_migration_confirmation_html(campaign_customer_uuid)
|
32
32
|
response = execute(
|
33
33
|
"/v2/migration/#{campaign_customer_uuid}",
|
34
34
|
'GET')
|
35
|
-
|
35
|
+
response.body
|
36
36
|
end
|
37
37
|
|
38
38
|
def fetch_customer_data(campaign_customer_uuid)
|
39
39
|
response = execute(
|
40
40
|
"/v2/migration/#{campaign_customer_uuid}/user",
|
41
41
|
'GET')
|
42
|
-
|
42
|
+
CustomerImport.from_json(JSON.parse(response.body))
|
43
43
|
end
|
44
44
|
|
45
45
|
def confirm_migration_success?(campaign_customer_uuid)
|
46
46
|
response = execute(
|
47
47
|
"/v2/migration/#{campaign_customer_uuid}/success",
|
48
48
|
'POST')
|
49
|
-
|
49
|
+
JSON.parse(response.body)['success']
|
50
50
|
end
|
51
51
|
|
52
|
-
def execute(
|
53
|
-
uri = URI.parse("#{@endpoint}#{
|
52
|
+
def execute(method_uri, http_verb, body = nil)
|
53
|
+
uri = URI.parse("#{@endpoint}#{method_uri}")
|
54
54
|
http = Net::HTTP.new(uri.host, uri.port)
|
55
55
|
http.use_ssl = @endpoint.start_with?('https')
|
56
56
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
57
57
|
|
58
58
|
request =
|
59
|
-
if
|
60
|
-
elsif
|
61
|
-
elsif
|
62
|
-
else raise "unexpected http verb [#{
|
59
|
+
if http_verb == 'GET' then Net::HTTP::Get.new(uri.request_uri)
|
60
|
+
elsif http_verb == 'POST' then Net::HTTP::Post.new(uri.request_uri)
|
61
|
+
elsif http_verb == 'DELETE' then Net::HTTP::Delete.new(uri.request_uri)
|
62
|
+
else raise "unexpected http verb [#{http_verb}]"
|
63
63
|
end
|
64
64
|
|
65
|
-
request.basic_auth(@
|
65
|
+
request.basic_auth(@merchant_uuid, @secret_key)
|
66
66
|
if body != nil then
|
67
67
|
request["Content-Type"] = 'application/json'
|
68
68
|
request.body = body
|
@@ -74,16 +74,14 @@ module Expressly
|
|
74
74
|
handle_error(response)
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
response
|
78
78
|
end
|
79
79
|
|
80
80
|
def handle_error(response)
|
81
81
|
is_json = response.content_type == "application/json"
|
82
82
|
body = is_json ? JSON.parse(response.body) : response.body
|
83
83
|
|
84
|
-
raise (if is_json && !body['id'].nil? then
|
85
|
-
ExpresslyError.new(body) else
|
86
|
-
HttpError.new(response) end)
|
84
|
+
raise (if is_json && !body['id'].nil? then ExpresslyError.new(body) else HttpError.new(response) end)
|
87
85
|
end
|
88
86
|
|
89
87
|
private :execute, :handle_error
|
data/lib/expressly/domain.rb
CHANGED
@@ -31,7 +31,7 @@ module Expressly
|
|
31
31
|
ObjectHelper.equals(self,object)
|
32
32
|
end
|
33
33
|
|
34
|
-
def to_json(
|
34
|
+
def to_json(_state = nil)
|
35
35
|
JSON.generate({
|
36
36
|
:meta => @metadata,
|
37
37
|
:data => {
|
@@ -126,7 +126,7 @@ module Expressly
|
|
126
126
|
datetime.nil? ? nil : DateTime.parse(datetime)
|
127
127
|
end
|
128
128
|
|
129
|
-
def to_json(
|
129
|
+
def to_json(_state = nil)
|
130
130
|
JSON.generate({
|
131
131
|
:firstName => @first_name,
|
132
132
|
:lastName => @last_name,
|
@@ -194,7 +194,7 @@ module Expressly
|
|
194
194
|
return list
|
195
195
|
end
|
196
196
|
|
197
|
-
def to_json(
|
197
|
+
def to_json(_state = nil)
|
198
198
|
JSON.generate({
|
199
199
|
:firstName => @first_name,
|
200
200
|
:lastName => @last_name,
|
@@ -253,7 +253,7 @@ module Expressly
|
|
253
253
|
return list
|
254
254
|
end
|
255
255
|
|
256
|
-
def to_json(
|
256
|
+
def to_json(_state = nil)
|
257
257
|
JSON.generate({
|
258
258
|
:type => @type.to_s,
|
259
259
|
:number => @number,
|
@@ -298,7 +298,7 @@ module Expressly
|
|
298
298
|
return list
|
299
299
|
end
|
300
300
|
|
301
|
-
def to_json(
|
301
|
+
def to_json(_state = nil)
|
302
302
|
JSON.generate({
|
303
303
|
:email => @email,
|
304
304
|
:alias => @alias
|
@@ -339,7 +339,7 @@ module Expressly
|
|
339
339
|
return list
|
340
340
|
end
|
341
341
|
|
342
|
-
def to_json(
|
342
|
+
def to_json(_state = nil)
|
343
343
|
JSON.generate({
|
344
344
|
:field => @type.to_s,
|
345
345
|
:value => @identity
|
@@ -432,7 +432,7 @@ module Expressly
|
|
432
432
|
@tax += order.tax.to_f
|
433
433
|
end
|
434
434
|
|
435
|
-
def to_json(
|
435
|
+
def to_json(_state = nil)
|
436
436
|
JSON.generate(json_attribute_map)
|
437
437
|
end
|
438
438
|
|
@@ -464,7 +464,7 @@ module Expressly
|
|
464
464
|
@order_date = if order_date.is_a? Date then order_date else Date.parse(order_date) end
|
465
465
|
end
|
466
466
|
|
467
|
-
def to_json(
|
467
|
+
def to_json(_state = nil)
|
468
468
|
JSON.generate({
|
469
469
|
:id => @order_id,
|
470
470
|
:date => @order_date,
|
data/lib/expressly/util.rb
CHANGED
data/lib/expressly/version.rb
CHANGED
@@ -0,0 +1,117 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
module Expressly
|
4
|
+
merchant_uuid = '61c8c55e-9365-11e5-ac6c-281878baaac8'
|
5
|
+
campaign_customer_uuid = '140d190c-b73c-4e59-aa01-c838c4ddde9d'
|
6
|
+
api_key = '61c8c55e-9365-11e5-ac6c-281878baaac8:d62e517165bf86562d7fe0dbf8ac2076'
|
7
|
+
api_url = 'http://localhost:8080/api'
|
8
|
+
api = Expressly::Api.new(api_key, api_url)
|
9
|
+
#FakeWeb.allow_net_connect = false
|
10
|
+
|
11
|
+
describe "Api" do
|
12
|
+
|
13
|
+
it "can ping" do
|
14
|
+
FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v1/merchant/ping",
|
15
|
+
:body => '{"success":true,"msg":"61c8c55e-9365-11e5-ac6c-281878baaac8"}')
|
16
|
+
api.ping?.should == true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "it can install" do
|
20
|
+
FakeWeb.register_uri(:post, "http://#{api_key}@localhost:8080/api/v2/plugin/merchant",
|
21
|
+
:status => ["204", "No Content"])
|
22
|
+
api.install("http://localhost:3000")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "it can uninstall" do
|
26
|
+
FakeWeb.register_uri(:delete, "http://#{api_key}@localhost:8080/api/v2/plugin/merchant/#{merchant_uuid}",
|
27
|
+
:body => '{"success":true,"msg":"Merchant uninstalled"}')
|
28
|
+
api.uninstall?.should == true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "it can fetch poup html" do
|
32
|
+
FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v2/migration/#{campaign_customer_uuid}",
|
33
|
+
:body => '<b>pop</b>')
|
34
|
+
response = api.fetch_migration_confirmation_html(campaign_customer_uuid)
|
35
|
+
response.should == '<b>pop</b>'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "it can fetch customer data" do
|
39
|
+
FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v2/migration/#{campaign_customer_uuid}/user",
|
40
|
+
:body => '{ "migration":{"meta":{"sender":"2"},"data":{"email":"m@9ls.com","customerData":' +
|
41
|
+
'{"firstName":"Marc","lastName":"Smith","gender":"M","billingAddress":0,"shippingAddress":0,' +
|
42
|
+
'"dateUpdated":"2015-11-25T13:21:04.000Z","numberOrdered":0,' +
|
43
|
+
'"onlinePresence":[{"field":"twitter","value":"mgsmith57"}],"emails":[{"email":"someone@test.com"}],' +
|
44
|
+
'"phones":[{"type":"L","number":"020 7946 0975","countryCode":44}],' +
|
45
|
+
'"addresses":[{"firstName":"Marc","lastName":"SMith","address1":"61 Wellfield Road","city":"Roath","zip":"CF24 3DG","phone":0,"stateProvince":"Cardiff","country":"GB"}]}}},' +
|
46
|
+
'"cart":{"couponCode":"coupon","productId":"product"}}')
|
47
|
+
customer_import = api.fetch_customer_data(campaign_customer_uuid)
|
48
|
+
customer_import.metadata.should == {"sender" => "2"}
|
49
|
+
customer_import.cart.coupon_code.should == 'coupon'
|
50
|
+
customer_import.cart.product_id.should == 'product'
|
51
|
+
customer_import.primary_email.should == 'm@9ls.com'
|
52
|
+
customer_import.customer.first_name.should == 'Marc'
|
53
|
+
customer_import.customer.last_name.should == 'Smith'
|
54
|
+
customer_import.customer.gender.should == Gender::Male
|
55
|
+
customer_import.customer.billing_address_index.should == 0
|
56
|
+
customer_import.customer.shipping_address_index.should == 0
|
57
|
+
customer_import.customer.last_updated.should == DateTime.parse('2015-11-25T13:21:04+00:00')
|
58
|
+
customer_import.customer.online_identity_list[0].type.should == OnlineIdentityType::Twitter
|
59
|
+
customer_import.customer.online_identity_list[0].identity.should == 'mgsmith57'
|
60
|
+
customer_import.customer.email_list[0].email.should == 'someone@test.com'
|
61
|
+
customer_import.customer.phone_list[0].number.should == '020 7946 0975'
|
62
|
+
customer_import.customer.phone_list[0].type.should == PhoneType::Landline
|
63
|
+
customer_import.customer.phone_list[0].country_code.should == 44
|
64
|
+
customer_import.customer.address_list[0].first_name.should == 'Marc'
|
65
|
+
customer_import.customer.address_list[0].last_name.should == 'SMith'
|
66
|
+
customer_import.customer.address_list[0].address_1.should == '61 Wellfield Road'
|
67
|
+
customer_import.customer.address_list[0].city.should == 'Roath'
|
68
|
+
customer_import.customer.address_list[0].zip.should == 'CF24 3DG'
|
69
|
+
customer_import.customer.address_list[0].phone_index.should == 0
|
70
|
+
customer_import.customer.address_list[0].state_province.should == 'Cardiff'
|
71
|
+
customer_import.customer.address_list[0].country.should == 'GB'
|
72
|
+
end
|
73
|
+
|
74
|
+
it "it can report the migration was successful" do
|
75
|
+
FakeWeb.register_uri(:post, "http://#{api_key}@localhost:8080/api/v2/migration/#{campaign_customer_uuid}/success",
|
76
|
+
:body => '{"success":true,"msg":"User registered as migrated"}')
|
77
|
+
response = api.confirm_migration_success?(campaign_customer_uuid)
|
78
|
+
response.should == true
|
79
|
+
end
|
80
|
+
|
81
|
+
it "it can parse the expressly error payload" do
|
82
|
+
FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v1/merchant/ping",
|
83
|
+
:status => ["400", "Bad Request"],
|
84
|
+
:content_type => "application/json",
|
85
|
+
:body => '{' +
|
86
|
+
'"id":"tid",' +
|
87
|
+
'"message":"Bad Request",' +
|
88
|
+
'"code":"USER_ALREADY_MIGRATED",' +
|
89
|
+
'"description":"ON NO",' +
|
90
|
+
'"causes":["cause"],' +
|
91
|
+
'"actions":["action"]}')
|
92
|
+
begin
|
93
|
+
api.ping?
|
94
|
+
rescue ExpresslyError => e
|
95
|
+
e.id.should == 'tid'
|
96
|
+
e.message.should == 'Bad Request'
|
97
|
+
e.code.should == 'USER_ALREADY_MIGRATED'
|
98
|
+
e.description.should == 'ON NO'
|
99
|
+
e.causes[0].should == 'cause'
|
100
|
+
e.actions[0].should == 'action'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it "if it can parse the expressly error payload it will throw an http error" do
|
105
|
+
FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v1/merchant/ping",
|
106
|
+
:status => ["400", "Bad Request"],
|
107
|
+
:body => 'WOW')
|
108
|
+
begin
|
109
|
+
api.ping?
|
110
|
+
rescue HttpError => e
|
111
|
+
e.code.should == "400"
|
112
|
+
e.body.should == 'WOW'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|