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/spec/factories/items.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
FactoryBot.define do
|
2
|
-
factory :product_item, class: Xpost::Item do
|
3
|
-
|
4
|
-
description
|
5
|
-
amount
|
2
|
+
factory :product_item, class: Xpost::Models::Item do
|
3
|
+
type "product"
|
4
|
+
description "orange shirt"
|
5
|
+
amount 1200
|
6
6
|
initialize_with { new(attributes) }
|
7
7
|
end
|
8
8
|
|
9
|
-
factory :complete_product_item, class: Xpost::Item do
|
10
|
-
|
11
|
-
description
|
12
|
-
amount
|
13
|
-
quantity
|
14
|
-
metadata
|
9
|
+
factory :complete_product_item, class: Xpost::Models::Item do
|
10
|
+
type "product"
|
11
|
+
description "red shirt"
|
12
|
+
amount 1000
|
13
|
+
quantity 1
|
14
|
+
metadata "Small"
|
15
15
|
initialize_with { new(attributes) }
|
16
16
|
end
|
17
17
|
end
|
data/spec/factories/orders.rb
CHANGED
@@ -1,53 +1,30 @@
|
|
1
|
-
require 'faker'
|
2
|
-
|
3
1
|
FactoryBot.define do
|
4
|
-
factory :order, class: Xpost::Order do
|
5
|
-
email
|
6
|
-
buyer_name
|
7
|
-
contact_number
|
8
|
-
reference_id { "xport-test-#{Faker::Number.number(10)}" }
|
9
|
-
|
10
|
-
shipment { "small-pouch" }
|
11
|
-
total { 1000 }
|
12
|
-
currency { "PHP" }
|
13
|
-
payment_method { "cod" }
|
14
|
-
payment_provider { "lbcx" }
|
15
|
-
|
16
|
-
items { [build(:complete_product_item)] }
|
17
|
-
delivery_address { build(:complete_address) }
|
18
|
-
end
|
19
|
-
|
20
|
-
factory :cod_order, class: Xpost::Order do
|
21
|
-
email { "john@me.com" }
|
22
|
-
buyer_name { "John Doe" }
|
23
|
-
contact_number { "+6391712345678" }
|
24
|
-
reference_id { "xport-test-#{Faker::Number.number(10)}" }
|
2
|
+
factory :order, class: Xpost::Models::Order do
|
3
|
+
email "john@me.com"
|
4
|
+
buyer_name "John Doe"
|
5
|
+
contact_number "+6391712345678"
|
25
6
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
payment_provider { "lbcx" }
|
7
|
+
total 1500
|
8
|
+
currency "PHP"
|
9
|
+
payment_method "cod"
|
10
|
+
payment_provider "lbcx"
|
31
11
|
|
32
12
|
items { [build(:complete_product_item)] }
|
33
13
|
delivery_address { build(:complete_address) }
|
34
14
|
end
|
35
15
|
|
36
|
-
factory :
|
37
|
-
email
|
38
|
-
buyer_name
|
39
|
-
contact_number
|
40
|
-
reference_id { "xport-test-#{Faker::Number.number(10)}" }
|
16
|
+
factory :cod_order, class: Xpost::Models::Order do
|
17
|
+
email "john@me.com"
|
18
|
+
buyer_name "John Doe"
|
19
|
+
contact_number "+6391712345678"
|
41
20
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
payment_provider { "lbcx" }
|
21
|
+
total 1500
|
22
|
+
currency "PHP"
|
23
|
+
payment_method "cod"
|
24
|
+
payment_provider "lbcx"
|
47
25
|
|
48
26
|
items { [build(:complete_product_item)] }
|
49
27
|
delivery_address { build(:complete_address) }
|
50
|
-
pickup_address { build(:complete_address_pickup) }
|
51
28
|
end
|
52
29
|
|
53
30
|
# factory :confirmable_order, class: Xpost::Models::Order do
|
data/spec/helpers.rb
CHANGED
File without changes
|
@@ -5,14 +5,14 @@ RSpec.describe 'Item' do
|
|
5
5
|
item = build(:product_item)
|
6
6
|
|
7
7
|
expect(item).to be_valid
|
8
|
-
expect(item.
|
8
|
+
expect(item.type).to eq "product"
|
9
9
|
expect(item.description).to eq "orange shirt"
|
10
|
-
expect(item.amount).to eq
|
10
|
+
expect(item.amount).to eq 1200
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'requires a valid item_type' do
|
14
|
-
expect(build(:product_item,
|
15
|
-
expect(build(:product_item,
|
14
|
+
expect(build(:product_item, type: "product")).to be_valid
|
15
|
+
expect(build(:product_item, type: "productz")).not_to be_valid
|
16
16
|
end
|
17
17
|
|
18
18
|
describe 'with required parameters' do
|
@@ -34,7 +34,7 @@ RSpec.describe 'Item' do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'is invalid without the required parameters' do
|
37
|
-
item = build(:complete_product_item,
|
37
|
+
item = build(:complete_product_item, type: nil)
|
38
38
|
expect(item).not_to be_valid
|
39
39
|
end
|
40
40
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'LineItem' do
|
4
|
+
|
5
|
+
describe 'with require parameters' do
|
6
|
+
# it 'is valid' do
|
7
|
+
# line_item = build(:line_item)
|
8
|
+
# expect(line_item).to be_valid
|
9
|
+
# end
|
10
|
+
|
11
|
+
# it 'is invalid with missing parameters' do
|
12
|
+
# line_item = build(:line_item, type: nil)
|
13
|
+
# expect(line_item).not_to be_valid
|
14
|
+
# end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'set'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe "Orders.create" do
|
5
|
+
before(:each) do
|
6
|
+
@order = build(:order)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'requires a delivery address' do
|
10
|
+
order_without_delivery_address = build(:order, delivery_address: nil)
|
11
|
+
order_with_delivery_address = build(:order)
|
12
|
+
expect(order_without_delivery_address).not_to be_valid
|
13
|
+
expect(order_with_delivery_address).to be_valid
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'requires a payment method' do
|
17
|
+
expect(@order.payment_method).to be_present
|
18
|
+
expect(@order.payment_provider).to be_present
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'requires at least one product in line items' do
|
22
|
+
expect(@order.items.count).to eq 1
|
23
|
+
expect(@order.items.first.description).to eq "red shirt"
|
24
|
+
end
|
25
|
+
|
26
|
+
# TODO: Skipping calls for now to prevent multiple
|
27
|
+
# orders from being added to the staging site.
|
28
|
+
|
29
|
+
|
30
|
+
# it 'creates an order' do
|
31
|
+
# auth_token = Xpost::Authentication.local_auth
|
32
|
+
# @res = Xpost::Orders.create(auth_token, @order)
|
33
|
+
# expect(@res[:tracking_number]).to eq 200
|
34
|
+
# end
|
35
|
+
|
36
|
+
# describe 'returning a valid order object' do
|
37
|
+
# before(:each) do
|
38
|
+
# auth_token = Xpost::Authentication.local_auth
|
39
|
+
# @res = Xpost::Orders.create(auth_token, @order)
|
40
|
+
# end
|
41
|
+
|
42
|
+
# it 'has a tracking number'
|
43
|
+
# it 'has a status of confirming'
|
44
|
+
# end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe "@order.for_pickup" do
|
4
|
+
before do
|
5
|
+
Xpost.configure do |config|
|
6
|
+
config.api_key = 'api_key'
|
7
|
+
config.secret_key = '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
|
+
@auth_token = Xpost::Authentication.authenticate(Xpost.configuration.api_key, Xpost.configuration.secret_key)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'already has a delivery address'
|
15
|
+
it 'requires a pickup address'
|
16
|
+
|
17
|
+
end
|
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe "Orders.find" do
|
4
4
|
before do
|
5
5
|
Xpost.configure do |config|
|
6
|
-
config.api_key =
|
7
|
-
config.secret_key =
|
6
|
+
config.api_key = 'api_key'
|
7
|
+
config.secret_key = 'secret_key'
|
8
8
|
config.staging_url = "https://api.staging.lbcx.ph/v1"
|
9
9
|
config.production_url = "https://api.staging.lbcx.ph/v1"
|
10
10
|
end
|
@@ -16,7 +16,6 @@ RSpec.describe "Orders.find" do
|
|
16
16
|
order = Xpost::Orders.find(@auth_token, tracking_number)
|
17
17
|
|
18
18
|
expect(order[:id]).to eq 761174
|
19
|
-
expect(order[:tracking_number]).to eq "0076-1174-PSAT"
|
20
19
|
end
|
21
20
|
|
22
21
|
it 'fails on an invalid order' do
|
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe "Orders.track" do
|
4
4
|
before do
|
5
5
|
Xpost.configure do |config|
|
6
|
-
config.api_key =
|
7
|
-
config.secret_key =
|
6
|
+
config.api_key = 'api_key'
|
7
|
+
config.secret_key = 'secret_key'
|
8
8
|
config.staging_url = "https://api.staging.lbcx.ph/v1"
|
9
9
|
config.production_url = "https://api.staging.lbcx.ph/v1"
|
10
10
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/xpost_spec.rb
CHANGED
@@ -33,32 +33,5 @@ RSpec.describe Xpost do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
37
|
-
describe 'Statuses' do
|
38
|
-
before do
|
39
|
-
Xpost.configure do |config|
|
40
|
-
config.api_key = ENV['XPOST_STAGING_API_KEY']
|
41
|
-
config.secret_key = ENV['XPOST_STAGING_SECRET_KEY']
|
42
|
-
config.staging_url = "https://api.staging.lbcx.ph/v1"
|
43
|
-
config.production_url = "https://api.staging.lbcx.ph/v1"
|
44
|
-
end
|
45
|
-
@auth_token = Xpost::Authentication.authenticate(Xpost.configuration.api_key, Xpost.configuration.secret_key)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'returns statuses' do
|
49
|
-
statuses = Xpost::Statuses.all(@auth_token)
|
50
|
-
|
51
|
-
expect(statuses.count).to_not eq 0
|
52
|
-
expect(statuses.first[:name]).to eq "pending"
|
53
|
-
expect(statuses.first[:label]).to eq "Pending"
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'fails to retrieve statuses with an invalid auth_token' do
|
57
|
-
statuses = Xpost::Statuses.all("random_invalid_auth_token")
|
58
|
-
|
59
|
-
expect(statuses[:status]).to eq 401
|
60
|
-
expect(statuses[:message]).to eq "Unauthorized"
|
61
|
-
end
|
62
|
-
end
|
63
36
|
end
|
64
37
|
|
data/xpost.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = 'david@xpanse.ph'
|
10
10
|
|
11
11
|
s.summary = "xpost Ruby API"
|
12
|
-
s.date = '2018-
|
12
|
+
s.date = '2018-04-27'
|
13
13
|
s.description = "A quick wrapped of the xpost API written by xpanse."
|
14
14
|
s.homepage = 'http://rubygems.org/gems/xpost'
|
15
15
|
s.license = 'MIT'
|
@@ -17,16 +17,12 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
-
s.
|
21
|
-
|
20
|
+
s.add_dependency 'activemodel', '~> 5.2'
|
22
21
|
s.add_dependency 'typhoeus', '~> 1.3'
|
23
22
|
s.add_dependency 'factory_bot', '~> 4.8'
|
24
|
-
s.add_dependency 'fast_jsonapi', '~> 1.3'
|
25
23
|
# s.add_dependency 'vcr', '~> 4.0'
|
26
24
|
|
27
25
|
s.add_development_dependency 'bundler', "~> 1.16"
|
28
|
-
s.add_development_dependency 'faker', "~> 1.9"
|
29
26
|
s.add_development_dependency 'rake', "~> 12.3"
|
30
27
|
s.add_development_dependency 'rspec', '~> 3.2'
|
31
|
-
s.add_development_dependency 'dotenv', '~> 2.5'
|
32
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xpost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Marquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: typhoeus
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.8'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: fast_jsonapi
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.3'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.3'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: bundler
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +66,6 @@ dependencies:
|
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '1.16'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: faker
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.9'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.9'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: rake
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,20 +94,6 @@ dependencies:
|
|
122
94
|
- - "~>"
|
123
95
|
- !ruby/object:Gem::Version
|
124
96
|
version: '3.2'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: dotenv
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '2.5'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '2.5'
|
139
97
|
description: A quick wrapped of the xpost API written by xpanse.
|
140
98
|
email: david@xpanse.ph
|
141
99
|
executables: []
|
@@ -149,36 +107,26 @@ files:
|
|
149
107
|
- LICENSE
|
150
108
|
- README.md
|
151
109
|
- TODO.md
|
152
|
-
- lib/.DS_Store
|
153
110
|
- lib/xpost.rb
|
154
|
-
- lib/xpost/.DS_Store
|
155
|
-
- lib/xpost/address.rb
|
156
111
|
- lib/xpost/authentication.rb
|
157
112
|
- lib/xpost/configuration.rb
|
158
|
-
- lib/xpost/
|
159
|
-
- lib/xpost/
|
113
|
+
- lib/xpost/models.rb
|
114
|
+
- lib/xpost/models/address.rb
|
115
|
+
- lib/xpost/models/item.rb
|
116
|
+
- lib/xpost/models/order.rb
|
160
117
|
- lib/xpost/orders.rb
|
161
|
-
- lib/xpost/statuses.rb
|
162
118
|
- lib/xpost/version.rb
|
163
|
-
-
|
164
|
-
- sample/sample_xpost_order-confirmed.json
|
165
|
-
- sample/sample_xpost_order-for-pickup.json
|
166
|
-
- sample/sample_xpost_order-pending.json
|
167
|
-
- sample/webhook_sample.json
|
119
|
+
- spec/address_spec.rb
|
168
120
|
- spec/factories/addresses.rb
|
169
121
|
- spec/factories/items.rb
|
170
122
|
- spec/factories/orders.rb
|
171
123
|
- spec/helpers.rb
|
172
|
-
- spec/
|
173
|
-
- spec/
|
174
|
-
- spec/
|
175
|
-
- spec/
|
176
|
-
- spec/
|
177
|
-
- spec/
|
178
|
-
- spec/order/items/item_spec.rb
|
179
|
-
- spec/order/order_spec.rb
|
180
|
-
- spec/orders/find_spec.rb
|
181
|
-
- spec/orders/track_spec.rb
|
124
|
+
- spec/item_spec.rb
|
125
|
+
- spec/line_item_spec.rb
|
126
|
+
- spec/orders/order_create_spec.rb
|
127
|
+
- spec/orders/order_for_pickup_spec.rb
|
128
|
+
- spec/orders/orders_find_spec.rb
|
129
|
+
- spec/orders/orders_track_spec.rb
|
182
130
|
- spec/spec_helper.rb
|
183
131
|
- spec/xpost_spec.rb
|
184
132
|
- xpost.gemspec
|
@@ -201,7 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
149
|
- !ruby/object:Gem::Version
|
202
150
|
version: '0'
|
203
151
|
requirements: []
|
204
|
-
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.6.14
|
205
154
|
signing_key:
|
206
155
|
specification_version: 4
|
207
156
|
summary: xpost Ruby API
|