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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1ed7a36224e604c2d21fbeb24428cd76250588f
4
- data.tar.gz: edff25fa0f78b2652c180072dd7f0bc6dacffa63
3
+ metadata.gz: 0b66da0d2b171917314fcb2ec4901ee401f520a6
4
+ data.tar.gz: af1fafd0d9e6652b4d8ca9dca05e3123ff25767f
5
5
  SHA512:
6
- metadata.gz: 80af83d4399e84dd1edec78a6f99355b3fe1a84d4157c50b8ec1ad68b5c678889dcad56b61645e4b8232023b243a8dfaa6edf988ef70e72c12f48a6adf1f10ea
7
- data.tar.gz: dd8b892452b4ee498f055e434de967c9c9d8468ad42845777940a794383debdf5f5f97c7700995c9e3f37d37efcec8e7010499c8c5ae879eebe4764b5a9d27ba
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
- thumbnail = product_images.find { |i| i["is_thumbnail"] }
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 => connection.build_url("/product_images/#{thumbnail['image_file']}").to_s,
55
- :image_url => connection.build_url("/product_images/#{image['image_file']}").to_s
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
@@ -1,3 +1,3 @@
1
1
  module MadCart
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/mad_cart.rb CHANGED
@@ -21,5 +21,6 @@ require 'mad_cart/model/store'
21
21
  # stores
22
22
  require 'mad_cart/store/base'
23
23
  require 'mad_cart/store/big_commerce'
24
+ require 'mad_cart/store/o_auth_big_commerce'
24
25
  require 'mad_cart/store/etsy'
25
26
  require 'mad_cart/store/spree'
@@ -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.9
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-06-01 00:00:00.000000000 Z
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.2.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: