bigcommerce 0.8.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,7 @@
2
2
  require File.expand_path('../lib/bigcommerce/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- if RUBY_VERSION < '1.9'
6
- s.add_dependency('activesupport', '< 4.0')
7
- else
8
- s.add_dependency('activesupport')
9
- end
5
+ s.add_dependency('activesupport')
10
6
  s.add_dependency('json')
11
7
  s.add_dependency('rest-client')
12
8
  if RUBY_VERSION >= '1.9'
@@ -1,3 +1,5 @@
1
+ require 'date'
2
+
1
3
  module Bigcommerce
2
4
  class Api
3
5
 
@@ -44,7 +46,7 @@ module Bigcommerce
44
46
  def get_brands_count
45
47
  @connection.get '/brands/count'
46
48
  end
47
-
49
+
48
50
  def get_brand(id)
49
51
  @connection.get("/brands/#{id}", {})
50
52
  end
@@ -56,7 +58,7 @@ module Bigcommerce
56
58
  def update_brand(id, options={})
57
59
  @connection.put("/brands/#{id}", options)
58
60
  end
59
-
61
+
60
62
  def delete_brand(id)
61
63
  @connection.delete("/brands/#{id}")
62
64
  end
@@ -92,11 +94,11 @@ module Bigcommerce
92
94
  def update_category(id, options={})
93
95
  @connection.put("/categories/#{id}", options)
94
96
  end
95
-
97
+
96
98
  def delete_category(id)
97
99
  @connection.delete("/categories/#{id}")
98
100
  end
99
-
101
+
100
102
  def get_countries(options={})
101
103
  @connection.get("/countries", options)
102
104
  end
@@ -148,7 +150,7 @@ module Bigcommerce
148
150
  def update_option(id, options={})
149
151
  @connection.put("/options/#{id}", options)
150
152
  end
151
-
153
+
152
154
  def delete_option(id)
153
155
  @connection.delete("/options/#{id}")
154
156
  end
@@ -172,11 +174,11 @@ module Bigcommerce
172
174
  def get_optionsets(options={})
173
175
  @connection.get("/optionsets", options)
174
176
  end
175
-
177
+
176
178
  def get_optionsets_count
177
179
  @connection.get '/optionsets/count'
178
180
  end
179
-
181
+
180
182
  def get_optionset(id)
181
183
  @connection.get("/optionsets/#{id}", {})
182
184
  end
@@ -188,7 +190,7 @@ module Bigcommerce
188
190
  def update_optionset(id, options={})
189
191
  @connection.put("/optionsets/#{id}", options)
190
192
  end
191
-
193
+
192
194
  def delete_optionset(id)
193
195
  @connection.delete("/optionsets/#{id}")
194
196
  end
@@ -200,7 +202,7 @@ module Bigcommerce
200
202
  def get_optionset_options(id)
201
203
  @connection.get("/optionsets/#{id}/options", {})
202
204
  end
203
-
205
+
204
206
  def get_optionsets_option(id)
205
207
  @connection.get("/optionsets/options/#{id}", {})
206
208
  end
@@ -291,7 +293,7 @@ module Bigcommerce
291
293
  def get_products_count
292
294
  @connection.get '/products/count'
293
295
  end
294
-
296
+
295
297
  def get_product(id)
296
298
  @connection.get("/products/#{id}", {})
297
299
  end
@@ -303,15 +305,15 @@ module Bigcommerce
303
305
  def update_products(id, options={})
304
306
  @connection.put("/products/#{id}", options)
305
307
  end
306
-
308
+
307
309
  def get_products_discountrules(options={})
308
310
  @connection.get("/products/discountrules", options)
309
311
  end
310
-
312
+
311
313
  def get_product_discountrules(product_id, options={})
312
314
  @connection.get("/products/#{product_id}/discountrules", options)
313
315
  end
314
-
316
+
315
317
  def get_products_discountrule(product_id, discountrule_id)
316
318
  @connection.get("/products/#{product_id}/discountrules/#{discountrule_id}", {})
317
319
  end
@@ -323,7 +325,7 @@ module Bigcommerce
323
325
  def get_product_configurablefields(product_id, options={})
324
326
  @connection.get("/products/#{product_id}/configurablefields", options)
325
327
  end
326
-
328
+
327
329
  def get_products_configurablefield(product_id, configurable_field_id)
328
330
  @connection.get("/products/#{product_id}/configurablefields/#{configurable_field_id}", {})
329
331
  end
@@ -331,7 +333,7 @@ module Bigcommerce
331
333
  def get_products_customfields(options={})
332
334
  @connection.get("/products/customfields", options)
333
335
  end
334
-
336
+
335
337
  def get_product_customfields(product_id, options={})
336
338
  @connection.get("/products/#{product_id}/customfields", options)
337
339
  end
@@ -343,7 +345,7 @@ module Bigcommerce
343
345
  def get_product_images(product_id, options={})
344
346
  @connection.get("/products/#{product_id}/images", options)
345
347
  end
346
-
348
+
347
349
  def create_product_images(product_id, options={})
348
350
  @connection.post("/products/#{product_id}/images", options)
349
351
  end
@@ -367,7 +369,7 @@ module Bigcommerce
367
369
  def get_products_customfields(options={})
368
370
  @connection.get("/products/options", options)
369
371
  end
370
-
372
+
371
373
  def get_product_options(product_id, options={})
372
374
  @connection.get("/products/#{product_id}/options", options)
373
375
  end
@@ -383,7 +385,7 @@ module Bigcommerce
383
385
  def get_product_rules(product_id, options={})
384
386
  @connection.get("/products/#{product_id}/rules", options)
385
387
  end
386
-
388
+
387
389
  def create_products_rules(options={})
388
390
  @connection.post("/products/rules", options)
389
391
  end
@@ -399,7 +401,7 @@ module Bigcommerce
399
401
  def get_products_skus(options={})
400
402
  @connection.get("/products/skus", options)
401
403
  end
402
-
404
+
403
405
  def get_product_skus(product_id, options={})
404
406
  @connection.get("/products/#{product_id}/skus", options)
405
407
  end
@@ -419,7 +421,7 @@ module Bigcommerce
419
421
  def get_products_videos(options={})
420
422
  @connection.get("/products/videos", options)
421
423
  end
422
-
424
+
423
425
  def get_product_videos(product_id, options={})
424
426
  @connection.get("/products/#{product_id}/videos", options)
425
427
  end
@@ -62,7 +62,12 @@ module Bigcommerce
62
62
  end
63
63
 
64
64
  def request(method, path, options,headers={})
65
- restclient = RestClient::Resource.new "#{@configuration[:store_url]}/api/v2#{path}.json", @configuration[:username], @configuration[:api_key]
65
+ resource_options = {
66
+ :user => @configuration[:username],
67
+ :password => @configuration[:api_key],
68
+ :headers => headers
69
+ }
70
+ restclient = RestClient::Resource.new "#{@configuration[:store_url]}/api/v2#{path}.json", resource_options
66
71
  if @configuration[:ssl_client_key] && @configuration[:ssl_client_cert] && @configuration[:ssl_ca_file]
67
72
  restclient = RestClient::Resource.new(
68
73
  "#{@configuration[:store_url]}/api/v2#{path}.json",
@@ -1,6 +1,6 @@
1
1
  module Bigcommerce
2
2
  major = 0
3
- minor = 8
4
- patch = 4
3
+ minor = 9
4
+ patch = 0
5
5
  VERSION = [major, minor, patch].join('.') unless defined? Bigcommerce::VERSION
6
6
  end
@@ -7,12 +7,12 @@ describe "/api/v2/orders" do
7
7
  orders = api.get_orders
8
8
  orders.should be_a_kind_of(Enumerable)
9
9
  orders.size.should be > 0
10
- end
10
+ end
11
11
 
12
12
  it "filters orders by date", :vcr do
13
13
  orders = api.get_orders_by_date('2013-03-01')
14
14
  orders.should be_a_kind_of(Enumerable)
15
15
  orders.size.should be > 0
16
16
  end
17
-
18
- end
17
+
18
+ end
@@ -1,6 +1,6 @@
1
1
  describe "API request delegation" do
2
2
  include_context "mock api"
3
-
3
+
4
4
  it "requests a resource" do
5
5
  api.connection.should_receive(:get).once.with("/time")
6
6
  api.get_time
@@ -10,7 +10,7 @@ describe "API request delegation" do
10
10
  api.connection.should_receive(:get).once.with("/products/333", {})
11
11
  api.get_product(333)
12
12
  end
13
-
13
+
14
14
  it "requests a compound resource by ids" do
15
15
  api.connection.should_receive(:get).once.with("/orders/999/products/333", {})
16
16
  api.get_orders_product(999, 333)
@@ -30,5 +30,5 @@ describe "API request delegation" do
30
30
  api.connection.should_receive(:get).once.with("/customers", {:limit => 10, :page => 2})
31
31
  api.get_customers(:limit => 10, :page => 2)
32
32
  end
33
-
34
- end
33
+
34
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::Api do
4
+ include_context "mock api"
5
+
6
+ describe "get_orders_by_date" do
7
+ it "should accept a valid Date object" do
8
+ date = DateTime.now
9
+ parsed_date = described_class.new.to_rfc2822(date)
10
+ api.connection.should_receive(:get).once.with("/orders",
11
+ {:min_date_created => parsed_date})
12
+ api.get_orders_by_date(date)
13
+ end
14
+
15
+ it "should parse a valid date string" do
16
+ date = described_class.new.to_rfc2822(DateTime.parse('2012-1-1'))
17
+ api.connection.should_receive(:get).once.with("/orders",
18
+ {:min_date_created => date})
19
+ api.get_orders_by_date('2012-1-1')
20
+ end
21
+ end
22
+ end
@@ -22,3 +22,31 @@ shared_examples_for "request method accepting optional params and headers" do
22
22
  end
23
23
  end
24
24
 
25
+ describe Bigcommerce::Connection do
26
+ describe "#request" do
27
+ let(:configuration) { { :username => "test", :api_key => "12345", :store_url => "http://a.bigcommerce.com" } }
28
+ let(:connection) { Bigcommerce::Connection.new(configuration) }
29
+ let(:expected_url) { "#{configuration[:store_url]}/api/v2/orders.json" }
30
+ let(:expected_params) { { :user => "test", :password => "12345", :headers => {} } }
31
+ let(:mock_resource) { double("RestClient::Resource") }
32
+ let(:mock_response) { double }
33
+ let(:path) { "/orders" }
34
+
35
+ before do
36
+ mock_response.stub(:code).and_return(204)
37
+ mock_resource.stub(:get).and_return(mock_response)
38
+ end
39
+
40
+ it "should set up the expected url, user and password" do
41
+ RestClient::Resource.should_receive(:new).once.with(expected_url, expected_params).and_return(mock_resource)
42
+ connection.request(:get, path, {})
43
+ end
44
+
45
+ it "should pass through headers to RestClient::Resource" do
46
+ params_with_headers = expected_params.merge(:headers => {"Some-Header" => "abc"})
47
+ RestClient::Resource.should_receive(:new).once.with(expected_url, params_with_headers).and_return(mock_resource)
48
+
49
+ connection.request(:get, "/orders", {}, {"Some-Header" => "abc"})
50
+ end
51
+ end
52
+ end
metadata CHANGED
@@ -1,10 +1,15 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bigcommerce
3
- version: !ruby/object:Gem::Version
4
- version: 0.8.4
3
+ version: !ruby/object:Gem::Version
4
+ hash: 59
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Mark Rickerby
9
14
  - Rob Howard
10
15
  - Saranyan Vigraham
@@ -12,178 +17,151 @@ authors:
12
17
  autorequire:
13
18
  bindir: bin
14
19
  cert_chain: []
15
- date: 2013-09-06 00:00:00.000000000 Z
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
20
+
21
+ date: 2013-10-17 00:00:00 +11:00
22
+ default_executable:
23
+ dependencies:
24
+ - !ruby/object:Gem::Dependency
18
25
  name: activesupport
19
- requirement: !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - ! '>='
23
- - !ruby/object:Gem::Version
24
- version: '0'
25
- type: :runtime
26
26
  prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- - !ruby/object:Gem::Dependency
34
- name: json
35
- requirement: !ruby/object:Gem::Requirement
36
- none: false
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
27
+ requirement: &id001 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ hash: 3
33
+ segments:
34
+ - 0
35
+ version: "0"
41
36
  type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: json
42
40
  prerelease: false
43
- version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
- requirements:
46
- - - ! '>='
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- - !ruby/object:Gem::Dependency
50
- name: rest-client
51
- requirement: !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ! '>='
55
- - !ruby/object:Gem::Version
56
- version: '0'
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
57
50
  type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: rest-client
58
54
  prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
62
- - - ! '>='
63
- - !ruby/object:Gem::Version
64
- version: '0'
65
- - !ruby/object:Gem::Dependency
66
- name: coveralls
67
- requirement: !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ! '>='
71
- - !ruby/object:Gem::Version
72
- version: '0'
73
- type: :development
74
- prerelease: false
75
- version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ! '>='
79
- - !ruby/object:Gem::Version
80
- version: '0'
81
- - !ruby/object:Gem::Dependency
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :runtime
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
82
67
  name: ci_reporter
83
- requirement: !ruby/object:Gem::Requirement
84
- none: false
85
- requirements:
86
- - - ! '>='
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
- type: :development
90
68
  prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: mocha
99
- requirement: !ruby/object:Gem::Requirement
100
- none: false
101
- requirements:
102
- - - ! '>='
103
- - !ruby/object:Gem::Version
104
- version: '0'
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
105
78
  type: :development
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: mocha
106
82
  prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - ! '>='
111
- - !ruby/object:Gem::Version
112
- version: '0'
113
- - !ruby/object:Gem::Dependency
114
- name: rake
115
- requirement: !ruby/object:Gem::Requirement
116
- none: false
117
- requirements:
118
- - - ! '>='
119
- - !ruby/object:Gem::Version
120
- version: '0'
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
121
92
  type: :development
93
+ version_requirements: *id005
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
122
96
  prerelease: false
123
- version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
- requirements:
126
- - - ! '>='
127
- - !ruby/object:Gem::Version
128
- version: '0'
129
- - !ruby/object:Gem::Dependency
130
- name: rspec
131
- requirement: !ruby/object:Gem::Requirement
132
- none: false
133
- requirements:
134
- - - ~>
135
- - !ruby/object:Gem::Version
136
- version: '2.11'
97
+ requirement: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
137
106
  type: :development
107
+ version_requirements: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ name: rspec
138
110
  prerelease: false
139
- version_requirements: !ruby/object:Gem::Requirement
111
+ requirement: &id007 !ruby/object:Gem::Requirement
140
112
  none: false
141
- requirements:
113
+ requirements:
142
114
  - - ~>
143
- - !ruby/object:Gem::Version
144
- version: '2.11'
145
- - !ruby/object:Gem::Dependency
146
- name: vcr
147
- requirement: !ruby/object:Gem::Requirement
148
- none: false
149
- requirements:
150
- - - ! '>='
151
- - !ruby/object:Gem::Version
152
- version: '0'
115
+ - !ruby/object:Gem::Version
116
+ hash: 21
117
+ segments:
118
+ - 2
119
+ - 11
120
+ version: "2.11"
153
121
  type: :development
122
+ version_requirements: *id007
123
+ - !ruby/object:Gem::Dependency
124
+ name: vcr
154
125
  prerelease: false
155
- version_requirements: !ruby/object:Gem::Requirement
156
- none: false
157
- requirements:
158
- - - ! '>='
159
- - !ruby/object:Gem::Version
160
- version: '0'
161
- - !ruby/object:Gem::Dependency
162
- name: webmock
163
- requirement: !ruby/object:Gem::Requirement
164
- none: false
165
- requirements:
166
- - - '='
167
- - !ruby/object:Gem::Version
168
- version: '1.9'
126
+ requirement: &id008 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
134
+ version: "0"
169
135
  type: :development
136
+ version_requirements: *id008
137
+ - !ruby/object:Gem::Dependency
138
+ name: webmock
170
139
  prerelease: false
171
- version_requirements: !ruby/object:Gem::Requirement
172
- none: false
173
- requirements:
174
- - - '='
175
- - !ruby/object:Gem::Version
176
- version: '1.9'
140
+ requirement: &id009 !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - "="
144
+ - !ruby/object:Gem::Version
145
+ hash: 29
146
+ segments:
147
+ - 1
148
+ - 9
149
+ version: "1.9"
150
+ type: :development
151
+ version_requirements: *id009
177
152
  description: Enables Ruby applications to communicate with the Bigcommerce API V2.
178
- email:
153
+ email:
179
154
  - mark.rickerby@bigcommerce.com
180
155
  - rob.howard@bigcommerce.com
181
156
  - saranyan.vigraham@bigcommerce.com
182
157
  - sasha.gerrand@bigcommerce.com
183
158
  executables: []
159
+
184
160
  extensions: []
161
+
185
162
  extra_rdoc_files: []
186
- files:
163
+
164
+ files:
187
165
  - LICENSE
188
166
  - Rakefile
189
167
  - README.md
@@ -199,43 +177,56 @@ files:
199
177
  - ./spec/support/integration_context.rb
200
178
  - ./spec/support/mock_api_context.rb
201
179
  - ./spec/unit/api_request_spec.rb
180
+ - ./spec/unit/api_spec.rb
202
181
  - ./spec/unit/connection_spec.rb
203
182
  - ./spec/unit/date_time_spec.rb
204
183
  - ./spec/unit/version_spec.rb
205
184
  - spec/big_commerce_spec.rb
206
185
  - spec/integration/orders_spec.rb
207
186
  - spec/unit/api_request_spec.rb
187
+ - spec/unit/api_spec.rb
208
188
  - spec/unit/connection_spec.rb
209
189
  - spec/unit/date_time_spec.rb
210
190
  - spec/unit/version_spec.rb
191
+ has_rdoc: true
211
192
  homepage: http://github.com/bigcommerce/bigcommerce-api-ruby
212
193
  licenses: []
194
+
213
195
  post_install_message:
214
196
  rdoc_options: []
215
- require_paths:
197
+
198
+ require_paths:
216
199
  - lib
217
- required_ruby_version: !ruby/object:Gem::Requirement
200
+ required_ruby_version: !ruby/object:Gem::Requirement
218
201
  none: false
219
- requirements:
220
- - - ! '>='
221
- - !ruby/object:Gem::Version
222
- version: '0'
223
- required_rubygems_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ hash: 3
206
+ segments:
207
+ - 0
208
+ version: "0"
209
+ required_rubygems_version: !ruby/object:Gem::Requirement
224
210
  none: false
225
- requirements:
226
- - - ! '>='
227
- - !ruby/object:Gem::Version
228
- version: '0'
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ hash: 3
215
+ segments:
216
+ - 0
217
+ version: "0"
229
218
  requirements: []
219
+
230
220
  rubyforge_project:
231
- rubygems_version: 1.8.23
221
+ rubygems_version: 1.6.2
232
222
  signing_key:
233
223
  specification_version: 3
234
224
  summary: Enables Ruby applications to communicate with the Bigcommerce API
235
- test_files:
225
+ test_files:
236
226
  - spec/big_commerce_spec.rb
237
227
  - spec/integration/orders_spec.rb
238
228
  - spec/unit/api_request_spec.rb
229
+ - spec/unit/api_spec.rb
239
230
  - spec/unit/connection_spec.rb
240
231
  - spec/unit/date_time_spec.rb
241
232
  - spec/unit/version_spec.rb