tophatter-merchant 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/Gemfile +1 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/bin/console +1 -1
- data/lib/tophatter_merchant/metadata.rb +18 -16
- data/lib/tophatter_merchant/order.rb +4 -4
- data/lib/tophatter_merchant/product.rb +18 -17
- data/lib/tophatter_merchant/resource.rb +7 -3
- data/lib/tophatter_merchant/variation.rb +3 -1
- data/lib/tophatter_merchant/version.rb +1 -1
- data/lib/tophatter_merchant.rb +1 -4
- data/spec/cassettes/TophatterMerchant_Metadata/_brands/returns_brands.yml +161 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_carriers/returns_carriers.yml +81 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_categories/returns_categories.yml +97 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_colors/returns_colors.yml +67 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_conditions/returns_conditions.yml +67 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_countries/returns_countries.yml +101 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_country_codes/returns_country_codes.yml +119 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_materials/returns_materials.yml +82 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_metadata/returns_metadata.yml +319 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_provinces/returns_provinces.yml +69 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_sizes/returns_sizes.yml +75 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_states/returns_states.yml +78 -0
- data/spec/cassettes/TophatterMerchant_Metadata/_territories/returns_territories.yml +68 -0
- data/spec/cassettes/TophatterMerchant_Order/_all/returns_all_orders.yml +56 -0
- data/spec/cassettes/TophatterMerchant_Order/_fulfill/fulfills_an_order.yml +53 -0
- data/spec/cassettes/TophatterMerchant_Order/_refund/refunds_an_order.yml +53 -0
- data/spec/cassettes/TophatterMerchant_Order/_retrieve/retrieves_an_order.yml +53 -0
- data/spec/cassettes/TophatterMerchant_Order/_schema/returns_the_schema.yml +81 -0
- data/spec/cassettes/TophatterMerchant_Product/_all/returns_all_products.yml +64 -0
- data/spec/cassettes/TophatterMerchant_Product/_create/creates_a_product.yml +53 -0
- data/spec/cassettes/TophatterMerchant_Product/_delete/deletes_a_product.yml +103 -0
- data/spec/cassettes/TophatterMerchant_Product/_disable/disables_a_product.yml +103 -0
- data/spec/cassettes/TophatterMerchant_Product/_enable/enables_a_product.yml +103 -0
- data/spec/cassettes/TophatterMerchant_Product/_retrieve/retrieves_a_product.yml +53 -0
- data/spec/cassettes/TophatterMerchant_Product/_schema/returns_the_schema.yml +124 -0
- data/spec/cassettes/TophatterMerchant_Product/_search/returns_products_matching_search_terms.yml +57 -0
- data/spec/cassettes/TophatterMerchant_Product/_update/updates_a_product.yml +103 -0
- data/spec/cassettes/TophatterMerchant_Variation/_create/creates_a_variation.yml +50 -0
- data/spec/cassettes/TophatterMerchant_Variation/_retrieve/retrieves_a_variation.yml +50 -0
- data/spec/cassettes/TophatterMerchant_Variation/_schema/returns_the_schema.yml +61 -0
- data/spec/cassettes/TophatterMerchant_Variation/_update/updates_a_variation.yml +97 -0
- data/spec/spec_helper.rb +6 -18
- data/spec/tophatter_merchant/metadata_spec.rb +111 -30
- data/spec/tophatter_merchant/order_spec.rb +55 -0
- data/spec/tophatter_merchant/product_spec.rb +102 -3
- data/spec/tophatter_merchant/variation_spec.rb +47 -0
- metadata +68 -10
- data/CHANGELOG +0 -3
- data/lib/tophatter_merchant/account.rb +0 -47
- data/lib/tophatter_merchant/api_key.rb +0 -42
- data/lib/tophatter_merchant/exceptions.rb +0 -8
- data/lib/tophatter_merchant/image.rb +0 -21
- data/tmp/stubs/metadata/conditions.json +0 -12
- data/tmp/stubs/metadata/gemstones.json +0 -12
- data/tmp/stubs/metadata.json +0 -12
@@ -0,0 +1,97 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://tophatter.dev/merchant_api/v1/variations/update.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: quantity=99&identifier=CT1-S&access_token=293da6763df7cb3b894a1831addcb52d
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*; q=0.5, application/xml"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Content-Length:
|
15
|
+
- '74'
|
16
|
+
Content-Type:
|
17
|
+
- application/x-www-form-urlencoded
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
X-Frame-Options:
|
26
|
+
- SAMEORIGIN
|
27
|
+
X-Xss-Protection:
|
28
|
+
- 1; mode=block
|
29
|
+
X-Content-Type-Options:
|
30
|
+
- nosniff
|
31
|
+
Content-Type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
Etag:
|
34
|
+
- W/"b537e3016e70441a3ae79b844c96e772"
|
35
|
+
Cache-Control:
|
36
|
+
- max-age=0, private, must-revalidate
|
37
|
+
X-Request-Id:
|
38
|
+
- 8aeeb437-17bf-4b9a-85d7-9531242afe7f
|
39
|
+
X-Runtime:
|
40
|
+
- '0.034810'
|
41
|
+
Date:
|
42
|
+
- Sat, 25 Mar 2017 22:51:01 GMT
|
43
|
+
Connection:
|
44
|
+
- close
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"product_identifier":"C-T-1","identifier":"CT1-S","size":"S","color":null,"quantity":99,"created_at":"2017-03-25T15:17:23-07:00"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Sat, 25 Mar 2017 22:51:01 GMT
|
50
|
+
- request:
|
51
|
+
method: post
|
52
|
+
uri: http://tophatter.dev/merchant_api/v1/variations/update.json
|
53
|
+
body:
|
54
|
+
encoding: UTF-8
|
55
|
+
string: quantity=999&identifier=CT1-S&access_token=293da6763df7cb3b894a1831addcb52d
|
56
|
+
headers:
|
57
|
+
Accept:
|
58
|
+
- "*/*; q=0.5, application/xml"
|
59
|
+
Accept-Encoding:
|
60
|
+
- gzip, deflate
|
61
|
+
Content-Length:
|
62
|
+
- '75'
|
63
|
+
Content-Type:
|
64
|
+
- application/x-www-form-urlencoded
|
65
|
+
User-Agent:
|
66
|
+
- Ruby
|
67
|
+
response:
|
68
|
+
status:
|
69
|
+
code: 200
|
70
|
+
message: OK
|
71
|
+
headers:
|
72
|
+
X-Frame-Options:
|
73
|
+
- SAMEORIGIN
|
74
|
+
X-Xss-Protection:
|
75
|
+
- 1; mode=block
|
76
|
+
X-Content-Type-Options:
|
77
|
+
- nosniff
|
78
|
+
Content-Type:
|
79
|
+
- application/json; charset=utf-8
|
80
|
+
Etag:
|
81
|
+
- W/"c8a1f6ecccd46d2a313a1f258f8ba01b"
|
82
|
+
Cache-Control:
|
83
|
+
- max-age=0, private, must-revalidate
|
84
|
+
X-Request-Id:
|
85
|
+
- 9b1958b3-04f6-479b-b893-dbbef05d0686
|
86
|
+
X-Runtime:
|
87
|
+
- '0.035316'
|
88
|
+
Date:
|
89
|
+
- Sat, 25 Mar 2017 22:51:01 GMT
|
90
|
+
Connection:
|
91
|
+
- close
|
92
|
+
body:
|
93
|
+
encoding: UTF-8
|
94
|
+
string: '{"product_identifier":"C-T-1","identifier":"CT1-S","size":"S","color":null,"quantity":999,"created_at":"2017-03-25T15:17:23-07:00"}'
|
95
|
+
http_version:
|
96
|
+
recorded_at: Sat, 25 Mar 2017 22:51:01 GMT
|
97
|
+
recorded_with: VCR 3.0.3
|
data/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,10 @@
|
|
1
1
|
require 'rest-client'
|
2
|
+
require 'awesome_print'
|
2
3
|
require 'tophatter_merchant'
|
3
|
-
require '
|
4
|
+
require 'vcr'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
config.expect_with :rspec do |expectations|
|
10
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
11
|
-
end
|
12
|
-
|
13
|
-
config.mock_with :rspec do |mocks|
|
14
|
-
mocks.verify_partial_doubles = true
|
15
|
-
end
|
16
|
-
|
17
|
-
config.before(:each) do
|
18
|
-
stub_request(:get, /.*metadata\.json/).to_return(File.new(File.dirname(__FILE__) + '/../tmp/stubs/metadata.json'))
|
19
|
-
stub_request(:get, /.*conditions\.json/).to_return(File.new(File.dirname(__FILE__) + '/../tmp/stubs/metadata/conditions.json'))
|
20
|
-
stub_request(:get, /.*gemstones\.json/).to_return(File.new(File.dirname(__FILE__) + '/../tmp/stubs/metadata/gemstones.json'))
|
21
|
-
end
|
6
|
+
VCR.configure do |c|
|
7
|
+
c.cassette_library_dir = 'spec/cassettes'
|
8
|
+
c.hook_into :webmock
|
9
|
+
c.configure_rspec_metadata!
|
22
10
|
end
|
@@ -2,35 +2,116 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
# rspec spec/tophatter_merchant/metadata_spec.rb
|
4
4
|
describe TophatterMerchant::Metadata do
|
5
|
-
|
6
|
-
metadata
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
5
|
+
describe '.metadata' do
|
6
|
+
it 'returns metadata', :vcr do
|
7
|
+
result = TophatterMerchant::Metadata.all
|
8
|
+
expect(result.keys.include?('categories')).to be(true)
|
9
|
+
expect(result.keys.include?('conditions')).to be(true)
|
10
|
+
expect(result.keys.include?('brands')).to be(true)
|
11
|
+
expect(result.keys.include?('materials')).to be(true)
|
12
|
+
expect(result.keys.include?('sizes')).to be(true)
|
13
|
+
expect(result.keys.include?('colors')).to be(true)
|
14
|
+
expect(result.keys.include?('countries')).to be(true)
|
15
|
+
expect(result.keys.include?('country_codes')).to be(true)
|
16
|
+
expect(result.keys.include?('states')).to be(true)
|
17
|
+
expect(result.keys.include?('provinces')).to be(true)
|
18
|
+
expect(result.keys.include?('territories')).to be(true)
|
19
|
+
expect(result.keys.include?('carriers')).to be(true)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.categories' do
|
24
|
+
it 'returns categories', :vcr do
|
25
|
+
result = TophatterMerchant::Metadata.categories
|
26
|
+
expect(result.include?('Apparel | Swim | Tops')).to be(true)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.conditions' do
|
31
|
+
it 'returns conditions', :vcr do
|
32
|
+
result = TophatterMerchant::Metadata.conditions
|
33
|
+
expect(result.include?('New')).to be(true)
|
34
|
+
expect(result.include?('New with Tags')).to be(true)
|
35
|
+
expect(result.include?('New with Defects')).to be(true)
|
36
|
+
expect(result.include?('Used')).to be(true)
|
37
|
+
expect(result.include?('Refurbished')).to be(true)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '.brands' do
|
42
|
+
it 'returns brands', :vcr do
|
43
|
+
result = TophatterMerchant::Metadata.brands
|
44
|
+
expect(result.key?('Home')).to be(true)
|
45
|
+
expect(result['Home'].include?('Ninja')).to be(true)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '.materials' do
|
50
|
+
it 'returns materials', :vcr do
|
51
|
+
result = TophatterMerchant::Metadata.materials
|
52
|
+
expect(result.key?('Gemstones')).to be(true)
|
53
|
+
expect(result['Gemstones'].include?('Star Ruby')).to be(true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '.sizes' do
|
58
|
+
it 'returns sizes', :vcr do
|
59
|
+
result = TophatterMerchant::Metadata.sizes
|
60
|
+
expect(result.key?('Accessories')).to be(true)
|
61
|
+
expect(result['Accessories'].include?('Small')).to be(true)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '.colors' do
|
66
|
+
it 'returns colors', :vcr do
|
67
|
+
result = TophatterMerchant::Metadata.colors
|
68
|
+
expect(result.include?('Red')).to be(true)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '.countries' do
|
73
|
+
it 'returns countries', :vcr do
|
74
|
+
result = TophatterMerchant::Metadata.countries
|
75
|
+
expect(result.include?('United States')).to be(true)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '.country_codes' do
|
80
|
+
it 'returns country codes', :vcr do
|
81
|
+
result = TophatterMerchant::Metadata.country_codes
|
82
|
+
expect(result.key?('United States')).to be(true)
|
83
|
+
expect(result['United States']).to eq('USA')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '.states' do
|
88
|
+
it 'returns states', :vcr do
|
89
|
+
result = TophatterMerchant::Metadata.states
|
90
|
+
expect(result.key?('California')).to be(true)
|
91
|
+
expect(result['California']).to eq('CA')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '.provinces' do
|
96
|
+
it 'returns provinces', :vcr do
|
97
|
+
result = TophatterMerchant::Metadata.provinces
|
98
|
+
expect(result.key?('Alberta')).to be(true)
|
99
|
+
expect(result['Alberta']).to eq('AB')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '.territories' do
|
104
|
+
it 'returns territories', :vcr do
|
105
|
+
result = TophatterMerchant::Metadata.territories
|
106
|
+
expect(result.key?('New South Wales')).to be(true)
|
107
|
+
expect(result['New South Wales']).to eq('NSW')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '.carriers' do
|
112
|
+
it 'returns carriers', :vcr do
|
113
|
+
result = TophatterMerchant::Metadata.carriers
|
114
|
+
expect(result.key?('USPS')).to be(true)
|
115
|
+
end
|
35
116
|
end
|
36
117
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# rspec spec/tophatter_merchant/order_spec.rb
|
4
|
+
describe TophatterMerchant::Order do
|
5
|
+
before :each do
|
6
|
+
TophatterMerchant.api_path = 'http://tophatter.dev/merchant_api/v1'
|
7
|
+
TophatterMerchant.access_token = 'c574bc2f5f4e9da1975e7ae1103eea24'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.schema', :vcr do
|
11
|
+
it 'returns the schema' do
|
12
|
+
schema = TophatterMerchant::Order.schema
|
13
|
+
expect(schema.find { |component| component['field'] == 'order_id' }['name']).to eq('Order ID')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.all' do
|
18
|
+
it 'returns all orders', :vcr do
|
19
|
+
orders = TophatterMerchant::Order.all
|
20
|
+
expect(orders.length).to be(2)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.retrieve' do
|
25
|
+
it 'retrieves an order', :vcr do
|
26
|
+
order = TophatterMerchant::Order.retrieve(359887509)
|
27
|
+
expect(order.order_id).to eq(359887509)
|
28
|
+
expect(order.status).to eq('paid')
|
29
|
+
expect(order.product_identifier).to eq('DEFAULT')
|
30
|
+
expect(order.customer_id).to eq(981984628)
|
31
|
+
expect(order.customer_name).to eq('Optimus Prime')
|
32
|
+
expect(order.address1).to eq('201 Valley Street')
|
33
|
+
expect(order.city).to eq('Los Altos')
|
34
|
+
expect(order.state).to eq('CA')
|
35
|
+
expect(order.postal_code).to eq('94022')
|
36
|
+
expect(order.country).to eq('United States')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.fulfill' do
|
41
|
+
it 'fulfills an order', :vcr do
|
42
|
+
order = TophatterMerchant::Order.fulfill(359887509, carrier: 'USPS', tracking_number: 'CX263292019US')
|
43
|
+
expect(order.status).to eq('shipped')
|
44
|
+
expect(order.carrier).to eq('usps')
|
45
|
+
expect(order.tracking_number).to eq('CX263292019US')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '.refund' do
|
50
|
+
it 'refunds an order', :vcr do
|
51
|
+
order = TophatterMerchant::Order.refund(359887509, type: 'partial', reason: 'delay_in_shipping', fees: ['shipping_fee'])
|
52
|
+
expect(order.available_refunds).to eq('buyer_fee' => 399.0)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -2,8 +2,107 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
# rspec spec/tophatter_merchant/product_spec.rb
|
4
4
|
describe TophatterMerchant::Product do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
before :each do
|
6
|
+
TophatterMerchant.api_path = 'http://tophatter.dev/merchant_api/v1'
|
7
|
+
TophatterMerchant.access_token = '293da6763df7cb3b894a1831addcb52d'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.schema' do
|
11
|
+
it 'returns the schema', :vcr do
|
12
|
+
schema = TophatterMerchant::Product.schema
|
13
|
+
expect(schema.find { |component| component['field'] == 'identifier' }['name']).to eq('Unique ID')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.all' do
|
18
|
+
it 'returns all products', :vcr do
|
19
|
+
products = TophatterMerchant::Product.all(page: 1, per_page: 5)
|
20
|
+
expect(products.length).to be(5)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.search' do
|
25
|
+
it 'returns products matching search terms', :vcr do
|
26
|
+
products = TophatterMerchant::Product.search(query: 'Cute', page: 1, per_page: 5)
|
27
|
+
expect(products.first.title.include?('Cute')).to be(true)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.retrieve' do
|
32
|
+
it 'retrieves a product', :vcr do
|
33
|
+
product = TophatterMerchant::Product.retrieve('PFTBNU5')
|
34
|
+
expect(product.identifier).to eq('PFTBNU5')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '.create' do
|
39
|
+
it 'creates a product', :vcr do
|
40
|
+
product = TophatterMerchant::Product.create(
|
41
|
+
identifier: '6631A',
|
42
|
+
category: 'Electronics|Hardware (Computers/Tablets/Phones)|Mobile',
|
43
|
+
title: 'Apple iPhone 6S',
|
44
|
+
description: 'This is the description.',
|
45
|
+
condition: 'Refurbished - Manufacturer',
|
46
|
+
starting_bid: 1,
|
47
|
+
buy_now_price: 150,
|
48
|
+
cost_basis: 75,
|
49
|
+
shipping_price: 5.0,
|
50
|
+
success_fee_bid: 0.5,
|
51
|
+
shipping_origin: 'United States',
|
52
|
+
weight: 6,
|
53
|
+
days_to_fulfill: 3,
|
54
|
+
days_to_deliver: 5,
|
55
|
+
variations: {
|
56
|
+
'6631A-WHITE': {
|
57
|
+
identifier: '6631A-WHITE',
|
58
|
+
color: 'White', quantity: 1
|
59
|
+
},
|
60
|
+
'6631A-BLACK': {
|
61
|
+
identifier: '6631A-BLACK',
|
62
|
+
color: 'Black', quantity: 2
|
63
|
+
}
|
64
|
+
},
|
65
|
+
primary_image: 'https://d38eepresuu519.cloudfront.net/b2aa7d2708324f756ffee551ba43a74f/original.jpg',
|
66
|
+
extra_images: 'https://d38eepresuu519.cloudfront.net/e615c55184c06f391dbd768f855904e6/original.jpg|https://d38eepresuu519.cloudfront.net/7cd125f0fa42c965675eabaf3309aa6d/original.jpg'
|
67
|
+
)
|
68
|
+
expect(product.persisted?).to be(true)
|
69
|
+
expect(product.identifier).to eq('6631A')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '.update' do
|
74
|
+
it 'updates a product', :vcr do
|
75
|
+
product = TophatterMerchant::Product.retrieve('PFTBNU5')
|
76
|
+
expect(product.buy_now_price).to eq(399)
|
77
|
+
product = TophatterMerchant::Product.update('PFTBNU5', buy_now_price: 100)
|
78
|
+
expect(product.buy_now_price).to eq(100)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '.disable' do
|
83
|
+
it 'disables a product', :vcr do
|
84
|
+
product = TophatterMerchant::Product.enable('PFTBNU5')
|
85
|
+
expect(product.disabled_at.nil?).to be(true)
|
86
|
+
product = TophatterMerchant::Product.disable('PFTBNU5')
|
87
|
+
expect(product.disabled_at.present?).to be(true)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '.enable' do
|
92
|
+
it 'enables a product', :vcr do
|
93
|
+
product = TophatterMerchant::Product.disable('PFTBNU5')
|
94
|
+
expect(product.disabled_at.present?).to be(true)
|
95
|
+
product = TophatterMerchant::Product.enable('PFTBNU5')
|
96
|
+
expect(product.disabled_at.nil?).to be(true)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '.delete' do
|
101
|
+
it 'deletes a product', :vcr do
|
102
|
+
product = TophatterMerchant::Product.retrieve('6631A')
|
103
|
+
expect(product.deleted_at.nil?).to be(true)
|
104
|
+
product = TophatterMerchant::Product.delete('6631A')
|
105
|
+
expect(product.deleted_at.present?).to be(true)
|
106
|
+
end
|
8
107
|
end
|
9
108
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# rspec spec/tophatter_merchant/variation_spec.rb
|
4
|
+
describe TophatterMerchant::Variation do
|
5
|
+
before :each do
|
6
|
+
TophatterMerchant.api_path = 'http://tophatter.dev/merchant_api/v1'
|
7
|
+
TophatterMerchant.access_token = '293da6763df7cb3b894a1831addcb52d'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.schema', :vcr do
|
11
|
+
it 'returns the schema' do
|
12
|
+
schema = TophatterMerchant::Variation.schema
|
13
|
+
expect(schema.find { |component| component['field'] == 'identifier' }['name']).to eq('Variation Unique ID (SKU)')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.retrieve' do
|
18
|
+
it 'retrieves a variation', :vcr do
|
19
|
+
variation = TophatterMerchant::Variation.retrieve('CT1-S')
|
20
|
+
expect(variation.identifier).to eq('CT1-S')
|
21
|
+
expect(variation.size).to eq('S')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.create' do
|
26
|
+
it 'creates a variation', :vcr do
|
27
|
+
variation = TophatterMerchant::Variation.create(
|
28
|
+
product_identifier: 'C-T-1',
|
29
|
+
identifier: 'CT1-M',
|
30
|
+
size: 'M',
|
31
|
+
quantity: 99
|
32
|
+
)
|
33
|
+
expect(variation.identifier).to eq('CT1-M')
|
34
|
+
expect(variation.size).to eq('M')
|
35
|
+
expect(variation.quantity).to eq(99)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '.update' do
|
40
|
+
it 'updates a variation', :vcr do
|
41
|
+
variation = TophatterMerchant::Variation.update('CT1-S', quantity: 99)
|
42
|
+
expect(variation.quantity).to eq(99)
|
43
|
+
variation = TophatterMerchant::Variation.update('CT1-S', quantity: 999)
|
44
|
+
expect(variation.quantity).to eq(999)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tophatter-merchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Estreich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -50,29 +50,54 @@ files:
|
|
50
50
|
- ".gitignore"
|
51
51
|
- ".rspec"
|
52
52
|
- ".rubocop.yml"
|
53
|
-
- CHANGELOG
|
54
53
|
- Gemfile
|
55
54
|
- LICENSE
|
56
55
|
- README.md
|
57
56
|
- VERSION
|
58
57
|
- bin/console
|
59
58
|
- lib/tophatter_merchant.rb
|
60
|
-
- lib/tophatter_merchant/account.rb
|
61
|
-
- lib/tophatter_merchant/api_key.rb
|
62
|
-
- lib/tophatter_merchant/exceptions.rb
|
63
|
-
- lib/tophatter_merchant/image.rb
|
64
59
|
- lib/tophatter_merchant/metadata.rb
|
65
60
|
- lib/tophatter_merchant/order.rb
|
66
61
|
- lib/tophatter_merchant/product.rb
|
67
62
|
- lib/tophatter_merchant/resource.rb
|
68
63
|
- lib/tophatter_merchant/variation.rb
|
69
64
|
- lib/tophatter_merchant/version.rb
|
65
|
+
- spec/cassettes/TophatterMerchant_Metadata/_brands/returns_brands.yml
|
66
|
+
- spec/cassettes/TophatterMerchant_Metadata/_carriers/returns_carriers.yml
|
67
|
+
- spec/cassettes/TophatterMerchant_Metadata/_categories/returns_categories.yml
|
68
|
+
- spec/cassettes/TophatterMerchant_Metadata/_colors/returns_colors.yml
|
69
|
+
- spec/cassettes/TophatterMerchant_Metadata/_conditions/returns_conditions.yml
|
70
|
+
- spec/cassettes/TophatterMerchant_Metadata/_countries/returns_countries.yml
|
71
|
+
- spec/cassettes/TophatterMerchant_Metadata/_country_codes/returns_country_codes.yml
|
72
|
+
- spec/cassettes/TophatterMerchant_Metadata/_materials/returns_materials.yml
|
73
|
+
- spec/cassettes/TophatterMerchant_Metadata/_metadata/returns_metadata.yml
|
74
|
+
- spec/cassettes/TophatterMerchant_Metadata/_provinces/returns_provinces.yml
|
75
|
+
- spec/cassettes/TophatterMerchant_Metadata/_sizes/returns_sizes.yml
|
76
|
+
- spec/cassettes/TophatterMerchant_Metadata/_states/returns_states.yml
|
77
|
+
- spec/cassettes/TophatterMerchant_Metadata/_territories/returns_territories.yml
|
78
|
+
- spec/cassettes/TophatterMerchant_Order/_all/returns_all_orders.yml
|
79
|
+
- spec/cassettes/TophatterMerchant_Order/_fulfill/fulfills_an_order.yml
|
80
|
+
- spec/cassettes/TophatterMerchant_Order/_refund/refunds_an_order.yml
|
81
|
+
- spec/cassettes/TophatterMerchant_Order/_retrieve/retrieves_an_order.yml
|
82
|
+
- spec/cassettes/TophatterMerchant_Order/_schema/returns_the_schema.yml
|
83
|
+
- spec/cassettes/TophatterMerchant_Product/_all/returns_all_products.yml
|
84
|
+
- spec/cassettes/TophatterMerchant_Product/_create/creates_a_product.yml
|
85
|
+
- spec/cassettes/TophatterMerchant_Product/_delete/deletes_a_product.yml
|
86
|
+
- spec/cassettes/TophatterMerchant_Product/_disable/disables_a_product.yml
|
87
|
+
- spec/cassettes/TophatterMerchant_Product/_enable/enables_a_product.yml
|
88
|
+
- spec/cassettes/TophatterMerchant_Product/_retrieve/retrieves_a_product.yml
|
89
|
+
- spec/cassettes/TophatterMerchant_Product/_schema/returns_the_schema.yml
|
90
|
+
- spec/cassettes/TophatterMerchant_Product/_search/returns_products_matching_search_terms.yml
|
91
|
+
- spec/cassettes/TophatterMerchant_Product/_update/updates_a_product.yml
|
92
|
+
- spec/cassettes/TophatterMerchant_Variation/_create/creates_a_variation.yml
|
93
|
+
- spec/cassettes/TophatterMerchant_Variation/_retrieve/retrieves_a_variation.yml
|
94
|
+
- spec/cassettes/TophatterMerchant_Variation/_schema/returns_the_schema.yml
|
95
|
+
- spec/cassettes/TophatterMerchant_Variation/_update/updates_a_variation.yml
|
70
96
|
- spec/spec_helper.rb
|
71
97
|
- spec/tophatter_merchant/metadata_spec.rb
|
98
|
+
- spec/tophatter_merchant/order_spec.rb
|
72
99
|
- spec/tophatter_merchant/product_spec.rb
|
73
|
-
-
|
74
|
-
- tmp/stubs/metadata/conditions.json
|
75
|
-
- tmp/stubs/metadata/gemstones.json
|
100
|
+
- spec/tophatter_merchant/variation_spec.rb
|
76
101
|
- tophatter-merchant.gemspec
|
77
102
|
homepage: https://github.com/tophatter/merchant-api-ruby
|
78
103
|
licenses:
|
@@ -99,6 +124,39 @@ signing_key:
|
|
99
124
|
specification_version: 4
|
100
125
|
summary: Manage your inventory and fulfill orders on Tophatter.
|
101
126
|
test_files:
|
127
|
+
- spec/cassettes/TophatterMerchant_Metadata/_brands/returns_brands.yml
|
128
|
+
- spec/cassettes/TophatterMerchant_Metadata/_carriers/returns_carriers.yml
|
129
|
+
- spec/cassettes/TophatterMerchant_Metadata/_categories/returns_categories.yml
|
130
|
+
- spec/cassettes/TophatterMerchant_Metadata/_colors/returns_colors.yml
|
131
|
+
- spec/cassettes/TophatterMerchant_Metadata/_conditions/returns_conditions.yml
|
132
|
+
- spec/cassettes/TophatterMerchant_Metadata/_countries/returns_countries.yml
|
133
|
+
- spec/cassettes/TophatterMerchant_Metadata/_country_codes/returns_country_codes.yml
|
134
|
+
- spec/cassettes/TophatterMerchant_Metadata/_materials/returns_materials.yml
|
135
|
+
- spec/cassettes/TophatterMerchant_Metadata/_metadata/returns_metadata.yml
|
136
|
+
- spec/cassettes/TophatterMerchant_Metadata/_provinces/returns_provinces.yml
|
137
|
+
- spec/cassettes/TophatterMerchant_Metadata/_sizes/returns_sizes.yml
|
138
|
+
- spec/cassettes/TophatterMerchant_Metadata/_states/returns_states.yml
|
139
|
+
- spec/cassettes/TophatterMerchant_Metadata/_territories/returns_territories.yml
|
140
|
+
- spec/cassettes/TophatterMerchant_Order/_all/returns_all_orders.yml
|
141
|
+
- spec/cassettes/TophatterMerchant_Order/_fulfill/fulfills_an_order.yml
|
142
|
+
- spec/cassettes/TophatterMerchant_Order/_refund/refunds_an_order.yml
|
143
|
+
- spec/cassettes/TophatterMerchant_Order/_retrieve/retrieves_an_order.yml
|
144
|
+
- spec/cassettes/TophatterMerchant_Order/_schema/returns_the_schema.yml
|
145
|
+
- spec/cassettes/TophatterMerchant_Product/_all/returns_all_products.yml
|
146
|
+
- spec/cassettes/TophatterMerchant_Product/_create/creates_a_product.yml
|
147
|
+
- spec/cassettes/TophatterMerchant_Product/_delete/deletes_a_product.yml
|
148
|
+
- spec/cassettes/TophatterMerchant_Product/_disable/disables_a_product.yml
|
149
|
+
- spec/cassettes/TophatterMerchant_Product/_enable/enables_a_product.yml
|
150
|
+
- spec/cassettes/TophatterMerchant_Product/_retrieve/retrieves_a_product.yml
|
151
|
+
- spec/cassettes/TophatterMerchant_Product/_schema/returns_the_schema.yml
|
152
|
+
- spec/cassettes/TophatterMerchant_Product/_search/returns_products_matching_search_terms.yml
|
153
|
+
- spec/cassettes/TophatterMerchant_Product/_update/updates_a_product.yml
|
154
|
+
- spec/cassettes/TophatterMerchant_Variation/_create/creates_a_variation.yml
|
155
|
+
- spec/cassettes/TophatterMerchant_Variation/_retrieve/retrieves_a_variation.yml
|
156
|
+
- spec/cassettes/TophatterMerchant_Variation/_schema/returns_the_schema.yml
|
157
|
+
- spec/cassettes/TophatterMerchant_Variation/_update/updates_a_variation.yml
|
102
158
|
- spec/spec_helper.rb
|
103
159
|
- spec/tophatter_merchant/metadata_spec.rb
|
160
|
+
- spec/tophatter_merchant/order_spec.rb
|
104
161
|
- spec/tophatter_merchant/product_spec.rb
|
162
|
+
- spec/tophatter_merchant/variation_spec.rb
|
data/CHANGELOG
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module TophatterMerchant
|
2
|
-
class Account < Resource
|
3
|
-
attr_accessor :access_token, :first_name, :last_name, :store_name, :email, :country, :time_zone
|
4
|
-
|
5
|
-
def id
|
6
|
-
email
|
7
|
-
end
|
8
|
-
|
9
|
-
class << self
|
10
|
-
# ap TophatterMerchant::Account.schema
|
11
|
-
def schema
|
12
|
-
get(url: "#{path}/schema.json")
|
13
|
-
end
|
14
|
-
|
15
|
-
# ap TophatterMerchant::Account.authenticate(email: 'megatron@autobot.com', password: 'ipipip').to_h
|
16
|
-
def authenticate(email:, password:)
|
17
|
-
Account.new post(url: "#{path}/authenticate.json", params: { email: email, password: password })
|
18
|
-
end
|
19
|
-
|
20
|
-
# ap TophatterMerchant::Account.me.to_h
|
21
|
-
def me
|
22
|
-
Account.new get(url: "#{path}/me.json")
|
23
|
-
end
|
24
|
-
|
25
|
-
# ap TophatterMerchant::Account.create(first_name: 'Foo', last_name: 'Bar', store_name: 'Foo Bar, Inc', email: 'foo@bar.com', password: 'ipipip', country: 'United States', time_zone: 'Pacific Time (US & Canada)').to_h
|
26
|
-
def create(data)
|
27
|
-
Account.new post(url: "#{path}.json", params: data)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Change first & last name:
|
31
|
-
# ap TophatterMerchant::Account.update(first_name: 'Mega', last_name: 'Tron').to_h
|
32
|
-
# Change password:
|
33
|
-
# ap TophatterMerchant::Account.update(password: 'qwer1234').to_h
|
34
|
-
# ap TophatterMerchant::Account.authenticate(email: 'megatron@autobot.com', password: 'qwer1234').to_h
|
35
|
-
# ap TophatterMerchant::Account.update(password: 'ipipip').to_h
|
36
|
-
def update(data)
|
37
|
-
Account.new post(url: "#{path}/update.json", params: data)
|
38
|
-
end
|
39
|
-
|
40
|
-
protected
|
41
|
-
|
42
|
-
def path
|
43
|
-
super + '/account'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|