mad_cart 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mad_cart/store/big_commerce.rb +3 -4
- data/lib/mad_cart/store/o_auth_big_commerce.rb +23 -0
- data/lib/mad_cart/version.rb +1 -1
- data/lib/mad_cart.rb +1 -0
- data/spec/fixtures/vcr_cassettes/o_auth_big_commerce_store.yml +48 -0
- data/spec/lib/store/o_auth_big_commerce_spec.rb +38 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b66da0d2b171917314fcb2ec4901ee401f520a6
|
4
|
+
data.tar.gz: af1fafd0d9e6652b4d8ca9dca05e3123ff25767f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9ab642eed49edc26f61b02979e4145990e56fa0c2ff39bdbb76eca4722f8984e56a23772a321bda3b928b4e27426956f16bcac81c76b8f7d01fc29253db1c4a
|
7
|
+
data.tar.gz: 994a045e6a9188f759a11851b12170f1025ea59c49d631e9e53089f0f544ec587c40025aa984a6c3f53732ecf2c19b5645c3467003ed82450b3d7d7de567a26d
|
@@ -46,13 +46,12 @@ module MadCart
|
|
46
46
|
product_hashes.map do |p|
|
47
47
|
|
48
48
|
product_images = images.find { |i| i.first['product_id'] == p['id'] }
|
49
|
-
|
50
|
-
image = product_images.sort_by{|i| i["sort_order"] }.find { |i| i["is_thumbnail"] }
|
49
|
+
image = product_images.sort_by{|i| i["sort_order"] }.find { |i| i["is_thumbnail"] }
|
51
50
|
|
52
51
|
p.merge({
|
53
52
|
:url => connection.build_url("#{p['custom_url']}").to_s,
|
54
|
-
:image_square_url =>
|
55
|
-
:image_url =>
|
53
|
+
:image_square_url => image.try(:[], "thumbnail_url"),
|
54
|
+
:image_url => image.try(:[], "standard_url")
|
56
55
|
})
|
57
56
|
end
|
58
57
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module MadCart
|
2
|
+
module Store
|
3
|
+
class OAuthBigCommerce < BigCommerce
|
4
|
+
create_connection_with :create_connection, :requires => [:store_hash, :access_token, :client_id]
|
5
|
+
|
6
|
+
def api_url_for(store_hash)
|
7
|
+
"https://api.bigcommerce.com/#{store_hash}/v2/"
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_connection(args={})
|
11
|
+
options = DEFAULT_CONNECTION_OPTIONS.merge(
|
12
|
+
:url => api_url_for(args[:store_hash])
|
13
|
+
)
|
14
|
+
Faraday.new(options) do |connection|
|
15
|
+
connection.headers["X-Auth-Client"] = args[:client_id]
|
16
|
+
connection.headers["X-Auth-Token"] = args[:access_token]
|
17
|
+
connection.response :json
|
18
|
+
connection.adapter Faraday.default_adapter
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/mad_cart/version.rb
CHANGED
data/lib/mad_cart.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.bigcommerce.com/stores/cr4wsh4/v2/store.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
X-Auth-Client:
|
11
|
+
- db7uvk7wc5vstd3f1pw5ma1af13p93n
|
12
|
+
X-Auth-Token:
|
13
|
+
- q3l1fqfz08jqlxtvmavzgr8cjhmqaww
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.9.1
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- "*/*"
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- nginx
|
27
|
+
Date:
|
28
|
+
- Thu, 02 Jul 2015 12:43:32 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '735'
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
35
|
+
X-Bc-Apilimit-Remaining:
|
36
|
+
- '20000'
|
37
|
+
X-Bc-Is-Ha:
|
38
|
+
- '1'
|
39
|
+
X-Bc-Store-Version:
|
40
|
+
- 7.6.0
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"id":"cr4wsh4","domain":"mimi.mybigcommerce.com","name":"","address":"","phone":"","admin_email":"stuart@siyelo.com","order_email":"stuart@siyelo.com","timezone":{"name":"Europe\/London","raw_offset":0,"dst_offset":0,"dst_correction":false,"date_format":{"display":"jS
|
44
|
+
M Y","export":"jS M Y","extended_display":"jS M Y @ g:i A"}},"language":"en","currency":"USD","currency_symbol":"$","decimal_separator":".","thousands_separator":",","decimal_places":2,"currency_symbol_location":"left","weight_units":"LBS","dimension_units":"Inches","dimension_decimal_places":"2","dimension_decimal_token":".","dimension_thousands_token":",","plan_name":"Partner
|
45
|
+
Sandbox","logo":[],"is_price_entered_with_tax":false,"active_comparison_modules":[]}'
|
46
|
+
http_version:
|
47
|
+
recorded_at: Thu, 02 Jul 2015 12:43:41 GMT
|
48
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MadCart::Store::OAuthBigCommerce do
|
4
|
+
|
5
|
+
subject { MadCart::Store::OAuthBigCommerce.new(valid_credentials) }
|
6
|
+
|
7
|
+
let(:valid_credentials) do
|
8
|
+
{
|
9
|
+
:client_id => 'db7uvk7wc5vstd3f1pw5ma1af13p93n',
|
10
|
+
:store_hash => 'stores/cr4wsh4',
|
11
|
+
:access_token => 'q3l1fqfz08jqlxtvmavzgr8cjhmqaww'
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "store" do
|
16
|
+
it "expects to be instantiated with an client id, store hash and access token" do
|
17
|
+
expect{
|
18
|
+
MadCart::Store::OAuthBigCommerce.new(
|
19
|
+
:client_id => 'test', :store_hash => 'test'
|
20
|
+
).connection
|
21
|
+
}.to raise_error(ArgumentError)
|
22
|
+
|
23
|
+
expect{
|
24
|
+
MadCart::Store::OAuthBigCommerce.new(
|
25
|
+
:client_id => 'test', :store_hash => 'test', :access_token => "madeYouLook"
|
26
|
+
).connection
|
27
|
+
}.not_to raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
context "retrieval" do
|
31
|
+
it "returns the store" do
|
32
|
+
VCR.use_cassette('o_auth_big_commerce_store') do
|
33
|
+
subject.store.should_not be_nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mad_cart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Heiligers
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -218,6 +218,7 @@ files:
|
|
218
218
|
- lib/mad_cart/store/base.rb
|
219
219
|
- lib/mad_cart/store/big_commerce.rb
|
220
220
|
- lib/mad_cart/store/etsy.rb
|
221
|
+
- lib/mad_cart/store/o_auth_big_commerce.rb
|
221
222
|
- lib/mad_cart/store/spree.rb
|
222
223
|
- lib/mad_cart/version.rb
|
223
224
|
- mad_cart.gemspec
|
@@ -230,6 +231,7 @@ files:
|
|
230
231
|
- spec/fixtures/vcr_cassettes/big_commerce_time.yml
|
231
232
|
- spec/fixtures/vcr_cassettes/etsy_store_does_not_exist.yml
|
232
233
|
- spec/fixtures/vcr_cassettes/etsy_store_listings.yml
|
234
|
+
- spec/fixtures/vcr_cassettes/o_auth_big_commerce_store.yml
|
233
235
|
- spec/fixtures/vcr_cassettes/spree.yml
|
234
236
|
- spec/fixtures/vcr_cassettes/spree_alternative.yml
|
235
237
|
- spec/fixtures/vcr_cassettes/spree_invalid_key.yml
|
@@ -242,6 +244,7 @@ files:
|
|
242
244
|
- spec/lib/store/base_spec.rb
|
243
245
|
- spec/lib/store/big_commerce_spec.rb
|
244
246
|
- spec/lib/store/etsy_spec.rb
|
247
|
+
- spec/lib/store/o_auth_big_commerce_spec.rb
|
245
248
|
- spec/lib/store/spree_spec.rb
|
246
249
|
- spec/spec_helper.rb
|
247
250
|
homepage: https://github.com/madmimi/mad_cart
|
@@ -264,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
267
|
version: '0'
|
265
268
|
requirements: []
|
266
269
|
rubyforge_project:
|
267
|
-
rubygems_version: 2.
|
270
|
+
rubygems_version: 2.4.3
|
268
271
|
signing_key:
|
269
272
|
specification_version: 4
|
270
273
|
summary: Allows communication with various e-commerce merchants such as BigCommerce
|
@@ -280,6 +283,7 @@ test_files:
|
|
280
283
|
- spec/fixtures/vcr_cassettes/big_commerce_time.yml
|
281
284
|
- spec/fixtures/vcr_cassettes/etsy_store_does_not_exist.yml
|
282
285
|
- spec/fixtures/vcr_cassettes/etsy_store_listings.yml
|
286
|
+
- spec/fixtures/vcr_cassettes/o_auth_big_commerce_store.yml
|
283
287
|
- spec/fixtures/vcr_cassettes/spree.yml
|
284
288
|
- spec/fixtures/vcr_cassettes/spree_alternative.yml
|
285
289
|
- spec/fixtures/vcr_cassettes/spree_invalid_key.yml
|
@@ -292,6 +296,6 @@ test_files:
|
|
292
296
|
- spec/lib/store/base_spec.rb
|
293
297
|
- spec/lib/store/big_commerce_spec.rb
|
294
298
|
- spec/lib/store/etsy_spec.rb
|
299
|
+
- spec/lib/store/o_auth_big_commerce_spec.rb
|
295
300
|
- spec/lib/store/spree_spec.rb
|
296
301
|
- spec/spec_helper.rb
|
297
|
-
has_rdoc:
|