xpost 0.1.4 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.DS_Store +0 -0
- data/.gitignore +1 -2
- data/.rspec +0 -0
- data/Gemfile +0 -0
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/TODO.md +1 -28
- data/lib/xpost.rb +6 -8
- data/lib/xpost/authentication.rb +0 -5
- data/lib/xpost/configuration.rb +0 -15
- data/lib/xpost/models.rb +5 -0
- data/lib/xpost/models/address.rb +38 -0
- data/lib/xpost/models/item.rb +31 -0
- data/lib/xpost/models/order.rb +54 -0
- data/lib/xpost/orders.rb +16 -57
- data/lib/xpost/version.rb +1 -1
- data/spec/{order/address/address_spec.rb → address_spec.rb} +0 -0
- data/spec/factories/addresses.rb +28 -46
- data/spec/factories/items.rb +10 -10
- data/spec/factories/orders.rb +16 -39
- data/spec/helpers.rb +0 -0
- data/spec/{order/items/item_spec.rb → item_spec.rb} +5 -5
- data/spec/line_item_spec.rb +16 -0
- data/spec/orders/order_create_spec.rb +46 -0
- data/spec/orders/order_for_pickup_spec.rb +17 -0
- data/spec/orders/{find_spec.rb → orders_find_spec.rb} +2 -3
- data/spec/orders/{track_spec.rb → orders_track_spec.rb} +2 -2
- data/spec/spec_helper.rb +0 -1
- data/spec/xpost_spec.rb +0 -27
- data/xpost.gemspec +2 -6
- metadata +17 -68
- data/lib/.DS_Store +0 -0
- data/lib/xpost/.DS_Store +0 -0
- data/lib/xpost/address.rb +0 -77
- data/lib/xpost/item.rb +0 -44
- data/lib/xpost/order.rb +0 -135
- data/lib/xpost/statuses.rb +0 -29
- data/sample/sample_essential_order_details.json +0 -63
- data/sample/sample_xpost_order-confirmed.json +0 -317
- data/sample/sample_xpost_order-for-pickup.json +0 -379
- data/sample/sample_xpost_order-pending.json +0 -306
- data/sample/webhook_sample.json +0 -105
- data/spec/order/cancel_spec.rb +0 -37
- data/spec/order/confirm_spec.rb +0 -38
- data/spec/order/create_spec.rb +0 -97
- data/spec/order/for_pickup_spec.rb +0 -42
- data/spec/order/get_shipping_label_spec.rb +0 -60
- data/spec/order/order_spec.rb +0 -96
data/sample/webhook_sample.json
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"event": "status_update",
|
3
|
-
"timestamp": 1512551041,
|
4
|
-
"data": [
|
5
|
-
{
|
6
|
-
"event_id": 35862967,
|
7
|
-
"tracking_number": "0495-0754-VZXJ",
|
8
|
-
"reference_id": "17120514285DPEK.42ecdce0-d185-4356-a30f-d33ea14cff05",
|
9
|
-
"created_at": "2017-12-06 16:41:31.898782+08",
|
10
|
-
"status_updated_at": "2017-12-06 16:41:21+08",
|
11
|
-
"status": "picked_up",
|
12
|
-
"remarks": "Package successfully picked up",
|
13
|
-
"fees": {
|
14
|
-
"shipping_fee": 100,
|
15
|
-
"insurance_fee": 9,
|
16
|
-
"transaction_fee": 27
|
17
|
-
},
|
18
|
-
"party": {
|
19
|
-
"id": 6,
|
20
|
-
"external_id": null
|
21
|
-
},
|
22
|
-
"parent": {
|
23
|
-
"id": null,
|
24
|
-
"tracking_number": null,
|
25
|
-
"reference_id": null
|
26
|
-
}
|
27
|
-
},
|
28
|
-
{
|
29
|
-
"event_id": 35862969,
|
30
|
-
"tracking_number": "0476-8835-FHUL",
|
31
|
-
"reference_id": "17120110305AQXW.db11da3c-15f9-4a79-a605-2aa59600790f",
|
32
|
-
"created_at": "2017-12-06 16:41:31.939001+08",
|
33
|
-
"status_updated_at": "2017-12-06 16:04:06+08",
|
34
|
-
"status": "in_transit",
|
35
|
-
"remarks": "FORWARDED TO PUERTO PRINCESA DELIVERY HUB",
|
36
|
-
"fees": {
|
37
|
-
"shipping_fee": 100,
|
38
|
-
"insurance_fee": 5,
|
39
|
-
"transaction_fee": 20
|
40
|
-
},
|
41
|
-
"party": {
|
42
|
-
"id": 6,
|
43
|
-
"external_id": null
|
44
|
-
},
|
45
|
-
"parent": {
|
46
|
-
"id": null,
|
47
|
-
"tracking_number": null,
|
48
|
-
"reference_id": null
|
49
|
-
}
|
50
|
-
},
|
51
|
-
{
|
52
|
-
"event_id": 35862972,
|
53
|
-
"tracking_number": "0479-8119-CWAX",
|
54
|
-
"reference_id": "17120109493993N.88b7c455-cf29-404c-a91f-a398278ad1fd",
|
55
|
-
"created_at": "2017-12-06 16:41:32.475252+08",
|
56
|
-
"status_updated_at": "2017-12-06 16:20:19+08",
|
57
|
-
"status": "in_transit",
|
58
|
-
"remarks": "RECEIVED AT SOUTH LUZON AREA",
|
59
|
-
"fees": {
|
60
|
-
"shipping_fee": 100,
|
61
|
-
"insurance_fee": 6.1,
|
62
|
-
"transaction_fee": 20
|
63
|
-
},
|
64
|
-
"party": {
|
65
|
-
"id": 6,
|
66
|
-
"external_id": null
|
67
|
-
},
|
68
|
-
"parent": {
|
69
|
-
"id": null,
|
70
|
-
"tracking_number": null,
|
71
|
-
"reference_id": null
|
72
|
-
}
|
73
|
-
},
|
74
|
-
{
|
75
|
-
"event_id": 35862977,
|
76
|
-
"tracking_number": "0481-9668-HAJN",
|
77
|
-
"reference_id": "17120113387HYRH.3623ee76-ee52-44a0-b890-f2bdc661078e",
|
78
|
-
"created_at": "2017-12-06 16:41:33.064148+08",
|
79
|
-
"status_updated_at": "2017-12-06 16:37:43+08",
|
80
|
-
"status": "in_transit",
|
81
|
-
"remarks": "RECEIVED AT SOUTH LUZON AREA",
|
82
|
-
"fees": {
|
83
|
-
"shipping_fee": 100,
|
84
|
-
"insurance_fee": 5.52,
|
85
|
-
"transaction_fee": 20
|
86
|
-
},
|
87
|
-
"party": {
|
88
|
-
"id": 6,
|
89
|
-
"external_id": null
|
90
|
-
},
|
91
|
-
"parent": {
|
92
|
-
"id": null,
|
93
|
-
"tracking_number": null,
|
94
|
-
"reference_id": null
|
95
|
-
}
|
96
|
-
},
|
97
|
-
{
|
98
|
-
"event_id": 35862981,
|
99
|
-
"tracking_number": "0492-6744-JFQD",
|
100
|
-
"reference_id": "17120411264R1YD.8b95ac0c-4466-4053-bd03-ce1c9723b8fc",
|
101
|
-
"created_at": "2017-12-06 16:41:33.193278+08",
|
102
|
-
"status_updated_at": "2017-12-06 16:41:22+08",
|
103
|
-
...
|
104
|
-
}]
|
105
|
-
}
|
data/spec/order/cancel_spec.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe "@order.cancel" do
|
4
|
-
before do
|
5
|
-
Xpost.configure do |config|
|
6
|
-
config.api_key = ENV['XPOST_STAGING_API_KEY']
|
7
|
-
config.secret_key = ENV['XPOST_STAGING_SECRET_KEY']
|
8
|
-
config.staging_url = "https://api.staging.lbcx.ph/v1"
|
9
|
-
config.production_url = "https://api.staging.lbcx.ph/v1"
|
10
|
-
end
|
11
|
-
|
12
|
-
@auth_token = Xpost::Authentication.authenticate(Xpost.configuration.api_key, Xpost.configuration.secret_key)
|
13
|
-
@order = build(:order)
|
14
|
-
@order_data = Xpost::Orders.create(@auth_token, @order, "small-pouch")
|
15
|
-
@tracking_number = @order_data[:tracking_number]
|
16
|
-
@order = Xpost::Orders.find(@auth_token, @tracking_number)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'makes sure the order exists' do
|
20
|
-
expect(Xpost::Orders.exists?(@auth_token, @tracking_number)).to eq true
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'cancels a pending order' do
|
24
|
-
res = Xpost::Orders.cancel(@auth_token, @tracking_number)
|
25
|
-
|
26
|
-
expect(res[:tracking_number]).to eq @tracking_number
|
27
|
-
expect(res[:old_status]).to eq "pending"
|
28
|
-
expect(res[:new_status]).to eq "canceled"
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'doesnt accept non-pending orders' do
|
32
|
-
res = Xpost::Orders.confirm(@auth_token, @tracking_number)
|
33
|
-
expect(res[:new_status]).to eq "confirmed"
|
34
|
-
|
35
|
-
expect { Xpost::Orders.cancel(@auth_token, @tracking_number) }.to raise_error "Order isn't pending"
|
36
|
-
end
|
37
|
-
end
|
data/spec/order/confirm_spec.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe "@order.confirm" do
|
4
|
-
before do
|
5
|
-
Xpost.configure do |config|
|
6
|
-
config.api_key = ENV['XPOST_STAGING_API_KEY']
|
7
|
-
config.secret_key = ENV['XPOST_STAGING_SECRET_KEY']
|
8
|
-
config.staging_url = "https://api.staging.lbcx.ph/v1"
|
9
|
-
config.production_url = "https://api.staging.lbcx.ph/v1"
|
10
|
-
end
|
11
|
-
|
12
|
-
@auth_token = Xpost::Authentication.authenticate(Xpost.configuration.api_key, Xpost.configuration.secret_key)
|
13
|
-
@order = build(:order)
|
14
|
-
@order_data = Xpost::Orders.create(@auth_token, @order, "small-pouch")
|
15
|
-
@tracking_number = @order_data[:tracking_number]
|
16
|
-
@order = Xpost::Orders.find(@auth_token, @tracking_number)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'makes sure the order exists' do
|
20
|
-
expect(Xpost::Orders.exists?(@auth_token, @tracking_number)).to eq true
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'confirms pending orders' do
|
24
|
-
res = Xpost::Orders.confirm(@auth_token, @tracking_number)
|
25
|
-
|
26
|
-
expect(res[:tracking_number]).to eq @tracking_number
|
27
|
-
expect(res[:old_status]).to eq "pending"
|
28
|
-
expect(res[:new_status]).to eq "confirmed"
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'doesnt accept non-pending orders' do
|
32
|
-
expect(@order[:status]).to eq "pending"
|
33
|
-
|
34
|
-
Xpost::Orders.confirm(@auth_token, @tracking_number)
|
35
|
-
|
36
|
-
expect { Xpost::Orders.confirm(@auth_token, @tracking_number) }.to raise_error "Order isn't pending"
|
37
|
-
end
|
38
|
-
end
|
data/spec/order/create_spec.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'faker'
|
4
|
-
|
5
|
-
RSpec.describe "Xpost::Order.create" do
|
6
|
-
|
7
|
-
describe 'validations' do
|
8
|
-
before(:each) do
|
9
|
-
@order = Xpost::Order.new(
|
10
|
-
email: "john@me.com",
|
11
|
-
buyer_name: "John Doe",
|
12
|
-
contact_number: "+639171234567"
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'is invalid without a delivery address, payment method, and items' do
|
17
|
-
expect(@order.valid?).to be false
|
18
|
-
expect(@order.has_delivery_address?).to eq false
|
19
|
-
expect(@order.has_payment_method?).to eq false
|
20
|
-
expect(@order.has_items?).to eq false
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'requires a delivery address' do
|
24
|
-
expect(@order.has_delivery_address?).to eq false
|
25
|
-
|
26
|
-
delivery_address = build(:required_address)
|
27
|
-
@order.delivery_address = delivery_address
|
28
|
-
|
29
|
-
expect(@order.has_delivery_address?).to eq true
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'requires a payment method' do
|
33
|
-
expect(@order.has_payment_method?).to eq false
|
34
|
-
|
35
|
-
@order.payment_method = "cod"
|
36
|
-
@order.payment_provider = "lbcx"
|
37
|
-
@order.total = 1000
|
38
|
-
@order.currency = "PHP"
|
39
|
-
|
40
|
-
expect(@order.has_payment_method?).to eq true
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'requires at least one item' do
|
44
|
-
expect(@order.has_items?).to eq false
|
45
|
-
|
46
|
-
item = build(:product_item)
|
47
|
-
@order.add_item(item)
|
48
|
-
|
49
|
-
expect(@order.has_items?).to eq true
|
50
|
-
expect(@order.items.count).to eq 1
|
51
|
-
expect(@order.items.first.description).to eq "orange shirt"
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'is valid with a delivery address, payment method, and items' do
|
55
|
-
@order.payment_method = "cod"
|
56
|
-
@order.payment_provider = "lbcx"
|
57
|
-
@order.total = 1000
|
58
|
-
@order.currency = "PHP"
|
59
|
-
|
60
|
-
delivery_address = build(:required_address)
|
61
|
-
@order.delivery_address = delivery_address
|
62
|
-
|
63
|
-
item = build(:product_item)
|
64
|
-
@order.add_item(item)
|
65
|
-
|
66
|
-
expect(@order.confirmable?).to eq true
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe 'creation' do
|
71
|
-
before(:each) do
|
72
|
-
Xpost.configure do |config|
|
73
|
-
config.api_key = ENV['XPOST_STAGING_API_KEY']
|
74
|
-
config.secret_key = ENV['XPOST_STAGING_SECRET_KEY']
|
75
|
-
config.staging_url = "https://api.staging.lbcx.ph/v1"
|
76
|
-
config.production_url = "https://api.staging.lbcx.ph/v1"
|
77
|
-
end
|
78
|
-
@auth_token = Xpost::Authentication.authenticate(Xpost.configuration.api_key, Xpost.configuration.secret_key)
|
79
|
-
@order = build(:order)
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'expects a valid order' do
|
83
|
-
expect(@order.valid?).to be true
|
84
|
-
end
|
85
|
-
|
86
|
-
# TODO: No time to debug but works in console
|
87
|
-
# it 'creates an order' do
|
88
|
-
# order = Xpost::Orders.create(@auth_token, @order, "big-pouch", "xpost-specs-#{Faker::Number.number(10)}")
|
89
|
-
|
90
|
-
# expect(order).to eq 1000
|
91
|
-
# expect(order[:total]).to eq 1000
|
92
|
-
# expect(order[:shipment]).to eq "big-pouch"
|
93
|
-
# expect(order[:status]).to eq "pending"
|
94
|
-
# expect(order[:tracking_number]).to_not be nil
|
95
|
-
# end
|
96
|
-
end
|
97
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe "@order.for_pickup" do
|
4
|
-
before do
|
5
|
-
Xpost.configure do |config|
|
6
|
-
config.api_key = ENV['XPOST_STAGING_API_KEY']
|
7
|
-
config.secret_key = ENV['XPOST_STAGING_SECRET_KEY']
|
8
|
-
config.staging_url = "https://api.staging.lbcx.ph/v1"
|
9
|
-
config.production_url = "https://api.staging.lbcx.ph/v1"
|
10
|
-
end
|
11
|
-
|
12
|
-
@auth_token = Xpost::Authentication.authenticate(Xpost.configuration.api_key, Xpost.configuration.secret_key)
|
13
|
-
@order = build(:order)
|
14
|
-
@order_data = Xpost::Orders.create(@auth_token, @order, "small-pouch")
|
15
|
-
@tracking_number = @order_data[:tracking_number]
|
16
|
-
@order = Xpost::Orders.find(@auth_token, @tracking_number)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'already has a delivery address' do
|
20
|
-
expect(@order[:delivery_address]).to be_present
|
21
|
-
expect(@order[:delivery_address][:name]).to eq "Bobby Axelrod"
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'requires a pickup address' do
|
25
|
-
Xpost::Orders.confirm(@auth_token, @tracking_number)
|
26
|
-
pickup_address = nil
|
27
|
-
|
28
|
-
expect{ Xpost::Orders.for_pickup(@auth_token, @tracking_number, pickup_address) }.to raise_error "Missing pickup address"
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'only allows confirmed orders' do
|
32
|
-
expect{ Xpost::Orders.for_pickup(@auth_token, @tracking_number, nil) }.to raise_error "Order isn't confirmed"
|
33
|
-
|
34
|
-
order = Xpost::Orders.confirm(@auth_token, @tracking_number)
|
35
|
-
expect(order[:new_status]).to eq "confirmed"
|
36
|
-
|
37
|
-
pickup_address = build(:complete_address_pickup)
|
38
|
-
order = Xpost::Orders.for_pickup(@auth_token, @tracking_number, pickup_address)
|
39
|
-
|
40
|
-
expect(order[:new_status]).to eq "for_pickup"
|
41
|
-
end
|
42
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe "@order.get_shipping_labels" do
|
4
|
-
before do
|
5
|
-
Xpost.configure do |config|
|
6
|
-
config.api_key = ENV['XPOST_STAGING_API_KEY']
|
7
|
-
config.secret_key = ENV['XPOST_STAGING_SECRET_KEY']
|
8
|
-
config.staging_url = "https://api.staging.lbcx.ph/v1"
|
9
|
-
config.production_url = "https://api.staging.lbcx.ph/v1"
|
10
|
-
end
|
11
|
-
|
12
|
-
@auth_token = Xpost::Authentication.authenticate(Xpost.configuration.api_key, Xpost.configuration.secret_key)
|
13
|
-
@order = build(:order)
|
14
|
-
@order_data = Xpost::Orders.create(@auth_token, @order, "small-pouch")
|
15
|
-
@tracking_number = @order_data[:tracking_number]
|
16
|
-
@order = Xpost::Orders.find(@auth_token, @tracking_number)
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'for a single order' do
|
20
|
-
it 'should expect the order to be for_pickup' do
|
21
|
-
expect { Xpost::Orders.get_shipping_labels(@auth_token, @tracking_number) }.to raise_error "Order isn't for_pickup"
|
22
|
-
|
23
|
-
Xpost::Orders.confirm(@auth_token, @tracking_number)
|
24
|
-
expect { Xpost::Orders.get_shipping_labels(@auth_token, @tracking_number) }.to raise_error "Order isn't for_pickup"
|
25
|
-
|
26
|
-
order = Xpost::Orders.for_pickup(@auth_token, @tracking_number, build(:complete_address_pickup))
|
27
|
-
expect(order[:new_status]).to eq "for_pickup"
|
28
|
-
|
29
|
-
expect { Xpost::Orders.get_shipping_labels(@auth_token, @tracking_number) }.not_to raise_error
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should return the shipping labels' do
|
33
|
-
Xpost::Orders.confirm(@auth_token, @tracking_number)
|
34
|
-
Xpost::Orders.for_pickup(@auth_token, @tracking_number, build(:complete_address_pickup))
|
35
|
-
|
36
|
-
order = Xpost::Orders.get_shipping_labels(@auth_token, @tracking_number)
|
37
|
-
|
38
|
-
expect(order[:awb]).to be_present
|
39
|
-
expect(order[:pod]).to be_present
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'for multiple orders' do
|
44
|
-
it 'should return the shipping labels' do
|
45
|
-
Xpost::Orders.confirm(@auth_token, @tracking_number)
|
46
|
-
Xpost::Orders.for_pickup(@auth_token, @tracking_number, build(:complete_address_pickup))
|
47
|
-
|
48
|
-
new_order = build(:order)
|
49
|
-
new_order_data = Xpost::Orders.create(@auth_token, new_order, "small-pouch")
|
50
|
-
|
51
|
-
tracking_numbers = [@tracking_number, new_order_data[:tracking_number]]
|
52
|
-
|
53
|
-
order = Xpost::Orders.get_shipping_labels(@auth_token, @tracking_number)
|
54
|
-
|
55
|
-
expect(order[:awb]).to be_present
|
56
|
-
expect(order[:pod]).to be_present
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
data/spec/order/order_spec.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
RSpec.describe "Xpost::Order" do
|
5
|
-
|
6
|
-
describe '.attributes' do
|
7
|
-
before(:each) do
|
8
|
-
@order = build(:order)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'returns the base order details' do
|
12
|
-
attributes = @order.attributes
|
13
|
-
|
14
|
-
expect(attributes[:buyer_name]).to eq "John Doe"
|
15
|
-
expect(attributes[:email]).to eq "john@me.com"
|
16
|
-
expect(attributes[:contact_number]).to eq "+6391712345678"
|
17
|
-
expect(attributes[:currency]).to eq "PHP"
|
18
|
-
expect(attributes[:total]).to eq 1000
|
19
|
-
expect(attributes[:payment_method]).to eq "cod"
|
20
|
-
expect(attributes[:payment_provider]).to eq "lbcx"
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'returns the items' do
|
24
|
-
attributes = @order.attributes
|
25
|
-
order_items = attributes[:items]
|
26
|
-
|
27
|
-
expect(order_items).to be_present
|
28
|
-
expect(order_items.first[:description]).to eq "red shirt"
|
29
|
-
expect(order_items.first[:amount]).to eq 1000
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'returns the delivery_address' do
|
33
|
-
attributes = @order.attributes
|
34
|
-
delivery_address = attributes[:delivery_address]
|
35
|
-
|
36
|
-
expect(delivery_address).to be_present
|
37
|
-
expect(delivery_address[:name]).to eq "Bobby Axelrod"
|
38
|
-
expect(delivery_address[:line_1]).to eq "BGC Corporate Centre"
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'returns the pickup_address' do
|
42
|
-
@order = build(:cod_order_ready_for_pickup)
|
43
|
-
attributes = @order.attributes
|
44
|
-
pickup_address = attributes[:pickup_address]
|
45
|
-
|
46
|
-
expect(pickup_address).to be_present
|
47
|
-
expect(pickup_address[:name]).to eq "Taylor Mason"
|
48
|
-
expect(pickup_address[:line_1]).to eq "BGC Corporate Centre"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# describe '.to_json' do
|
53
|
-
# it '.to_json matches API requirements' do
|
54
|
-
# skip 'array order is being a little b'
|
55
|
-
# @order = build(:order)
|
56
|
-
# order_json = {
|
57
|
-
# email: "john@me.com",
|
58
|
-
# buyer_name: "John Doe",
|
59
|
-
# contact_number: "+6391712345678",
|
60
|
-
# shipment: "small-pouch",
|
61
|
-
# total: 1000,
|
62
|
-
# currency: "PHP",
|
63
|
-
# payment_method: "cod",
|
64
|
-
# payment_provider: "lbcx",
|
65
|
-
# items: {
|
66
|
-
# type: "product",
|
67
|
-
# description: "red shirt",
|
68
|
-
# amount: 1000,
|
69
|
-
# quantity: 1,
|
70
|
-
# metadata: "Small"
|
71
|
-
# },
|
72
|
-
# delivery_address: {
|
73
|
-
# name: "Bobby Axelrod",
|
74
|
-
# shipment: "small-pouch",
|
75
|
-
# line_1: "855 Sixth Avenue",
|
76
|
-
# line_2: "5th floor",
|
77
|
-
# city: "New York",
|
78
|
-
# state: "NY",
|
79
|
-
# postal_code: 10001,
|
80
|
-
# country: "US",
|
81
|
-
# company: "Axe Capital",
|
82
|
-
# title: "CEO",
|
83
|
-
# email: "bobby@axe.com",
|
84
|
-
# phone_number: "12345678",
|
85
|
-
# mobile_number: "091712345678",
|
86
|
-
# fax_number: "12345678",
|
87
|
-
# district: "Manhattan",
|
88
|
-
# remarks: "Send ASAP"
|
89
|
-
# },
|
90
|
-
# pickup_address: nil
|
91
|
-
# }.to_json
|
92
|
-
|
93
|
-
# expect(@order.to_json).to eq order_json
|
94
|
-
# end
|
95
|
-
# end
|
96
|
-
end
|