ecommerce-client 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/README.md +25 -2
  4. data/ecommerce-client.gemspec +1 -0
  5. data/lib/ecommerce.rb +5 -0
  6. data/lib/ecommerce/attribute_handler.rb +1 -1
  7. data/lib/ecommerce/resources/account_order.rb +26 -0
  8. data/lib/ecommerce/resources/collection.rb +57 -0
  9. data/lib/ecommerce/resources/invoice_order.rb +52 -0
  10. data/lib/ecommerce/resources/invoice_order_collection.rb +20 -0
  11. data/lib/ecommerce/resources/invoice_plan.rb +27 -0
  12. data/lib/ecommerce/resources/order.rb +18 -13
  13. data/lib/ecommerce/resources/order_collection.rb +6 -48
  14. data/lib/ecommerce/version.rb +1 -1
  15. data/spec/ecommerce/attribute_handler_spec.rb +24 -0
  16. data/spec/ecommerce/resources/account_order_spec.rb +24 -0
  17. data/spec/ecommerce/resources/collection_spec.rb +70 -0
  18. data/spec/ecommerce/resources/invoice_order_collection_spec.rb +20 -0
  19. data/spec/ecommerce/resources/invoice_order_spec.rb +54 -0
  20. data/spec/ecommerce/resources/invoice_plan_spec.rb +23 -0
  21. data/spec/ecommerce/resources/order_collection_spec.rb +7 -69
  22. data/spec/ecommerce/resources/order_spec.rb +46 -5
  23. data/spec/spec_helper.rb +3 -0
  24. data/spec/vcr_cassettes/Ecommerce/Resources_AccountOrder_find_all_when_not_found_raises_NotFound.yml +219 -0
  25. data/spec/vcr_cassettes/Ecommerce/Resources_AccountOrder_find_all_when_success_returns_a_find_all_of_orders.yml +297 -0
  26. data/spec/vcr_cassettes/Ecommerce/Resources_InvoiceOrder_find_all_when_not_found_raises_NotFound.yml +30 -0
  27. data/spec/vcr_cassettes/Ecommerce/Resources_InvoiceOrder_find_all_when_success_returns_a_find_all_of_orders.yml +73 -0
  28. data/spec/vcr_cassettes/Ecommerce/Resources_InvoiceOrder_find_when_not_found_raises_NotFound.yml +46 -0
  29. data/spec/vcr_cassettes/Ecommerce/Resources_InvoiceOrder_find_when_success_returns_order_object.yml +59 -0
  30. data/spec/vcr_cassettes/Ecommerce/Resources_InvoicePlan_find_all_when_not_found_raises_NotFound.yml +46 -0
  31. data/spec/vcr_cassettes/Ecommerce/Resources_InvoicePlan_find_all_when_success_returns_a_find_all_of_orders.yml +63 -0
  32. data/spec/vcr_cassettes/Ecommerce/Resources_Order_update_when_sending_not_all_required_parameters_raises_error_BarRequ.yml +49 -0
  33. data/spec/vcr_cassettes/Ecommerce/Resources_Order_update_with_success_returns_order_information_on_body.yml +61 -0
  34. metadata +52 -3
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ describe Ecommerce::Resources::AccountOrder do
4
+ describe '.find_all', vcr: true do
5
+ context 'when success' do
6
+ subject { described_class.find_all('e5732007-7989-4372-8e72-9ec8cf6ee046') }
7
+
8
+ it 'returns a find_all of orders' do
9
+ expect(subject.class).to eq(Ecommerce::Resources::OrderCollection)
10
+ expect(subject.orders.first.plan_slug).to eq("rexpense-custom-monthly-brl-5250")
11
+ expect(subject.orders.first.class).to eq(Ecommerce::Resources::Order)
12
+ expect(subject.orders.count).to eq(20)
13
+ end
14
+ end
15
+
16
+ context 'when not found' do
17
+ subject { described_class.find_all('wrong-account-uuid') }
18
+
19
+ it 'raises NotFound' do
20
+ expect{ subject }.to raise_error(Ecommerce::RequestError)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,70 @@
1
+ require "spec_helper"
2
+
3
+ describe Ecommerce::Resources::Collection do
4
+ let(:response) { double(headers: {"Link" => "<http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=3>; rel=next, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=1>; rel=prev, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=3>; rel=last, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=1>; rel=first"},
5
+ body: "[{\"is_paid\": false, \"address_number\": null, \"plan_change_urls\": {}, \"activation_expired\": false, \"number\": 2608, \"address_state\": null, \"global_account\": \"e5732007-7989-4372-8e72-9ec8cf6ee046\", \"api_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/\", \"is_trial\": false, \"document_number\": null, \"checkout_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2608/checkout/\", \"active_until\": null, \"charge_day\": 25, \"address_quarter\": null, \"activated_at\": null, \"is_active\": false, \"user_code\": \"\", \"address\": null, \"is_recurring\": true, \"address_city\": null, \"plan_slug\": \"rexpense-custom-monthly-brl-5250\", \"address_complement\": null, \"discounts_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/discounts/\", \"created_at\": \"2015-03-25 17:54:42\", \"adjustments_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/adjustments/\", \"next_payment_at\": null, \"amount\": \"52.50\", \"client_email\": \"jaime.lannister@mailinator.com\", \"zip_code\": null, \"client_name\": \"\", \"invoices_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/invoices/\"}, {\"is_paid\": false, \"address_number\": null, \"plan_change_urls\": {}, \"activation_expired\": false, \"number\": 2609, \"address_state\": null, \"global_account\": \"e5732007-7989-4372-8e72-9ec8cf6ee046\", \"api_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2609/\", \"is_trial\": false, \"document_number\": null, \"checkout_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2609/checkout/\", \"active_until\": null, \"charge_day\": 25, \"address_quarter\": null, \"activated_at\": null, \"is_active\": false, \"user_code\": \"\", \"address\": null, \"is_recurring\": true, \"address_city\": null, \"plan_slug\": \"rexpense-custom-monthly-brl-5250\", \"address_complement\": null, \"discounts_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2609/discounts/\", \"created_at\": \"2015-03-25 17:55:32\", \"adjustments_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2609/adjustments/\", \"next_payment_at\": null, \"amount\": \"52.50\", \"client_email\": \"jaime.lannister@mailinator.com\", \"zip_code\": null, \"client_name\": \"\", \"invoices_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2609/invoices/\"}, {\"is_paid\": false, \"address_number\": null, \"plan_change_urls\": {}, \"activation_expired\": false, \"number\": 2610, \"address_state\": null, \"global_account\": \"e5732007-7989-4372-8e72-9ec8cf6ee046\", \"api_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2610/\", \"is_trial\": false, \"document_number\": null, \"checkout_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2610/checkout/\", \"active_until\": null, \"charge_day\": 25, \"address_quarter\": null, \"activated_at\": null, \"is_active\": false, \"user_code\": \"\", \"address\": null, \"is_recurring\": true, \"address_city\": null, \"plan_slug\": \"rexpense-custom-monthly-brl-5250\", \"address_complement\": null, \"discounts_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2610/discounts/\", \"created_at\": \"2015-03-25 17:59:15\", \"adjustments_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2610/adjustments/\", \"next_payment_at\": null, \"amount\": \"52.50\", \"client_email\": \"jaime.lannister@mailinator.com\", \"zip_code\": null, \"client_name\": \"\", \"invoices_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2610/invoices/\"}, {\"is_paid\": false, \"address_number\": null, \"plan_change_urls\": {}, \"activation_expired\": false, \"number\": 2611, \"address_state\": null, \"global_account\": \"e5732007-7989-4372-8e72-9ec8cf6ee046\", \"api_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2611/\", \"is_trial\": false, \"document_number\": null, \"checkout_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2611/checkout/\", \"active_until\": null, \"charge_day\": 25, \"address_quarter\": null, \"activated_at\": null, \"is_active\": false, \"user_code\": \"\", \"address\": null, \"is_recurring\": true, \"address_city\": null, \"plan_slug\": \"rexpense-custom-monthly-brl-5250\", \"address_complement\": null, \"discounts_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2611/discounts/\", \"created_at\": \"2015-03-25 18:03:33\", \"adjustments_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2611/adjustments/\", \"next_payment_at\": null, \"amount\": \"52.50\", \"client_email\": \"jaime.lannister@mailinator.com\", \"zip_code\": null, \"client_name\": \"\", \"invoices_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2611/invoices/\"}]") }
6
+
7
+ subject { described_class.new(response) }
8
+
9
+ describe '#build' do
10
+ it 'raises NotImplementedError' do
11
+ expect { subject.build }.to raise_error(NotImplementedError)
12
+ end
13
+ end
14
+
15
+ describe '#next_page' do
16
+ it 'returns next page (3)' do
17
+ expect(subject.next_page).to eq(3)
18
+ end
19
+
20
+ context 'when there is no next page' do
21
+ let(:response) { double(headers: {"Link" => ""}, body: "") }
22
+
23
+ it 'returns nil' do
24
+ expect(subject.next_page).to be_nil
25
+ end
26
+ end
27
+ end
28
+
29
+ describe '#last_page' do
30
+ it 'returns last page (3)' do
31
+ expect(subject.last_page).to eq(3)
32
+ end
33
+
34
+ context 'when there is no last page' do
35
+ let(:response) { double(headers: {"Link" => ""}, body: "") }
36
+
37
+ it 'returns nil' do
38
+ expect(subject.last_page).to be_nil
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '#previous_page' do
44
+ it 'returns previous page (3)' do
45
+ expect(subject.previous_page).to eq(1)
46
+ end
47
+
48
+ context 'when there is no previous page' do
49
+ let(:response) { double(headers: {"Link" => ""}, body: "") }
50
+
51
+ it 'returns nil' do
52
+ expect(subject.previous_page).to be_nil
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#first_page' do
58
+ it 'returns first page (3)' do
59
+ expect(subject.first_page).to eq(1)
60
+ end
61
+
62
+ context 'when there is no first page' do
63
+ let(:response) { double(headers: {"Link" => ""}, body: "") }
64
+
65
+ it 'returns nil' do
66
+ expect(subject.first_page).to be_nil
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ecommerce::Resources::InvoiceOrderCollection do
4
+ let(:response) { double(headers: {"Link" => "<http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=3>; rel=next, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=1>; rel=prev, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=3>; rel=last, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=1>; rel=first"},
5
+ body: "[{\"redeemed_adjustments\":[],\"order_url\":\"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2704/\",\"url\":\"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2704/invoices/2544/\",\"created_at\":\"2015-04-02 15:27:55\",\"activated_at\":\"2015-04-02 15:28:49\",\"number\":2544,\"user_data\":{\"address_city\":\"RJ\",\"address_complement\":\"41\",\"address_number\":\"41\",\"address_quarter\":\"Bla\",\"client_name\":\"Teste\",\"address_state\":\"RJ\",\"client_email\":\"jaime.lannister@mailinator.com\",\"address\":\"Ruasemnumero\",\"document_number\":\"05793832000126\",\"zip_code\":\"20231030\"},\"amount_with_adjustments\":\"52.00\",\"amount\":\"52.00\",\"paid_at\":\"2015-04-02 15:28:45\",\"payment_method\":\"buypage::visa\",\"plan_data\":{\"slug\":\"rexpense-custom-monthly-brl-5250\",\"name\":\"rexpense-custom-monthly-brl-5250\",\"description\":\"Rexpensemonthlyfor5users(10,50BRLeach)\"},\"charge_date\":\"2015-04-02\",\"next_payment_date\":\"2015-05-02\"},{\"redeemed_adjustments\":[],\"order_url\":\"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2704/\",\"url\":\"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2704/invoices/2545/\",\"created_at\":\"2015-04-02 15:28:49\",\"activated_at\":null,\"number\":2545,\"user_data\":{\"address_city\":\"RJ\",\"address_complement\":\"41\",\"address_number\":\"41\",\"address_quarter\":\"Bla\",\"client_name\":\"Teste\",\"address_state\":\"RJ\",\"client_email\":\"jaime.lannister@mailinator.com\",\"address\":\"Ruasemnumero\",\"document_number\":\"05793832000126\",\"zip_code\":\"20231030\"},\"amount_with_adjustments\":\"52.00\",\"amount\":\"52.00\",\"paid_at\":null,\"payment_method\":\"buypage::visa\",\"plan_data\":{\"slug\":\"rexpense-custom-monthly-brl-5250\",\"name\":\"rexpense-custom-monthly-brl-5250\",\"description\":\"Rexpensemonthlyfor5users(10,50BRLeach)\"},\"charge_date\":\"2015-05-02\",\"next_payment_date\":\"2015-06-02\"}]") }
6
+
7
+ subject { described_class.new(response) }
8
+
9
+ describe '#build' do
10
+ it 'returns order collection' do
11
+ expect(subject.build.class).to eq(Ecommerce::Resources::InvoiceOrderCollection)
12
+ end
13
+
14
+ it "returns orders" do
15
+ orders = subject.build.orders
16
+ expect(orders.count).to eq(2)
17
+ expect(orders.first.class).to eq(Ecommerce::Resources::InvoiceOrder)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,54 @@
1
+ require "spec_helper"
2
+
3
+ describe Ecommerce::Resources::InvoiceOrder do
4
+ describe '.find_all', vcr: true do
5
+ context 'when success' do
6
+ subject { described_class.find_all(2704, 'rexpense-custom-monthly-brl-5250') }
7
+
8
+ it 'returns a find_all of orders' do
9
+ expect(subject.class).to eq(Ecommerce::Resources::InvoiceOrderCollection)
10
+ expect(subject.orders.first.class).to eq(Ecommerce::Resources::InvoiceOrder)
11
+ expect(subject.orders.count).to eq(2)
12
+ end
13
+ end
14
+
15
+ context 'when not found' do
16
+ subject { described_class.find_all(2704, 'wrong-slug') }
17
+
18
+ it 'raises NotFound' do
19
+ expect{ subject }.to raise_error(Ecommerce::RequestError)
20
+ end
21
+ end
22
+ end
23
+
24
+ describe '.find', vcr: true do
25
+ context 'when success' do
26
+ subject { described_class.find(2544, 2704, 'rexpense-custom-monthly-brl-5250') }
27
+
28
+ it 'returns order object' do
29
+ expect(subject.redeemed_adjustments).to eq([])
30
+ expect(subject.order_url).to eq('http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2704/')
31
+ expect(subject.url).to eq('http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2704/invoices/2544/')
32
+ expect(subject.created_at).to eq(DateTime.new(2015, 4, 2, 15, 27, 55))
33
+ expect(subject.activated_at).to eq(DateTime.new(2015, 4, 2, 15, 28, 49))
34
+ expect(subject.number).to eq(2544)
35
+ expect(subject.user_data).to eq({"address_city"=>"RJ", "address_complement"=>"41", "address_number"=>"41", "address_quarter"=>"Bla", "client_name"=>"Teste", "address_state"=>"RJ", "client_email"=>"jaime.lannister@mailinator.com", "address"=>"Rua sem numero", "document_number"=>"05793832000126", "zip_code"=>"20231030"})
36
+ expect(subject.amount_with_adjustments).to eq(52.0)
37
+ expect(subject.amount).to eq(52.0)
38
+ expect(subject.paid).to be_nil
39
+ expect(subject.payment_method).to eq('buypage :: visa')
40
+ expect(subject.plan_data).to eq({"slug"=>"rexpense-custom-monthly-brl-5250", "name"=>"rexpense-custom-monthly-brl-5250", "description"=>"Rexpense monthly for 5 users (10,50 BRL each)"})
41
+ expect(subject.charge_date).to eq(Date.new(2015, 4, 2))
42
+ expect(subject.next_payment_date).to eq(Date.new(2015, 5, 2))
43
+ end
44
+ end
45
+
46
+ context 'when not found' do
47
+ subject { described_class.find(2544, 2704, 'wrong-slug') }
48
+
49
+ it 'raises NotFound' do
50
+ expect{ subject }.to raise_error(Ecommerce::RequestError)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ecommerce::Resources::InvoicePlan do
4
+ describe '.find_all', vcr: true do
5
+ context 'when success' do
6
+ subject { described_class.find_all('rexpense-custom-monthly-brl-5250') }
7
+
8
+ it 'returns a find_all of orders' do
9
+ expect(subject.class).to eq(Ecommerce::Resources::InvoiceOrderCollection)
10
+ expect(subject.orders.first.class).to eq(Ecommerce::Resources::InvoiceOrder)
11
+ expect(subject.orders.count).to eq(1)
12
+ end
13
+ end
14
+
15
+ context 'when not found' do
16
+ subject { described_class.find_all(2704, 'wrong-slug') }
17
+
18
+ it 'raises NotFound' do
19
+ expect{ subject }.to raise_error(Ecommerce::RequestError)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,82 +1,20 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Ecommerce::Resources::OrderCollection do
4
- let(:response) { double(headers: {"Link" => "<http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=3>; rel=next, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=1>; rel=prev, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=3>; rel=last, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=1>; rel=first"},
4
+ let(:response) { double(headers: {"Link" => "<http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=3>; rel=next, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=1>; rel=prev, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=3>; rel=last, <http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/?page=1>; rel=first"},
5
5
  body: "[{\"is_paid\": false, \"address_number\": null, \"plan_change_urls\": {}, \"activation_expired\": false, \"number\": 2608, \"address_state\": null, \"global_account\": \"e5732007-7989-4372-8e72-9ec8cf6ee046\", \"api_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/\", \"is_trial\": false, \"document_number\": null, \"checkout_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2608/checkout/\", \"active_until\": null, \"charge_day\": 25, \"address_quarter\": null, \"activated_at\": null, \"is_active\": false, \"user_code\": \"\", \"address\": null, \"is_recurring\": true, \"address_city\": null, \"plan_slug\": \"rexpense-custom-monthly-brl-5250\", \"address_complement\": null, \"discounts_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/discounts/\", \"created_at\": \"2015-03-25 17:54:42\", \"adjustments_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/adjustments/\", \"next_payment_at\": null, \"amount\": \"52.50\", \"client_email\": \"jaime.lannister@mailinator.com\", \"zip_code\": null, \"client_name\": \"\", \"invoices_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/invoices/\"}, {\"is_paid\": false, \"address_number\": null, \"plan_change_urls\": {}, \"activation_expired\": false, \"number\": 2609, \"address_state\": null, \"global_account\": \"e5732007-7989-4372-8e72-9ec8cf6ee046\", \"api_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2609/\", \"is_trial\": false, \"document_number\": null, \"checkout_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2609/checkout/\", \"active_until\": null, \"charge_day\": 25, \"address_quarter\": null, \"activated_at\": null, \"is_active\": false, \"user_code\": \"\", \"address\": null, \"is_recurring\": true, \"address_city\": null, \"plan_slug\": \"rexpense-custom-monthly-brl-5250\", \"address_complement\": null, \"discounts_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2609/discounts/\", \"created_at\": \"2015-03-25 17:55:32\", \"adjustments_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2609/adjustments/\", \"next_payment_at\": null, \"amount\": \"52.50\", \"client_email\": \"jaime.lannister@mailinator.com\", \"zip_code\": null, \"client_name\": \"\", \"invoices_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2609/invoices/\"}, {\"is_paid\": false, \"address_number\": null, \"plan_change_urls\": {}, \"activation_expired\": false, \"number\": 2610, \"address_state\": null, \"global_account\": \"e5732007-7989-4372-8e72-9ec8cf6ee046\", \"api_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2610/\", \"is_trial\": false, \"document_number\": null, \"checkout_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2610/checkout/\", \"active_until\": null, \"charge_day\": 25, \"address_quarter\": null, \"activated_at\": null, \"is_active\": false, \"user_code\": \"\", \"address\": null, \"is_recurring\": true, \"address_city\": null, \"plan_slug\": \"rexpense-custom-monthly-brl-5250\", \"address_complement\": null, \"discounts_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2610/discounts/\", \"created_at\": \"2015-03-25 17:59:15\", \"adjustments_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2610/adjustments/\", \"next_payment_at\": null, \"amount\": \"52.50\", \"client_email\": \"jaime.lannister@mailinator.com\", \"zip_code\": null, \"client_name\": \"\", \"invoices_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2610/invoices/\"}, {\"is_paid\": false, \"address_number\": null, \"plan_change_urls\": {}, \"activation_expired\": false, \"number\": 2611, \"address_state\": null, \"global_account\": \"e5732007-7989-4372-8e72-9ec8cf6ee046\", \"api_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2611/\", \"is_trial\": false, \"document_number\": null, \"checkout_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2611/checkout/\", \"active_until\": null, \"charge_day\": 25, \"address_quarter\": null, \"activated_at\": null, \"is_active\": false, \"user_code\": \"\", \"address\": null, \"is_recurring\": true, \"address_city\": null, \"plan_slug\": \"rexpense-custom-monthly-brl-5250\", \"address_complement\": null, \"discounts_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2611/discounts/\", \"created_at\": \"2015-03-25 18:03:33\", \"adjustments_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2611/adjustments/\", \"next_payment_at\": null, \"amount\": \"52.50\", \"client_email\": \"jaime.lannister@mailinator.com\", \"zip_code\": null, \"client_name\": \"\", \"invoices_url\": \"http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2611/invoices/\"}]") }
6
6
 
7
7
  subject { described_class.new(response) }
8
8
 
9
9
  describe '#build' do
10
- it 'builds orders' do
11
- expect(subject).to receive(:build_orders)
12
- subject.build
13
- end
14
-
15
- it 'returns Ecommerce::Resources::OrderCollection object' do
10
+ it 'returns order collection' do
16
11
  expect(subject.build.class).to eq(Ecommerce::Resources::OrderCollection)
17
12
  end
18
- end
19
-
20
- describe '#build_orders' do
21
- it 'builds an array of Ecommerce::Resources::Order' do
22
- expect(Ecommerce::Resources::Order).to receive(:new).exactly(4).times
23
- subject.build
24
- end
25
- end
26
-
27
- describe '#next_page' do
28
- it 'returns next page (3)' do
29
- expect(subject.next_page).to eq(3)
30
- end
31
-
32
- context 'when there is no next page' do
33
- let(:response) { double(headers: {"Link" => ""}, body: "") }
34
-
35
- it 'returns nil' do
36
- expect(subject.next_page).to be_nil
37
- end
38
- end
39
- end
40
-
41
- describe '#last_page' do
42
- it 'returns last page (3)' do
43
- expect(subject.last_page).to eq(3)
44
- end
45
-
46
- context 'when there is no last page' do
47
- let(:response) { double(headers: {"Link" => ""}, body: "") }
48
-
49
- it 'returns nil' do
50
- expect(subject.last_page).to be_nil
51
- end
52
- end
53
- end
54
-
55
- describe '#previous_page' do
56
- it 'returns previous page (3)' do
57
- expect(subject.previous_page).to eq(1)
58
- end
59
-
60
- context 'when there is no previous page' do
61
- let(:response) { double(headers: {"Link" => ""}, body: "") }
62
-
63
- it 'returns nil' do
64
- expect(subject.previous_page).to be_nil
65
- end
66
- end
67
- end
68
-
69
- describe '#first_page' do
70
- it 'returns first page (3)' do
71
- expect(subject.first_page).to eq(1)
72
- end
73
-
74
- context 'when there is no first page' do
75
- let(:response) { double(headers: {"Link" => ""}, body: "") }
76
13
 
77
- it 'returns nil' do
78
- expect(subject.first_page).to be_nil
79
- end
14
+ it "returns orders" do
15
+ orders = subject.build.orders
16
+ expect(orders.count).to eq(4)
17
+ expect(orders.first.class).to eq(Ecommerce::Resources::Order)
80
18
  end
81
19
  end
82
20
  end
@@ -144,12 +144,53 @@ describe Ecommerce::Resources::Order do
144
144
  end
145
145
  end
146
146
 
147
- describe '#destroy' do
148
- subject { described_class.new({ number: 2609, plan_slug: 'rexpense-custom-monthly-brl-5250' }) }
147
+ describe '.update', vcr: true do
148
+ let(:params) { { document_number: "976.305.273-49", identity: "8923199e-6c43-415a-bbd1-2e302fdf8d96", client_email: "jaime.lannister@mailinator.com", client_name: "Jaime Lannister KingSlayer" } }
149
149
 
150
- it 'invokes Ecommerce::Resources::Order.destroy' do
151
- expect(Ecommerce::Resources::Order).to receive(:destroy).with(2609, 'rexpense-custom-monthly-brl-5250')
152
- subject.destroy
150
+ subject { described_class.update(2608, "rexpense-custom-monthly-brl-5250", params) }
151
+
152
+ context 'with success' do
153
+ it 'returns order information on body' do
154
+ expect(subject.is_paid).to be_falsy
155
+ expect(subject.address_number).to be_nil
156
+ expect(subject.plan_change_urls).to eq({"rexpense-beta"=>"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2608/change/rexpense-beta/"})
157
+ expect(subject.activation_expired).to be_falsy
158
+ expect(subject.number).to eq(2608)
159
+ expect(subject.address_state).to eq('')
160
+ expect(subject.global_account).to eq('e5732007-7989-4372-8e72-9ec8cf6ee046')
161
+ expect(subject.api_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/")
162
+ expect(subject.is_trial).to be_falsy
163
+ expect(subject.document_number).to eq("97630527349")
164
+ expect(subject.checkout_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2608/checkout/")
165
+ expect(subject.active_until).to be_nil
166
+ expect(subject.charge_day).to eq(25)
167
+ expect(subject.address_quarter).to be_nil
168
+ expect(subject.activated_at).to be_nil
169
+ expect(subject.is_active).to be_falsy
170
+ expect(subject.user_code).to be_empty
171
+ expect(subject.address).to be_nil
172
+ expect(subject.is_recurring).to be_truthy
173
+ expect(subject.address_city).to be_nil
174
+ expect(subject.plan_slug).to eq("rexpense-custom-monthly-brl-5250")
175
+ expect(subject.address_complement).to eq('')
176
+ expect(subject.discounts_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/discounts/")
177
+ expect(subject.created_at).to eq(DateTime.new(2015, 3, 25, 17, 54, 42))
178
+ expect(subject.adjustments_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/adjustments/")
179
+ expect(subject.next_payment_at).to be_nil
180
+ expect(subject.amount).to eq(52.5)
181
+ expect(subject.client_email).to eq("jaime.lannister@mailinator.com")
182
+ expect(subject.zip_code).to be_nil
183
+ expect(subject.client_name).to eq("Jaime Lannister KingSlayer")
184
+ expect(subject.invoices_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/invoices/")
185
+ end
186
+ end
187
+
188
+ context 'when sending not all required parameters' do
189
+ before { params.delete(:document_number) }
190
+
191
+ it 'raises error BarRequest' do
192
+ expect{ subject }.to raise_error(Ecommerce::RequestError)
193
+ end
153
194
  end
154
195
  end
155
196
  end
@@ -1,3 +1,6 @@
1
+ require 'codeclimate-test-reporter'
2
+ CodeClimate::TestReporter.start
3
+
1
4
  require "ecommerce"
2
5
  require "pry"
3
6
  require "vcr"
@@ -0,0 +1,219 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://sandbox.ecommerce.myfreecomm.com.br/api/accounts/wrong-account-uuid/orders/
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"page":1,"limit":20}'
9
+ headers:
10
+ User-Agent:
11
+ - Ecommerce Ruby Client v0.0.2
12
+ Accept:
13
+ - application/json
14
+ Content-Type:
15
+ - application/json
16
+ Authorization:
17
+ - Basic cDlhWXNSU0l2TTo0MWUxMzc2OGI0N2Q1NTM0MTdiNDQxYjg2M2Jh
18
+ response:
19
+ status:
20
+ code: 404
21
+ message: NOT FOUND
22
+ headers:
23
+ Content-Encoding:
24
+ - gzip
25
+ Content-Language:
26
+ - pt-br
27
+ Content-Type:
28
+ - text/html; charset=iso-8859-1
29
+ Date:
30
+ - Tue, 31 Mar 2015 21:40:31 GMT
31
+ Server:
32
+ - nginx/1.6.2
33
+ Vary:
34
+ - Accept-Language, Cookie
35
+ transfer-encoding:
36
+ - chunked
37
+ Connection:
38
+ - keep-alive
39
+ body:
40
+ encoding: ASCII-8BIT
41
+ string: !binary |-
42
+ PCFET0NUWVBFIGh0bWw+CgoKCgo8IS0tIHBhdWxpcmlzaC5jb20vMjAwOC9j
43
+ b25kaXRpb25hbC1zdHlsZXNoZWV0cy12cy1jc3MtaGFja3MtYW5zd2VyLW5l
44
+ aXRoZXIvIC0tPgo8IS0tW2lmIGx0IElFIDddPiA8aHRtbCBjbGFzcz0ibm8t
45
+ anMgbHQtaWU5IGx0LWllOCBsdC1pZTciIGxhbmc9ImVuIj4gPCFbZW5kaWZd
46
+ LS0+CjwhLS1baWYgSUUgN10+ICAgIDxodG1sIGNsYXNzPSJuby1qcyBsdC1p
47
+ ZTkgbHQtaWU4IiBsYW5nPSJlbiI+IDwhW2VuZGlmXS0tPgo8IS0tW2lmIElF
48
+ IDhdPiAgICA8aHRtbCBjbGFzcz0ibm8tanMgbHQtaWU5IiBsYW5nPSJlbiI+
49
+ IDwhW2VuZGlmXS0tPgo8IS0tW2lmIGd0IElFIDhdPjwhLS0+IDxodG1sIGNs
50
+ YXNzPSJuby1qcyIgbGFuZz0iZW4iPiA8IS0tPCFbZW5kaWZdLS0+CjxoZWFk
51
+ PgogICAgPG1ldGEgY2hhcnNldD0idXRmLTgiIC8+CgogICAgPCEtLSBTZXQg
52
+ dGhlIHZpZXdwb3J0IHdpZHRoIHRvIGRldmljZSB3aWR0aCBmb3IgbW9iaWxl
53
+ IC0tPgogICAgPG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRo
54
+ PWRldmljZS13aWR0aCIgLz4KICAgIDxtZXRhIG5hbWU9ImF1dGhvciIgY29u
55
+ dGVudD0iTXlmcmVlY29tbSIgLz4KICAgIDxtZXRhIG5hbWU9InJvYm90cyIg
56
+ Y29udGVudD0ibm9mb2xsb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V3ZWIuY29tLmJyL2Fj
106
+ Y291bnRzL2xvZ291dC8/bmV4dD1odHRwOi8vc2FuZGJveC5lY29tbWVyY2Uu
107
+ bXlmcmVlY29tbS5jb20uYnIvYXV0aC9sb2dvdXQvJnB1c2hfaXQ9dHJ1ZSI+
108
+ PC9zY3JpcHQ+CgoKICAgIAogICAgICAgIAogICAgCgogICAgPGRpdiBjbGFz
109
+ cz0icm93Ij4KICAgICAgICA8ZGl2IGlkPSJjb250ZW50IiBjbGFzcz0idHdl
110
+ bHZlIGNvbHVtbnMiPgogICAgICAgICAgICA8ZGl2IGNsYXNzPSJyb3ciPgog
111
+ ICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0idHdlbHZlIGNvbHVtbnMgbWFp
112
+ biI+CiAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icm93Ij4KICAg
113
+ ICAgICAgICAgICAgICAgICAgICAgCjxkaXYgY2xhc3M9InR3ZWx2ZSBtb2Jp
114
+ bGUtZm91ciBjb2x1bW5zIj4KICAgIDxoNT5Q4WdpbmEgbuNvIGVuY29udHJh
115
+ ZGE8L2g1PgogICAgPHA+CiAgICAgICAgRGVzY3VscGUsIG1hcyBhIHDhZ2lu
116
+ YSBxdWUgdm9j6iBlc3ThIHRlbnRhbmRvIGFjZXNzYXIgbuNvIGV4aXN0ZS48
117
+ YnIvPgogICAgICAgIFBvciBmYXZvciwgdmVyaWZpcXVlIG8gZW5kZXJl528g
118
+ aW5mb3JtYWRvIGUgdGVudGUgbm92YW1lbnRlLgogICAgPC9wPgo8L2Rpdj4K
119
+ CiAgICAgICAgICAgICAgICAgICAgPC9kaXY+CgoKICAgICAgICAgICAgICAg
120
+ ICAgICAKICAgICAgICAgICAgICAgICAgICA8ZGl2IGlkPSJzZWN1cml0eS1t
121
+ ZXNzYWdlIiBjbGFzcz0icm93IGhpZGUtZm9yLXNtYWxsIj4KICAgICAgICAg
122
+ ICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0idHdlbHZ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lKGdhLCBzKTsKICAgICAgfSkoKTsKICAgIDwvc2NyaXB0PjwhLS0gR29v
157
+ Z2xlIEFuYWx5dGljcyAtLT4KCiAgICAKICAgICAgICA8c2NyaXB0IHR5cGU9
158
+ InRleHQvamF2YXNjcmlwdCIgY2hhcnNldD0idXRmLTgiPgogICAgICAgICAg
159
+ ICBmdW5jdGlvbiB1cGRhdGVfY29udGVudF9wYWRkaW5nKCkgewogICAgICAg
160
+ ICAgICAgICAgLy8gUGFkZGluZyBkaW7ibWljbyBwYXJhIG8gY29udGX6ZG8g
161
+ ZGUgYWNvcmRvIGNvbSBhIGFsdHVyYSBkbyB0aXR1bG8KICAgICAgICAgICAg
162
+ ICAgIGlmICgkKCcuY29udGVudC10aXRsZS1mdWxsJykubGVuZ3RoID4gMCkg
163
+ ewogICAgICAgICAgICAgICAgICAgIHRpdGxlX2hlaWdodCA9ICQoJy5jb250
164
+ ZW50LXRpdGxlLWZ1bGwnKS5oZWlnaHQoKTsKICAgICAgICAgICAgICAgICAg
165
+ ICAkKCcuY29udGVudC10aXRsZS1mdWxsICsgZGl2JykuY3NzKCdwYWRkaW5n
166
+ LXRvcCcsIHRpdGxlX2hlaWdodCArIDI1ICsgJ3B4Jyk7CiAgICAgICAgICAg
167
+ ICAgICB9CiAgICAgICAgICAgIH07CgogICAgICAgICAgICAkKGRvY3VtZW50
168
+ KS5yZWFkeShmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHVwZGF0ZV9j
169
+ b250ZW50X3BhZGRpbmcoKTsKICAgICAgICAgICAgICAgICQoJy5hdXRvZm9j
170
+ dXMnKS5mb2N1cygpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgJCh3
171
+ aW5kb3cpLnJlc2l6ZShmdW5jdGlvbigpewogICAgICAgICAgICAgICAgdXBk
172
+ YXRlX2NvbnRlbnRfcGFkZGluZygpOwogICAgICAgICAgICB9KTsKCiAgICAg
173
+ ICAgICAgIChmdW5jdGlvbigkLCB3aW5kb3csIHVuZGVmaW5lZCkgewogICAg
174
+ ICAgICAgICAgICAgJ3VzZSBzdHJpY3QnOwogICAgICAgICAgICAgICAgJC5m
175
+ bi5mb3VuZGF0aW9uQWNjb3JkaW9uID0gZnVuY3Rpb24ob3B0aW9ucykgewog
176
+ ICAgICAgICAgICAgICAgICAgIHZhciBoYXNIb3ZlciA9IGZ1bmN0aW9uKGFj
177
+ Y29yZGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJu
178
+ IGFjY29yZGlvbi5oYXNDbGFzcygnaG92ZXInKSAmJiAhTW9kZXJuaXpyLnRv
179
+ dWNoCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAg
180
+ ICAgICAgJChkb2N1bWVudCkub24oJ21vdXNlZW50ZXInLCAnLmFjY29yZGlv
181
+ biBsaScsIGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2
182
+ YXIgcCA9ICQodGhpcykucGFyZW50KCk7CiAgICAgICAgICAgICAgICAgICAg
183
+ ICAgIGlmIChoYXNIb3ZlcihwKSkgewogICAgICAgICAgICAgICAgICAgICAg
184
+ ICAgICAgdmFyIGZseW91dCA9ICQodGhpcykuY2hpbGRyZW4oJy5jb250ZW50
185
+ JykuZmlyc3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJy5j
186
+ b250ZW50JywgcCkubm90KGZseW91dCkuaGlkZSgpLnBhcmVudCgnbGknKS5y
187
+ ZW1vdmVDbGFzcygnYWN0aXZlJyk7CiAgICAgICAgICAgICAgICAgICAgICAg
188
+ ICAgICBmbHlvdXQuc2hvdygwLCBmdW5jdGlvbigpIHsKICAgICAgICAgICAg
189
+ ICAgICAgICAgICAgICAgICAgICBmbHlvdXQucGFyZW50KCdsaScpLmFkZENs
190
+ YXNzKCdhY3RpdmUnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0p
191
+ OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAg
192
+ ICAgfSk7CiAgICAgICAgICAgICAgICAgICAgJChkb2N1bWVudCkub24oJ2Ns
193
+ aWNrLmZuZHRuJywgJy5hY2NvcmRpb24gbGkgLnRpdGxlJywgZnVuY3Rpb24o
194
+ KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBsaSA9ICQodGhpcyku
195
+ Y2xvc2VzdCgnbGknKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAg
196
+ PSBsaS5wYXJlbnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFo
197
+ YXNIb3ZlcihwKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFy
198
+ IGZseW91dCA9IGxpLmNoaWxkcmVuKCcuY29udGVudCcpLmZpcnN0KCk7CiAg
199
+ ICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGkuaGFzQ2xhc3MoJ2Fj
200
+ dGl2ZScpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcC5m
201
+ aW5kKCdsaScpLnJlbW92ZUNsYXNzKCdhY3RpdmUnKS5lbmQoKS5maW5kKCcu
202
+ Y29udGVudCcpLmhpZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAg
203
+ IH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAg
204
+ ICAgICAgICAgICAgICAgICAgICAgICAgICQoJy5jb250ZW50JywgcCkubm90
205
+ KGZseW91dCkuaGlkZSgpLnBhcmVudCgnbGknKS5yZW1vdmVDbGFzcygnYWN0
206
+ aXZlJyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmx5b3V0
207
+ LnNob3coMCwgZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAgICAgICAg
208
+ ICAgICAgICAgICAgIGZseW91dC5wYXJlbnQoJ2xpJykuYWRkQ2xhc3MoJ2Fj
209
+ dGl2ZScpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwog
210
+ ICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAg
211
+ ICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAg
212
+ ICAgICB9OwogICAgICAgICAgICB9KShqUXVlcnksIHRoaXMpOwogICAgICAg
213
+ IDwvc2NyaXB0PgogICAgCgogICAgCiAgICAgICAgCiAgICAKCjwvYm9keT4K
214
+ PC9odG1sPgo=
215
+ http_version: '1.1'
216
+ adapter_metadata:
217
+ effective_url: http://sandbox.ecommerce.myfreecomm.com.br/api/accounts/wrong-account-uuid/orders/
218
+ recorded_at: Tue, 31 Mar 2015 21:40:33 GMT
219
+ recorded_with: VCR 2.9.3