bws 0.2.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +36 -0
- data/LICENSE +20 -0
- data/README.rdoc +116 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/bws.gemspec +133 -0
- data/lib/bws.rb +13 -0
- data/lib/bws/acknowledge_order.rb +11 -0
- data/lib/bws/active_isbn_report.rb +27 -0
- data/lib/bws/checkout.rb +30 -0
- data/lib/bws/client.rb +807 -0
- data/lib/bws/create_shipment.rb +11 -0
- data/lib/bws/fillable_orders.rb +15 -0
- data/lib/bws/inventory.rb +58 -0
- data/lib/bws/order.rb +10 -0
- data/lib/bws/order_events.rb +28 -0
- data/lib/bws/orders.rb +14 -0
- data/lib/bws/reject_line_item.rb +11 -0
- data/lib/bws/response.rb +8 -0
- data/lib/bws/unacknowledged_orders.rb +23 -0
- data/test/fixtures/acknowledge_success.xml +11 -0
- data/test/fixtures/active_isbn_report_with_one_isbn_request_body.xml +13 -0
- data/test/fixtures/active_isbn_report_with_one_isbn_success.xml +38 -0
- data/test/fixtures/active_isbn_report_with_two_isbns_request_body.xml +16 -0
- data/test/fixtures/active_isbn_report_with_two_isbns_success.xml +57 -0
- data/test/fixtures/cancel_line_item_success.xml +11 -0
- data/test/fixtures/create_order_request_body.xml +70 -0
- data/test/fixtures/create_order_response_success.xml +14 -0
- data/test/fixtures/create_shipment_success.xml +11 -0
- data/test/fixtures/fillable_success.xml +127 -0
- data/test/fixtures/inventory_by_isbn_success.xml +36 -0
- data/test/fixtures/inventory_success.xml +54 -0
- data/test/fixtures/order_events_by_order_success.xml +68 -0
- data/test/fixtures/order_events_success.xml +65 -0
- data/test/fixtures/order_success.xml +37 -0
- data/test/fixtures/orders_show_success.xml +37 -0
- data/test/fixtures/price_order_request_body.xml +46 -0
- data/test/fixtures/price_order_response_success.xml +63 -0
- data/test/fixtures/single_post_create_order_request_body.xml +62 -0
- data/test/fixtures/single_post_create_order_response_success.xml +13 -0
- data/test/fixtures/unacknowledged_success.xml +122 -0
- data/test/fixtures/unacknowledged_success_0_orders.xml +12 -0
- data/test/fixtures/unacknowledged_success_1_order.xml +37 -0
- data/test/fixtures/validate_credit_card_request_body.xml +39 -0
- data/test/fixtures/validate_credit_card_response_success.xml +14 -0
- data/test/helper.rb +23 -0
- data/test/integration/test_bws_active_isbn_report.rb +28 -0
- data/test/integration/test_bws_retrieve_inventory.rb +31 -0
- data/test/unit/test_bws_acknowledge_order.rb +24 -0
- data/test/unit/test_bws_active_isbn_report.rb +45 -0
- data/test/unit/test_bws_checkout.rb +117 -0
- data/test/unit/test_bws_client.rb +370 -0
- data/test/unit/test_bws_create_shipment.rb +26 -0
- data/test/unit/test_bws_fillable_orders.rb +41 -0
- data/test/unit/test_bws_order.rb +25 -0
- data/test/unit/test_bws_reject_line_item.rb +26 -0
- data/test/unit/test_bws_response.rb +7 -0
- data/test/unit/test_bws_retrieve_inventory.rb +42 -0
- data/test/unit/test_bws_retrieve_inventory_by_isbn.rb +25 -0
- data/test/unit/test_bws_retrieve_order_events.rb +42 -0
- data/test/unit/test_bws_retrieve_order_events_by_order.rb +37 -0
- data/test/unit/test_bws_unacknowledged_orders.rb +74 -0
- data/test/unit/test_retrieve_orders_show.rb +27 -0
- metadata +293 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestBwsAcknowledgeOrder < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
FakeWeb.allow_net_connect = false
|
6
|
+
end
|
7
|
+
|
8
|
+
context "acknowledge success" do
|
9
|
+
setup do
|
10
|
+
@key = 'my_api_key'
|
11
|
+
@url_prefix = 'https://bws.bookrenter.com/v1'
|
12
|
+
@client = BWS::Client.new(@key)
|
13
|
+
@url = "/distributor_orders/BR-1234/acknowledge.xml"
|
14
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'acknowledge_success.xml')
|
15
|
+
@response = @client.acknowledge_order({'order' => 'data', 'public_id' => 'BR-1234', 'distributor_line_items' => {'distributor_line_item' => {'public_id' => 'some-line-item-public-id'}}})
|
16
|
+
end
|
17
|
+
|
18
|
+
context ".result" do
|
19
|
+
should "be true" do
|
20
|
+
assert_equal true, @response.result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestBwsActiveIsbnReport < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
FakeWeb.allow_net_connect = false
|
6
|
+
end
|
7
|
+
|
8
|
+
context "active isbn report success" do
|
9
|
+
setup do
|
10
|
+
@key = 'my_api_key'
|
11
|
+
@url_prefix = 'https://bws.bookrenter.com/v1'
|
12
|
+
@client = BWS::Client.new(@key)
|
13
|
+
@url = "/reports/active_isbn_report.xml"
|
14
|
+
end
|
15
|
+
|
16
|
+
context "active_isbn_report with one isbn" do
|
17
|
+
setup do
|
18
|
+
@active_isbn_report_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "active_isbn_report_with_one_isbn_request_body.xml"))
|
19
|
+
@active_isbn_report_hash = Hash.from_xml(@active_isbn_report_request_body_xml)["reports_active_isbn_report"]
|
20
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'active_isbn_report_with_one_isbn_success.xml')
|
21
|
+
end
|
22
|
+
|
23
|
+
should "title not nil" do
|
24
|
+
@response = @client.retrieve_active_isbn_report @active_isbn_report_hash
|
25
|
+
assert_equal 1, @response.active_isbns.size
|
26
|
+
assert_equal "Managerial Accounting", @response.active_isbns.first['title']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "active_isbn_report with two isbns" do
|
31
|
+
setup do
|
32
|
+
@active_isbn_report_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "active_isbn_report_with_two_isbns_request_body.xml"))
|
33
|
+
@active_isbn_report_hash = Hash.from_xml(@active_isbn_report_request_body_xml)["reports_active_isbn_report"]
|
34
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'active_isbn_report_with_two_isbns_success.xml')
|
35
|
+
end
|
36
|
+
|
37
|
+
should "title not nil" do
|
38
|
+
@response = @client.retrieve_active_isbn_report @active_isbn_report_hash
|
39
|
+
assert_equal 2, @response.active_isbns.size
|
40
|
+
assert_equal "Managerial Accounting", @response.active_isbns.first['title']
|
41
|
+
assert_equal "Managerial Accounting II", @response.active_isbns.last['title']
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestBwsCheckout < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
FakeWeb.allow_net_connect = false
|
6
|
+
end
|
7
|
+
|
8
|
+
context "checkout price order success" do
|
9
|
+
setup do
|
10
|
+
@key = 'my_api_key'
|
11
|
+
@url_prefix = 'https://bws.bookrenter.com/v1'
|
12
|
+
@client = BWS::Client.new(@key)
|
13
|
+
@price_order_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "price_order_request_body.xml"))
|
14
|
+
@checkout_price_order_hash = Hash.from_xml(@price_order_request_body_xml)['checkout_price_order']
|
15
|
+
@url = "/checkout/price_order.xml"
|
16
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'price_order_response_success.xml')
|
17
|
+
end
|
18
|
+
|
19
|
+
context ".price_order" do
|
20
|
+
should "checkout_verification_code not nil" do
|
21
|
+
@response = @client.checkout_price_order @checkout_price_order_hash
|
22
|
+
assert_not_nil @response.price_order['checkout_verification_code']
|
23
|
+
end
|
24
|
+
|
25
|
+
should "customer_verification_code not nil" do
|
26
|
+
@response = @client.checkout_price_order @checkout_price_order_hash
|
27
|
+
assert_not_nil @response.price_order['customer']['customer_verification_code']
|
28
|
+
end
|
29
|
+
|
30
|
+
should "product_list_verification_code not nil" do
|
31
|
+
@response = @client.checkout_price_order @checkout_price_order_hash
|
32
|
+
assert_not_nil @response.price_order['product_list']['product_list_verification_code']
|
33
|
+
end
|
34
|
+
|
35
|
+
should "billing_address_verification_code not nil" do
|
36
|
+
@response = @client.checkout_price_order @checkout_price_order_hash
|
37
|
+
assert_not_nil @response.price_order['billing_address']['billing_address_verification_code']
|
38
|
+
end
|
39
|
+
|
40
|
+
should "shipping_address_verification_code not nil" do
|
41
|
+
@response = @client.checkout_price_order @checkout_price_order_hash
|
42
|
+
assert_not_nil @response.price_order['shipping_address']['shipping_address_verification_code']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "checkout validate credit card success" do
|
49
|
+
setup do
|
50
|
+
@key = 'my_api_key'
|
51
|
+
@url_prefix = 'https://bws.bookrenter.com/v1'
|
52
|
+
@client = BWS::Client.new(@key)
|
53
|
+
@validate_credit_card_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "validate_credit_card_request_body.xml"))
|
54
|
+
@checkout_validate_credit_card_hash = Hash.from_xml(@validate_credit_card_request_body_xml)['checkout_validate_credit_card']
|
55
|
+
@url = "/checkout/validate_credit_card.xml"
|
56
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'validate_credit_card_response_success.xml')
|
57
|
+
end
|
58
|
+
|
59
|
+
context ".validate_credit_card" do
|
60
|
+
should "checkout_verification_code not nil" do
|
61
|
+
@response = @client.checkout_validate_credit_card @checkout_validate_credit_card_hash
|
62
|
+
assert_not_nil @response.validate_credit_card['checkout_verification_code']
|
63
|
+
end
|
64
|
+
|
65
|
+
should "credit_card_verification_code not nil" do
|
66
|
+
@response = @client.checkout_validate_credit_card @checkout_validate_credit_card_hash
|
67
|
+
assert_not_nil @response.validate_credit_card['credit_card']['credit_card_verification_code']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
context "checkout create order success" do
|
74
|
+
setup do
|
75
|
+
@key = 'my_api_key'
|
76
|
+
@url_prefix = 'https://bws.bookrenter.com/v1'
|
77
|
+
@client = BWS::Client.new(@key)
|
78
|
+
@create_order_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "create_order_request_body.xml"))
|
79
|
+
@checkout_create_order_hash = Hash.from_xml(@create_order_request_body_xml)['checkout_create_order']
|
80
|
+
@url = "/checkout/create_order.xml"
|
81
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'create_order_response_success.xml')
|
82
|
+
end
|
83
|
+
|
84
|
+
context ".create_order" do
|
85
|
+
should "checkout_verification_code not nil" do
|
86
|
+
@response = @client.checkout_create_order @checkout_create_order_hash
|
87
|
+
assert_not_nil @response.create_order['checkout_verification_code']
|
88
|
+
end
|
89
|
+
|
90
|
+
should "public_id not nil" do
|
91
|
+
@response = @client.checkout_create_order @checkout_create_order_hash
|
92
|
+
assert_not_nil @response.create_order['order']['public_id']
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
context "checkout single post create order success" do
|
99
|
+
setup do
|
100
|
+
@key = 'my_api_key'
|
101
|
+
@url_prefix = 'https://bws.bookrenter.com/v1'
|
102
|
+
@client = BWS::Client.new(@key)
|
103
|
+
@single_post_create_order_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "single_post_create_order_request_body.xml"))
|
104
|
+
@checkout_single_post_create_order_hash = Hash.from_xml(@single_post_create_order_request_body_xml)['checkout_single_post_create_order']
|
105
|
+
@url = "/checkout/single_post_create_order.xml"
|
106
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'single_post_create_order_response_success.xml')
|
107
|
+
end
|
108
|
+
|
109
|
+
context ".single_post_create_order" do
|
110
|
+
should "public_id not nil" do
|
111
|
+
@response = @client.checkout_single_post_create_order @checkout_single_post_create_order_hash
|
112
|
+
assert_not_nil @response.single_post_create_order['order']['public_id']
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,370 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
|
4
|
+
class TestBwsClient < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
FakeWeb.allow_net_connect = false
|
7
|
+
end
|
8
|
+
|
9
|
+
context "initializing" do
|
10
|
+
should "accept and store an API KEY" do
|
11
|
+
client = BWS::Client.new('my_api_key')
|
12
|
+
assert_equal BWS::Client, client.class
|
13
|
+
assert_equal client.api_key, 'my_api_key'
|
14
|
+
end
|
15
|
+
|
16
|
+
should "accept an use an optional passed in base_uri" do
|
17
|
+
client = BWS::Client.new('my_api_key', 'http://some_uri.com')
|
18
|
+
assert_equal client.base_uri, 'http://some_uri.com'
|
19
|
+
BWS::Client.expects(:get).with('http://some_uri.com/distributor_orders/unacknowledged.xml?page=1&api_key=my_api_key', :timeout => 5)
|
20
|
+
client.unacknowledged_orders
|
21
|
+
end
|
22
|
+
|
23
|
+
should "raise an error if no API KEY is passed in" do
|
24
|
+
assert_raise(BWS::Client::MissingApiKey) { BWS::Client.new() }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with a working client" do
|
29
|
+
setup do
|
30
|
+
@key = 'my_api_key'
|
31
|
+
@url_prefix = 'https://bws.bookrenter.com/v1'
|
32
|
+
@client = BWS::Client.new(@key)
|
33
|
+
end
|
34
|
+
|
35
|
+
context "requesting unacknowledged orders" do
|
36
|
+
setup do
|
37
|
+
@url = "/distributor_orders/unacknowledged.xml?page=1"
|
38
|
+
fake_get("#{@url_prefix}#{@url}&api_key=#{@key}", 'unacknowledged_success.xml')
|
39
|
+
end
|
40
|
+
|
41
|
+
should "load the API page" do
|
42
|
+
@client.expects(:get).with(@url)
|
43
|
+
@client.unacknowledged_orders
|
44
|
+
end
|
45
|
+
|
46
|
+
should "return a BWS::UnacknowledgedOrders object" do
|
47
|
+
assert_equal BWS::UnacknowledgedOrders, @client.unacknowledged_orders.class
|
48
|
+
end
|
49
|
+
|
50
|
+
should "load subsequent pages" do
|
51
|
+
@client.expects(:get).with(@url.gsub!('page=1', 'page=3'))
|
52
|
+
@client.unacknowledged_orders(3)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "requesting fillable orders" do
|
57
|
+
setup do
|
58
|
+
@url = "/distributor_orders/fillable.xml?page=1"
|
59
|
+
fake_get("#{@url_prefix}#{@url}&api_key=#{@key}", 'fillable_success.xml')
|
60
|
+
end
|
61
|
+
|
62
|
+
should "load the API page" do
|
63
|
+
@client.expects(:get).with(@url)
|
64
|
+
@client.fillable_orders
|
65
|
+
end
|
66
|
+
|
67
|
+
should "return a BWS::FillableOrders object" do
|
68
|
+
assert_equal BWS::FillableOrders, @client.fillable_orders.class
|
69
|
+
end
|
70
|
+
|
71
|
+
should "load subsequent pages" do
|
72
|
+
@client.expects(:get).with(@url.gsub!('page=1', 'page=3'))
|
73
|
+
@client.fillable_orders(3)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "requesting an order" do
|
78
|
+
setup do
|
79
|
+
@order_id = 'test_order_id'
|
80
|
+
@url = "/distributor_orders/#{@order_id}.xml"
|
81
|
+
fake_get("#{@url_prefix}#{@url}?api_key=#{@key}", 'order_success.xml')
|
82
|
+
end
|
83
|
+
|
84
|
+
should "load the API page" do
|
85
|
+
@client.expects(:get).with(@url)
|
86
|
+
@client.order(@order_id)
|
87
|
+
end
|
88
|
+
|
89
|
+
should "raise an error if there is no order_id passed in" do
|
90
|
+
assert_raise(BWS::Client::BadParams) { @client.order }
|
91
|
+
end
|
92
|
+
|
93
|
+
should "return a BWS::Order object" do
|
94
|
+
assert_equal BWS::Order, @client.order(@order_id).class
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "acknowledging an order" do
|
99
|
+
setup do
|
100
|
+
@order_id = 'test_order_id'
|
101
|
+
@order_hash = {'order' => 'data', 'public_id' => @order_id, 'distributor_line_items' => {'distributor_line_item' => {'public_id' => 'some-line-item-public-id', 'status' => 'accepted'}}}
|
102
|
+
@url = "/distributor_orders/#{@order_id}/acknowledge.xml"
|
103
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'acknowledge_success.xml')
|
104
|
+
end
|
105
|
+
|
106
|
+
should "raise an error if there is no hash passed in" do
|
107
|
+
assert_raise(BWS::Client::BadParams) { @client.acknowledge_order }
|
108
|
+
end
|
109
|
+
|
110
|
+
should "post to the order acknowledge page" do
|
111
|
+
@client.expects(:post).with(@url, '<envelope><body><distributor_orders_acknowledge><distributor_order><public_id>test_order_id</public_id><distributor_line_items><distributor_line_item><public_id>some-line-item-public-id</public_id><status>accepted</status></distributor_line_item></distributor_line_items></distributor_order></distributor_orders_acknowledge></body></envelope>')
|
112
|
+
@client.acknowledge_order(@order_hash)
|
113
|
+
end
|
114
|
+
|
115
|
+
should "return a BWS::AcknowledgeOrder object" do
|
116
|
+
assert_equal BWS::AcknowledgeOrder, @client.acknowledge_order(@order_hash).class
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context "creating a shipment" do
|
121
|
+
setup do
|
122
|
+
@order_id = 'test_order_id'
|
123
|
+
@order_hash = {'order' => 'data', 'public_id' => @order_id, 'distributor_line_items' => []}
|
124
|
+
@url = "/distributor_orders/#{@order_id}/distributor_outbound_shipments.xml"
|
125
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'create_shipment_success.xml')
|
126
|
+
end
|
127
|
+
|
128
|
+
should "raise an error if there is no hash passed in" do
|
129
|
+
assert_raise(BWS::Client::BadParams) { @client.create_shipment }
|
130
|
+
end
|
131
|
+
|
132
|
+
should "post to the order acknowledge page" do
|
133
|
+
@client.expects(:post).with(@url, '<envelope><body><distributor_outbound_shipments_create><distributor_outbound_shipment><shipping_method></shipping_method><carrier></carrier><distributor_line_items></distributor_line_items></distributor_outbound_shipment></distributor_outbound_shipments_create></body></envelope>')
|
134
|
+
@client.create_shipment(@order_hash)
|
135
|
+
end
|
136
|
+
|
137
|
+
should "return a BWS::CreateShipment object" do
|
138
|
+
assert_equal BWS::CreateShipment, @client.create_shipment(@order_hash).class
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "cancelling a line item" do
|
143
|
+
setup do
|
144
|
+
@order_id = 'test_order_id'
|
145
|
+
@order_hash = {'order' => 'data', 'public_id' => @order_id}
|
146
|
+
@url = "/distributor_line_items/#{@order_id}/reject.xml"
|
147
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'cancel_line_item_success.xml')
|
148
|
+
end
|
149
|
+
|
150
|
+
should "raise an error if there is no hash passed in" do
|
151
|
+
assert_raise(BWS::Client::BadParams) { @client.reject_line_item }
|
152
|
+
end
|
153
|
+
|
154
|
+
should "post to the order acknowledge page" do
|
155
|
+
@client.expects(:post).with(@url, '<envelope><body><distributor_line_items_reject><distributor_line_item><public_id>test_order_id</public_id><status>rejected</status><reject_reason></reject_reason></distributor_line_item></distributor_line_items_reject></body></envelope>')
|
156
|
+
@client.reject_line_item(@order_hash)
|
157
|
+
end
|
158
|
+
|
159
|
+
should "return a BWS::RejectLineItem object" do
|
160
|
+
assert_equal BWS::RejectLineItem, @client.reject_line_item(@order_hash).class
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
#
|
165
|
+
# This context concentrates on the inventory portion of the API
|
166
|
+
#
|
167
|
+
context "Acquiring Inventory" do
|
168
|
+
setup do
|
169
|
+
@url = "/inventory_books.xml"
|
170
|
+
fake_get("#{@url_prefix}#{@url}?api_key=#{@key}", 'inventory_success.xml')
|
171
|
+
end
|
172
|
+
|
173
|
+
should "Should return an BWS::Inventory object" do
|
174
|
+
assert_equal BWS::Inventory, @client.retrieve_inventory.class
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
context "Acquiring Inventory By ISBN" do
|
180
|
+
setup do
|
181
|
+
@isbn = "9780007138210"
|
182
|
+
@url = "/inventory_books/#{@isbn}.xml"
|
183
|
+
fake_get("#{@url_prefix}#{@url}?api_key=#{@key}", 'inventory_by_isbn_success.xml')
|
184
|
+
end
|
185
|
+
|
186
|
+
should "Should return an BWS::Inventory object" do
|
187
|
+
assert_equal BWS::Inventory, @client.retrieve_inventory_by_isbn(@isbn, nil).class
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
#
|
193
|
+
# This context concentrates on the order_events portion of the API
|
194
|
+
#
|
195
|
+
context "Acquiring OrderEvents" do
|
196
|
+
setup do
|
197
|
+
@url = "/order_events.xml"
|
198
|
+
fake_get("#{@url_prefix}#{@url}?api_key=#{@key}", 'order_events_success.xml')
|
199
|
+
end
|
200
|
+
|
201
|
+
should "Should return an BWS::OrderEvents object" do
|
202
|
+
assert_equal BWS::OrderEvents, @client.retrieve_order_events.class
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
context "Acquiring OrderEvents By Order" do
|
208
|
+
setup do
|
209
|
+
@br_order_id = 'BR-A07824046'
|
210
|
+
@url = "/order_events/#{@br_order_id}.xml"
|
211
|
+
fake_get("#{@url_prefix}#{@url}?api_key=#{@key}", 'order_events_by_order_success.xml')
|
212
|
+
end
|
213
|
+
|
214
|
+
should "Should return an BWS::OrderEvents object" do
|
215
|
+
assert_equal BWS::OrderEvents, @client.retrieve_order_events_by_order(nil, @br_order_id).class
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
#
|
221
|
+
# This context concentrates on the checkout price order portion of the API
|
222
|
+
#
|
223
|
+
context "checkout price order" do
|
224
|
+
setup do
|
225
|
+
@price_order_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "price_order_request_body.xml"))
|
226
|
+
@checkout_price_order_hash = Hash.from_xml(@price_order_request_body_xml)['checkout_price_order']
|
227
|
+
@url = "/checkout/price_order.xml"
|
228
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'price_order_response_success.xml')
|
229
|
+
end
|
230
|
+
|
231
|
+
should "raise an error if there is no hash passed in" do
|
232
|
+
assert_raise(BWS::Client::BadParams) { @client.checkout_price_order }
|
233
|
+
end
|
234
|
+
|
235
|
+
should "post to the checkout_price_order" do
|
236
|
+
@client.checkout_price_order(@checkout_price_order_hash)
|
237
|
+
end
|
238
|
+
|
239
|
+
should "return a BWS::Checkout object" do
|
240
|
+
assert_equal BWS::Checkout, @client.checkout_price_order(@checkout_price_order_hash).class
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
#
|
245
|
+
# This context concentrates on the checkout validate credit card portion of the API
|
246
|
+
#
|
247
|
+
context "checkout validate credit card " do
|
248
|
+
setup do
|
249
|
+
@validate_credit_card_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "validate_credit_card_request_body.xml"))
|
250
|
+
@checkout_validate_credit_card_hash = Hash.from_xml(@validate_credit_card_request_body_xml)['checkout_validate_credit_card']
|
251
|
+
@url = "/checkout/validate_credit_card.xml"
|
252
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'validate_credit_card_response_success.xml')
|
253
|
+
end
|
254
|
+
|
255
|
+
should "raise an error if there is no hash passed in" do
|
256
|
+
assert_raise(BWS::Client::BadParams) { @client.checkout_validate_credit_card }
|
257
|
+
end
|
258
|
+
|
259
|
+
should "post to the checkout_validate_credit_card" do
|
260
|
+
@client.checkout_validate_credit_card(@checkout_validate_credit_card_hash)
|
261
|
+
end
|
262
|
+
|
263
|
+
should "return a BWS::Checkout object" do
|
264
|
+
assert_equal BWS::Checkout, @client.checkout_validate_credit_card(@checkout_validate_credit_card_hash).class
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
#
|
269
|
+
# This context concentrates on the checkout create order portion of the API
|
270
|
+
#
|
271
|
+
context "checkout create order" do
|
272
|
+
setup do
|
273
|
+
@create_order_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "create_order_request_body.xml"))
|
274
|
+
@checkout_create_order_hash = Hash.from_xml(@create_order_request_body_xml)['checkout_create_order']
|
275
|
+
@url = "/checkout/create_order.xml"
|
276
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'create_order_response_success.xml')
|
277
|
+
end
|
278
|
+
|
279
|
+
should "raise an error if there is no hash passed in" do
|
280
|
+
assert_raise(BWS::Client::BadParams) { @client.checkout_create_order }
|
281
|
+
end
|
282
|
+
|
283
|
+
should "post to the checkout_create_order" do
|
284
|
+
@client.checkout_create_order(@checkout_create_order_hash)
|
285
|
+
end
|
286
|
+
|
287
|
+
should "return a BWS::Checkout object" do
|
288
|
+
assert_equal BWS::Checkout, @client.checkout_create_order(@checkout_create_order_hash).class
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
#
|
293
|
+
# This context concentrates on the checkout create order portion of the API
|
294
|
+
#
|
295
|
+
context "checkout single post create order" do
|
296
|
+
setup do
|
297
|
+
@single_post_create_order_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "single_post_create_order_request_body.xml"))
|
298
|
+
@checkout_single_post_create_order_hash = Hash.from_xml(@single_post_create_order_request_body_xml)['checkout_single_post_create_order']
|
299
|
+
@url = "/checkout/single_post_create_order.xml"
|
300
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'single_post_create_order_response_success.xml')
|
301
|
+
end
|
302
|
+
|
303
|
+
should "raise an error if there is no hash passed in" do
|
304
|
+
assert_raise(BWS::Client::BadParams) { @client.checkout_single_post_create_order }
|
305
|
+
end
|
306
|
+
|
307
|
+
should "post to the checkout_single_post_create_order" do
|
308
|
+
@client.checkout_single_post_create_order(@checkout_single_post_create_order_hash)
|
309
|
+
end
|
310
|
+
|
311
|
+
should "return a BWS::Checkout object" do
|
312
|
+
assert_equal BWS::Checkout, @client.checkout_single_post_create_order(@checkout_single_post_create_order_hash).class
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
#
|
317
|
+
# This context concentrates on the orders portion of the API
|
318
|
+
#
|
319
|
+
context "Acquiring Orders by public_id" do
|
320
|
+
setup do
|
321
|
+
@public_id = "public_id"
|
322
|
+
@url = "/orders/#{@public_id}.xml"
|
323
|
+
fake_get("#{@url_prefix}#{@url}?api_key=#{@key}", 'orders_show_success.xml')
|
324
|
+
end
|
325
|
+
|
326
|
+
should "Should return an BWS::Orders object" do
|
327
|
+
assert_equal BWS::Orders, @client.retrieve_orders_show(@public_id).class
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
context "Acquiring Orders By external_order_id" do
|
333
|
+
setup do
|
334
|
+
@external_order_id = "external_order_id"
|
335
|
+
@url = "/orders/#{@external_order_id}.xml"
|
336
|
+
fake_get("#{@url_prefix}#{@url}?api_key=#{@key}", 'orders_show_success.xml')
|
337
|
+
end
|
338
|
+
|
339
|
+
should "Should return an BWS::Orders object" do
|
340
|
+
assert_equal BWS::Orders, @client.retrieve_orders_show(@external_order_id).class
|
341
|
+
end
|
342
|
+
|
343
|
+
end
|
344
|
+
|
345
|
+
#
|
346
|
+
# This context concentrates on the active isbn report portion of the API
|
347
|
+
#
|
348
|
+
context "active isbn report" do
|
349
|
+
setup do
|
350
|
+
@active_isbn_report_request_body_xml = File.read(File.join(File.dirname(__FILE__), '../fixtures', "active_isbn_report_with_one_isbn_request_body.xml"))
|
351
|
+
@active_isbn_report_hash = Hash.from_xml(@active_isbn_report_request_body_xml)["reports_active_isbn_report"]
|
352
|
+
@url = "/reports/active_isbn_report.xml"
|
353
|
+
fake_post("#{@url_prefix}#{@url}?api_key=#{@key}", 'active_isbn_report_with_one_isbn_success.xml')
|
354
|
+
end
|
355
|
+
|
356
|
+
should "raise an error if there is no hash passed in" do
|
357
|
+
assert_raise(BWS::Client::BadParams) { @client.retrieve_active_isbn_report }
|
358
|
+
end
|
359
|
+
|
360
|
+
should "post to active_isbn_report" do
|
361
|
+
@client.retrieve_active_isbn_report(@active_isbn_report_hash)
|
362
|
+
end
|
363
|
+
|
364
|
+
should "return a BWS::Checkout object" do
|
365
|
+
assert_equal BWS::ActiveIsbnReport, @client.retrieve_active_isbn_report(@active_isbn_report_hash).class
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
end
|
370
|
+
end
|