buckybox-api 1.6.2 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.gitlab-ci.yml +20 -0
- data/.rubocop.yml +29 -0
- data/.simplecov +1 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/buckybox-api.gemspec +12 -10
- data/fixtures/authenticate_customer.yml +60 -0
- data/fixtures/box.yml +63 -0
- data/fixtures/boxes.yml +70 -0
- data/fixtures/create_or_update_customer.yml +62 -0
- data/fixtures/create_order.yml +62 -0
- data/fixtures/customer.yml +60 -0
- data/fixtures/customers.yml +60 -0
- data/fixtures/delivery_service.yml +60 -0
- data/fixtures/delivery_services.yml +60 -0
- data/fixtures/webstore.yml +78 -0
- data/lib/buckybox/api.rb +70 -37
- data/spec/lib/buckybox/api_spec.rb +35 -25
- data/spec/spec_helper.rb +14 -6
- metadata +58 -18
|
@@ -3,14 +3,18 @@ require_relative "../../../lib/buckybox/api"
|
|
|
3
3
|
RSpec.describe BuckyBox::API, :vcr do
|
|
4
4
|
let(:api) do
|
|
5
5
|
BuckyBox::API.new(
|
|
6
|
-
"API-Key" => ENV.fetch("BUCKYBOX_API_KEY"),
|
|
7
|
-
"API-Secret" => ENV.fetch("BUCKYBOX_API_SECRET"),
|
|
6
|
+
"API-Key" => ENV.fetch("BUCKYBOX_API_KEY", ""),
|
|
7
|
+
"API-Secret" => ENV.fetch("BUCKYBOX_API_SECRET", ""),
|
|
8
8
|
)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
let(:box_id) { 217 }
|
|
12
|
+
let(:delivery_service_id) { 91 }
|
|
13
|
+
let(:customer_id) { 8859 }
|
|
14
|
+
|
|
11
15
|
before do
|
|
12
16
|
method = self.class.metadata[:parent_example_group][:description][1..-1]
|
|
13
|
-
VCR.insert_cassette
|
|
17
|
+
VCR.insert_cassette "/#{method}"
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
after do
|
|
@@ -21,15 +25,7 @@ RSpec.describe BuckyBox::API, :vcr do
|
|
|
21
25
|
let(:response) { subject }
|
|
22
26
|
|
|
23
27
|
specify { expect { response }.not_to raise_error }
|
|
24
|
-
specify { expect(
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
shared_examples_for "an invalid API response" do
|
|
28
|
-
let(:response) { subject }
|
|
29
|
-
|
|
30
|
-
it "returns an error when posting invalid params" do
|
|
31
|
-
expect { response }.to raise_error BuckyBox::API::ResponseError
|
|
32
|
-
end
|
|
28
|
+
specify { expect([BuckyBox::API::Response, Array]).to include response.class }
|
|
33
29
|
end
|
|
34
30
|
|
|
35
31
|
describe "#boxes" do
|
|
@@ -38,12 +34,8 @@ RSpec.describe BuckyBox::API, :vcr do
|
|
|
38
34
|
end
|
|
39
35
|
|
|
40
36
|
describe "#box" do
|
|
41
|
-
subject { api.box(
|
|
37
|
+
subject { api.box(box_id) }
|
|
42
38
|
it_behaves_like "a valid API response"
|
|
43
|
-
|
|
44
|
-
it "raises NotFoundError if not found" do
|
|
45
|
-
expect { api.box(0) }.to raise_error BuckyBox::API::NotFoundError
|
|
46
|
-
end
|
|
47
39
|
end
|
|
48
40
|
|
|
49
41
|
describe "#delivery_services" do
|
|
@@ -52,7 +44,7 @@ RSpec.describe BuckyBox::API, :vcr do
|
|
|
52
44
|
end
|
|
53
45
|
|
|
54
46
|
describe "#delivery_service" do
|
|
55
|
-
subject { api.delivery_service(
|
|
47
|
+
subject { api.delivery_service(delivery_service_id) }
|
|
56
48
|
it_behaves_like "a valid API response"
|
|
57
49
|
end
|
|
58
50
|
|
|
@@ -62,27 +54,45 @@ RSpec.describe BuckyBox::API, :vcr do
|
|
|
62
54
|
end
|
|
63
55
|
|
|
64
56
|
describe "#customers" do
|
|
65
|
-
subject { api.customers }
|
|
57
|
+
subject { api.customers(email: "joe@buckybox.com") }
|
|
66
58
|
it_behaves_like "a valid API response"
|
|
67
59
|
end
|
|
68
60
|
|
|
69
61
|
describe "#customer" do
|
|
70
|
-
subject { api.customer(
|
|
62
|
+
subject { api.customer(customer_id, embed: "address") }
|
|
71
63
|
it_behaves_like "a valid API response"
|
|
72
64
|
end
|
|
73
65
|
|
|
74
66
|
describe "#authenticate_customer" do
|
|
75
|
-
subject { api.authenticate_customer(email: "joe@
|
|
67
|
+
subject { api.authenticate_customer(email: "joe@buckybox.com", password: "nope") }
|
|
76
68
|
it_behaves_like "a valid API response"
|
|
77
69
|
end
|
|
78
70
|
|
|
79
71
|
describe "#create_or_update_customer" do
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
let(:customer) do
|
|
73
|
+
{
|
|
74
|
+
id: customer_id,
|
|
75
|
+
first_name: "Joe",
|
|
76
|
+
}
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
subject { api.create_or_update_customer(JSON.dump(customer)) }
|
|
80
|
+
it_behaves_like "a valid API response"
|
|
82
81
|
end
|
|
83
82
|
|
|
84
83
|
describe "#create_order" do
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
let(:order) do
|
|
85
|
+
{
|
|
86
|
+
customer_id: customer_id,
|
|
87
|
+
box_id: box_id,
|
|
88
|
+
start_date: "2016-08-09",
|
|
89
|
+
week_days: [2],
|
|
90
|
+
frequency: "single",
|
|
91
|
+
payment_method: "cash_on_delivery",
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
subject { api.create_order(JSON.dump(order)) }
|
|
96
|
+
it_behaves_like "a valid API response"
|
|
87
97
|
end
|
|
88
98
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -65,7 +65,7 @@ RSpec.configure do |config|
|
|
|
65
65
|
# Use the documentation formatter for detailed output,
|
|
66
66
|
# unless a formatter has already been configured
|
|
67
67
|
# (e.g. via a command-line flag).
|
|
68
|
-
config.default_formatter =
|
|
68
|
+
config.default_formatter = "doc"
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
# Print the 10 slowest examples and example groups at the
|
|
@@ -88,10 +88,18 @@ end
|
|
|
88
88
|
|
|
89
89
|
require "vcr"
|
|
90
90
|
VCR.configure do |c|
|
|
91
|
-
c.cassette_library_dir = 'fixtures'
|
|
92
|
-
c.hook_into :webmock
|
|
93
91
|
c.configure_rspec_metadata!
|
|
94
|
-
c.
|
|
95
|
-
c.
|
|
92
|
+
c.cassette_library_dir = "fixtures"
|
|
93
|
+
c.hook_into :webmock
|
|
94
|
+
c.default_cassette_options = {
|
|
95
|
+
record: :once, # NOTE: change to :all to refresh cassettes
|
|
96
|
+
allow_playback_repeats: true,
|
|
97
|
+
}
|
|
98
|
+
c.filter_sensitive_data("<API-Key>") { ENV.key("BUCKYBOX_API_KEY") }
|
|
99
|
+
c.filter_sensitive_data("<API-Secret>") { ENV.key("BUCKYBOX_API_SECRET") }
|
|
100
|
+
c.before_record do |interaction|
|
|
101
|
+
%w(Server Set-Cookie X-Request-Id X-Runtime X-Rack-Cache).each do |header|
|
|
102
|
+
interaction.response.headers.delete(header)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
96
105
|
end
|
|
97
|
-
|
metadata
CHANGED
|
@@ -1,57 +1,71 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: buckybox-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cédric Félizard
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: typhoeus
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 1.1.0
|
|
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: 1.1.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: hashie
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 3.4.4
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 3.4.4
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: crazy_money
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 1.
|
|
47
|
+
version: 1.4.0
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 1.
|
|
54
|
+
version: 1.4.0
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: oj
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: bundler
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,28 +100,28 @@ dependencies:
|
|
|
86
100
|
requirements:
|
|
87
101
|
- - ">="
|
|
88
102
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '3'
|
|
103
|
+
version: '3.5'
|
|
90
104
|
type: :development
|
|
91
105
|
prerelease: false
|
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
107
|
requirements:
|
|
94
108
|
- - ">="
|
|
95
109
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '3'
|
|
110
|
+
version: '3.5'
|
|
97
111
|
- !ruby/object:Gem::Dependency
|
|
98
112
|
name: vcr
|
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
|
100
114
|
requirements:
|
|
101
115
|
- - ">="
|
|
102
116
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
117
|
+
version: '3'
|
|
104
118
|
type: :development
|
|
105
119
|
prerelease: false
|
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
121
|
requirements:
|
|
108
122
|
- - ">="
|
|
109
123
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
124
|
+
version: '3'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: webmock
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -128,14 +142,28 @@ dependencies:
|
|
|
128
142
|
requirements:
|
|
129
143
|
- - ">="
|
|
130
144
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '0.
|
|
145
|
+
version: '0.11'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0.11'
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: rubocop
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
132
160
|
type: :development
|
|
133
161
|
prerelease: false
|
|
134
162
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
163
|
requirements:
|
|
136
164
|
- - ">="
|
|
137
165
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '0
|
|
166
|
+
version: '0'
|
|
139
167
|
description: RubyGem wrapper for the Bucky Box API - https://api.buckybox.com/docs
|
|
140
168
|
email:
|
|
141
169
|
- cedric@felizard.fr
|
|
@@ -144,17 +172,29 @@ extensions: []
|
|
|
144
172
|
extra_rdoc_files: []
|
|
145
173
|
files:
|
|
146
174
|
- ".gitignore"
|
|
175
|
+
- ".gitlab-ci.yml"
|
|
147
176
|
- ".rspec"
|
|
177
|
+
- ".rubocop.yml"
|
|
148
178
|
- ".simplecov"
|
|
149
179
|
- Gemfile
|
|
150
180
|
- LICENSE.txt
|
|
151
181
|
- README.md
|
|
152
182
|
- Rakefile
|
|
153
183
|
- buckybox-api.gemspec
|
|
184
|
+
- fixtures/authenticate_customer.yml
|
|
185
|
+
- fixtures/box.yml
|
|
186
|
+
- fixtures/boxes.yml
|
|
187
|
+
- fixtures/create_or_update_customer.yml
|
|
188
|
+
- fixtures/create_order.yml
|
|
189
|
+
- fixtures/customer.yml
|
|
190
|
+
- fixtures/customers.yml
|
|
191
|
+
- fixtures/delivery_service.yml
|
|
192
|
+
- fixtures/delivery_services.yml
|
|
193
|
+
- fixtures/webstore.yml
|
|
154
194
|
- lib/buckybox/api.rb
|
|
155
195
|
- spec/lib/buckybox/api_spec.rb
|
|
156
196
|
- spec/spec_helper.rb
|
|
157
|
-
homepage:
|
|
197
|
+
homepage: https://github.com/buckybox/buckybox-api-ruby
|
|
158
198
|
licenses:
|
|
159
199
|
- LGPLv3
|
|
160
200
|
metadata: {}
|
|
@@ -174,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
174
214
|
version: '0'
|
|
175
215
|
requirements: []
|
|
176
216
|
rubyforge_project:
|
|
177
|
-
rubygems_version: 2.
|
|
217
|
+
rubygems_version: 2.5.1
|
|
178
218
|
signing_key:
|
|
179
219
|
specification_version: 4
|
|
180
220
|
summary: RubyGem wrapper for the Bucky Box API
|