bigcommerce 0.10.0 → 1.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.rubocop.yml +620 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +119 -0
- data/DEPENDENCIES.md +7 -0
- data/Gemfile +15 -0
- data/Guardfile +22 -0
- data/LICENSE +15 -15
- data/README.md +61 -70
- data/RELEASING.md +64 -0
- data/Rakefile +8 -6
- data/bigcommerce.gemspec +22 -53
- data/examples/README.md +148 -0
- data/examples/configuration/legacy_auth.rb +12 -0
- data/examples/configuration/oauth.rb +9 -0
- data/examples/content/blog_post.rb +39 -0
- data/examples/content/blog_tag.rb +10 -0
- data/examples/content/redirect.rb +43 -0
- data/examples/customers/customer.rb +36 -0
- data/examples/customers/customer_address.rb +50 -0
- data/examples/customers/customer_group.rb +35 -0
- data/examples/exception_handling.rb +50 -0
- data/examples/geography/country.rb +16 -0
- data/examples/geography/state.rb +19 -0
- data/examples/marketing/coupon.rb +44 -0
- data/examples/orders/order.rb +53 -0
- data/examples/orders/order_coupon.rb +17 -0
- data/examples/orders/order_message.rb +17 -0
- data/examples/orders/order_product.rb +23 -0
- data/examples/orders/order_shipping_address.rb +23 -0
- data/examples/orders/order_status.rb +15 -0
- data/examples/orders/order_tax.rb +17 -0
- data/examples/orders/shipment.rb +57 -0
- data/examples/payments/payment_method.rb +10 -0
- data/examples/products/brand.rb +36 -0
- data/examples/products/bulk_pricing_rule.rb +47 -0
- data/examples/products/category.rb +37 -0
- data/examples/products/configurable_field.rb +29 -0
- data/examples/products/custom_field.rb +44 -0
- data/examples/products/google_product_search_mapping.rb +12 -0
- data/examples/products/option.rb +37 -0
- data/examples/products/option_set.rb +35 -0
- data/examples/products/option_set_option.rb +50 -0
- data/examples/products/option_value.rb +43 -0
- data/examples/products/product.rb +44 -0
- data/examples/products/product_image.rb +42 -0
- data/examples/products/product_option.rb +17 -0
- data/examples/products/product_review.rb +12 -0
- data/examples/products/product_rule.rb +54 -0
- data/examples/products/product_video.rb +45 -0
- data/examples/products/sku.rb +48 -0
- data/examples/shipping/shipping_method.rb +13 -0
- data/examples/store/store_info.rb +10 -0
- data/examples/system/time.rb +10 -0
- data/examples/tax/tax_class.rb +13 -0
- data/examples/webhooks/webhook.rb +29 -0
- data/lib/bigcommerce.rb +50 -8
- data/lib/bigcommerce/exception.rb +51 -0
- data/lib/bigcommerce/middleware/auth.rb +16 -0
- data/lib/bigcommerce/middleware/http_exception.rb +14 -0
- data/lib/bigcommerce/request.rb +89 -0
- data/lib/bigcommerce/resource_actions.rb +51 -0
- data/lib/bigcommerce/resources/content/blog_post.rb +31 -0
- data/lib/bigcommerce/resources/content/blog_tag.rb +17 -0
- data/lib/bigcommerce/resources/content/redirect.rb +21 -0
- data/lib/bigcommerce/resources/customers/customer.rb +30 -0
- data/lib/bigcommerce/resources/customers/customer_address.rb +34 -0
- data/lib/bigcommerce/resources/customers/customer_group.rb +21 -0
- data/lib/bigcommerce/resources/geography/country.rb +22 -0
- data/lib/bigcommerce/resources/geography/state.rb +25 -0
- data/lib/bigcommerce/resources/marketing/coupon.rb +30 -0
- data/lib/bigcommerce/resources/orders/order.rb +73 -0
- data/lib/bigcommerce/resources/orders/order_coupon.rb +20 -0
- data/lib/bigcommerce/resources/orders/order_message.rb +23 -0
- data/lib/bigcommerce/resources/orders/order_product.rb +64 -0
- data/lib/bigcommerce/resources/orders/order_shipping_address.rb +50 -0
- data/lib/bigcommerce/resources/orders/order_status.rb +16 -0
- data/lib/bigcommerce/resources/orders/order_tax.rb +23 -0
- data/lib/bigcommerce/resources/orders/shipment.rb +30 -0
- data/lib/bigcommerce/resources/payments/payment_method.rb +17 -0
- data/lib/bigcommerce/resources/products/brand.rb +23 -0
- data/lib/bigcommerce/resources/products/bulk_pricing_rule.rb +26 -0
- data/lib/bigcommerce/resources/products/category.rb +29 -0
- data/lib/bigcommerce/resources/products/configurable_field.rb +30 -0
- data/lib/bigcommerce/resources/products/custom_field.rb +24 -0
- data/lib/bigcommerce/resources/products/google_product_search_mapping.rb +26 -0
- data/lib/bigcommerce/resources/products/option.rb +20 -0
- data/lib/bigcommerce/resources/products/option_set.rb +18 -0
- data/lib/bigcommerce/resources/products/option_set_option.rb +19 -0
- data/lib/bigcommerce/resources/products/option_value.rb +15 -0
- data/lib/bigcommerce/resources/products/product.rb +97 -0
- data/lib/bigcommerce/resources/products/product_image.rb +31 -0
- data/lib/bigcommerce/resources/products/product_option.rb +17 -0
- data/lib/bigcommerce/resources/products/product_review.rb +22 -0
- data/lib/bigcommerce/resources/products/product_rule.rb +31 -0
- data/lib/bigcommerce/resources/products/product_video.rb +24 -0
- data/lib/bigcommerce/resources/products/sku.rb +29 -0
- data/lib/bigcommerce/resources/resource.rb +10 -0
- data/lib/bigcommerce/resources/shipping/shipping_method.rb +15 -0
- data/lib/bigcommerce/resources/store/store_information.rb +37 -0
- data/lib/bigcommerce/resources/system/time.rb +15 -0
- data/lib/bigcommerce/resources/tax/tax_class.rb +15 -0
- data/lib/bigcommerce/resources/webhooks/webhook.rb +22 -0
- data/lib/bigcommerce/subresource_actions.rb +43 -0
- data/lib/bigcommerce/version.rb +1 -4
- data/spec/bigcommerce/bigcommerce_spec.rb +76 -0
- data/spec/bigcommerce/unit/actions_spec.rb +151 -0
- data/spec/bigcommerce/unit/exception_spec.rb +53 -0
- data/spec/bigcommerce/unit/middleware/auth_spec.rb +18 -0
- data/spec/bigcommerce/unit/middleware/http_exception_spec.rb +40 -0
- data/spec/bigcommerce/unit/request_spec.rb +180 -0
- data/spec/bigcommerce/unit/resources/content/blog_post_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/content/blog_tag_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/content/redirect_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/customers/customer_address_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/customers/customer_group_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/customers/customer_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/geography/country_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/geography/state_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/marketing/coupon_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/orders/order_product_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/orders/order_shipping_address_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/orders/order_spec.rb +13 -0
- data/spec/bigcommerce/unit/resources/orders/shipment_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/payments/payment_method_spec.rb +23 -0
- data/spec/bigcommerce/unit/resources/products/brand_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/products/bulk_pricing_rule_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/products/category_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/products/configurable_field_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/products/custom_field_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/products/google_product_search_mapping_spec.rb +14 -0
- data/spec/bigcommerce/unit/resources/products/option_set_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/products/option_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/products/product_image_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/products/product_review_spec.rb +14 -0
- data/spec/bigcommerce/unit/resources/products/product_rule_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/products/product_spec.rb +13 -0
- data/spec/bigcommerce/unit/resources/products/product_video_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/products/sku_spec.rb +21 -0
- data/spec/bigcommerce/unit/resources/resource_spec.rb +4 -0
- data/spec/bigcommerce/unit/resources/store_info/store_information_spec.rb +12 -0
- data/spec/bigcommerce/unit/resources/system/time_spec.rb +12 -0
- data/spec/bigcommerce/unit/version_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -25
- metadata +203 -127
- data/lib/big_commerce.rb +0 -1
- data/lib/bigcommerce/api.rb +0 -473
- data/lib/bigcommerce/connection.rb +0 -171
- data/lib/bigcommerce/product.rb +0 -13
- data/lib/bigcommerce/resource.rb +0 -50
- data/spec/big_commerce_spec.rb +0 -9
- data/spec/integration/orders_spec.rb +0 -18
- data/spec/support/integration_context.rb +0 -13
- data/spec/support/mock_api_context.rb +0 -10
- data/spec/unit/api_request_spec.rb +0 -34
- data/spec/unit/api_spec.rb +0 -49
- data/spec/unit/connection_spec.rb +0 -23
- data/spec/unit/date_time_spec.rb +0 -31
- data/spec/unit/version_spec.rb +0 -13
@@ -1,171 +0,0 @@
|
|
1
|
-
module Bigcommerce
|
2
|
-
class Connection
|
3
|
-
attr_reader :configuration, :remaining_rate_limit
|
4
|
-
|
5
|
-
def initialize(configuration)
|
6
|
-
@configuration = {}
|
7
|
-
configuration.each do |key, val|
|
8
|
-
send(key.to_s + "=", val)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def store_hash=(store_hash)
|
13
|
-
@configuration[:store_hash] = store_hash
|
14
|
-
end
|
15
|
-
|
16
|
-
def client_id=(client_id)
|
17
|
-
@configuration[:client_id] = client_id
|
18
|
-
end
|
19
|
-
|
20
|
-
def access_token=(access_token)
|
21
|
-
@configuration[:access_token] = access_token
|
22
|
-
end
|
23
|
-
|
24
|
-
def store_url=(store_url)
|
25
|
-
url = URI.parse(store_url)
|
26
|
-
@configuration[:store_url] = url.scheme + "://" + url.host
|
27
|
-
end
|
28
|
-
|
29
|
-
def username=(username)
|
30
|
-
@configuration[:username] = username
|
31
|
-
end
|
32
|
-
|
33
|
-
def api_key=(api_key)
|
34
|
-
@configuration[:api_key] = api_key
|
35
|
-
end
|
36
|
-
|
37
|
-
def verify_peer=(verify)
|
38
|
-
@configuration[:verify_ssl] = verify
|
39
|
-
end
|
40
|
-
|
41
|
-
def ssl_ca_file=(path)
|
42
|
-
@configuration.ssl_ca_file = path
|
43
|
-
end
|
44
|
-
|
45
|
-
def ssl_client_key=(path,passphrase=nil)
|
46
|
-
if passphrase.nil?
|
47
|
-
@configuration.ssl_client_key = OpenSSL::PKey::RSA.new(File.read(path))
|
48
|
-
else
|
49
|
-
@configuration.ssl_client_key = OpenSSL::PKey::RSA.new(File.read(path), passphrase)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def ssl_client_cert=(path)
|
54
|
-
@configuration.client_cert = OpenSSL::X509::Certificate.new(File.read(path))
|
55
|
-
end
|
56
|
-
|
57
|
-
def get(path, options = {}, headers = {})
|
58
|
-
request(:get, path, options, headers)
|
59
|
-
end
|
60
|
-
|
61
|
-
def post(path, options = {}, headers = {})
|
62
|
-
request(:post, path, options, headers)
|
63
|
-
end
|
64
|
-
|
65
|
-
def put(path, options = {}, headers = {})
|
66
|
-
request(:put, path, options, headers)
|
67
|
-
end
|
68
|
-
|
69
|
-
def delete(path, options = {}, headers = {})
|
70
|
-
request(:delete, path, options, headers)
|
71
|
-
end
|
72
|
-
|
73
|
-
# Make a request to the bigcommerce API using either Legacy or OAuth
|
74
|
-
def request(method, path, options,headers={})
|
75
|
-
if oauth?
|
76
|
-
request_oauth(method, path, options, headers)
|
77
|
-
else
|
78
|
-
request_legacy(method, path, options, headers)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
def oauth?
|
85
|
-
@configuration[:store_hash] && @configuration[:client_id] && @configuration[:access_token]
|
86
|
-
end
|
87
|
-
|
88
|
-
def request_oauth(method, path, options, headers={})
|
89
|
-
uri = File.join((ENV['BC_API_ENDPOINT'] || 'https://api.bigcommerce.com'), '/stores', @configuration[:store_hash], '/v2', path)
|
90
|
-
|
91
|
-
rest_client = RestClient::Resource.new uri.to_s, {
|
92
|
-
headers: headers.merge({
|
93
|
-
'X-Auth-Client' => @configuration[:client_id],
|
94
|
-
'X-Auth-Token' => @configuration[:access_token],
|
95
|
-
:accept => :json,
|
96
|
-
:content_type => :json
|
97
|
-
})
|
98
|
-
}
|
99
|
-
|
100
|
-
response = case method
|
101
|
-
when :get then
|
102
|
-
rest_client.get :params => options
|
103
|
-
when :post then
|
104
|
-
rest_client.post(options.to_json)
|
105
|
-
when :put then
|
106
|
-
rest_client.put(options.to_json)
|
107
|
-
when :delete then
|
108
|
-
rest_client.delete
|
109
|
-
when :head then
|
110
|
-
rest_client.head
|
111
|
-
when :options then
|
112
|
-
rest_client.options
|
113
|
-
else
|
114
|
-
raise 'Unsupported method!'
|
115
|
-
end
|
116
|
-
|
117
|
-
if (200..201) === response.code
|
118
|
-
JSON.parse response
|
119
|
-
elsif response.code == 204
|
120
|
-
{}
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def request_legacy(method, path, options, headers={})
|
125
|
-
resource_options = {
|
126
|
-
:user => @configuration[:username],
|
127
|
-
:password => @configuration[:api_key],
|
128
|
-
:headers => headers
|
129
|
-
}
|
130
|
-
|
131
|
-
rest_client = RestClient::Resource.new "#{@configuration[:store_url]}/api/v2#{path}.json", resource_options
|
132
|
-
|
133
|
-
if @configuration[:ssl_client_key] && @configuration[:ssl_client_cert] && @configuration[:ssl_ca_file]
|
134
|
-
rest_client = RestClient::Resource.new(
|
135
|
-
"#{@configuration[:store_url]}/api/v2#{path}.json",
|
136
|
-
:username => @configuration[:username],
|
137
|
-
:password => @configuration[:api_key],
|
138
|
-
:ssl_client_cert => @configuration[:ssl_client_cert],
|
139
|
-
:ssl_client_key => @configuration[:ssl_client_key],
|
140
|
-
:ssl_ca_file => @configuration[:ssl_ca_file],
|
141
|
-
:verify_ssl => @configuration[:verify_ssl]
|
142
|
-
)
|
143
|
-
end
|
144
|
-
|
145
|
-
response = case method
|
146
|
-
when :get then
|
147
|
-
rest_client.get :params => options, :accept => :json, :content_type => :json
|
148
|
-
when :post then
|
149
|
-
rest_client.post(options.to_json, :content_type => :json, :accept => :json)
|
150
|
-
when :put then
|
151
|
-
rest_client.put(options.to_json, :content_type => :json, :accept => :json)
|
152
|
-
when :delete then
|
153
|
-
rest_client.delete
|
154
|
-
when :head then
|
155
|
-
rest_client.head
|
156
|
-
when :options then
|
157
|
-
rest_client.options
|
158
|
-
else
|
159
|
-
raise 'Unsupported method!'
|
160
|
-
end
|
161
|
-
|
162
|
-
@remaining_rate_limit = response.headers[:x_bc_apilimit_remaining]
|
163
|
-
if (200..201) === response.code
|
164
|
-
JSON.parse response
|
165
|
-
elsif response.code == 204
|
166
|
-
{}
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
end
|
data/lib/bigcommerce/product.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module Bigcommerce
|
2
|
-
class Product < Resource
|
3
|
-
|
4
|
-
# Here we memoize brand, so we can re-use it across different products
|
5
|
-
# Note we store this across the class
|
6
|
-
def brand
|
7
|
-
key = @hash["brand"]["resource"]
|
8
|
-
@@some_method ||= {}
|
9
|
-
@@some_method[key] ||= @connection.get(@hash["brand"]["resource"])
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
data/lib/bigcommerce/resource.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
module Bigcommerce
|
2
|
-
class Resource
|
3
|
-
|
4
|
-
def metaclass
|
5
|
-
class << self; self; end
|
6
|
-
end
|
7
|
-
|
8
|
-
def initialize hash, connection
|
9
|
-
@connection = connection
|
10
|
-
@hash = hash
|
11
|
-
@hash.each do |key, value|
|
12
|
-
if (value.class == Hash)
|
13
|
-
self.resourceify(key, value)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
@full_hash = @hash
|
17
|
-
end
|
18
|
-
|
19
|
-
def [](key)
|
20
|
-
@hash[key]
|
21
|
-
end
|
22
|
-
|
23
|
-
def []=(key,value)
|
24
|
-
@hash[key] = value
|
25
|
-
end
|
26
|
-
|
27
|
-
def resourceify(name, data)
|
28
|
-
if (!self.respond_to?(name.to_sym))
|
29
|
-
self.metaclass.send(:define_method, name) do
|
30
|
-
@connection.get data["resource"]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def load(*sub_resources)
|
36
|
-
sub_resources.each do |sub_resource|
|
37
|
-
begin
|
38
|
-
@full_hash[sub_resource.to_s] = self.send(sub_resource)
|
39
|
-
rescue RuntimeError => e
|
40
|
-
puts e
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def to_json
|
46
|
-
@full_hash.to_json
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
data/spec/big_commerce_spec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "/api/v2/orders" do
|
4
|
-
include_context "integration"
|
5
|
-
|
6
|
-
it "gets the orders collection", :vcr do
|
7
|
-
orders = api.orders
|
8
|
-
orders.should be_a_kind_of(Enumerable)
|
9
|
-
orders.size.should be > 0
|
10
|
-
end
|
11
|
-
|
12
|
-
it "filters orders by date", :vcr do
|
13
|
-
orders = api.orders_by_date('2013-03-01')
|
14
|
-
orders.should be_a_kind_of(Enumerable)
|
15
|
-
orders.size.should be > 0
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
shared_context "integration" do
|
2
|
-
let :api do
|
3
|
-
ENV['API_URL'] = ENV['API_URL'] || 'https://store-vnh06c71.mybigcommerce.com'
|
4
|
-
ENV['API_USER'] = ENV['API_USER'] || 'apiuser'
|
5
|
-
ENV['API_PASS'] = ENV['API_PASS'] || '123456'
|
6
|
-
|
7
|
-
Bigcommerce::Api.new({
|
8
|
-
:store_url => ENV['API_URL'],
|
9
|
-
:username => ENV['API_USER'],
|
10
|
-
:api_key => ENV['API_PASS']
|
11
|
-
})
|
12
|
-
end
|
13
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
describe "API request delegation" do
|
2
|
-
include_context "mock api"
|
3
|
-
|
4
|
-
it "requests a resource" do
|
5
|
-
api.connection.should_receive(:get).once.with("/time")
|
6
|
-
api.time
|
7
|
-
end
|
8
|
-
|
9
|
-
it "requests a resource by id" do
|
10
|
-
api.connection.should_receive(:get).once.with("/products/333", {})
|
11
|
-
api.product(333)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "requests a compound resource by ids" do
|
15
|
-
api.connection.should_receive(:get).once.with("/orders/999/products/333", {})
|
16
|
-
api.orders_product(999, 333)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "requests a resource with pagination" do
|
20
|
-
api.connection.should_receive(:get).once.with("/orders", {:page => 2})
|
21
|
-
api.orders(:page => 2)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "requests a resource with limit" do
|
25
|
-
api.connection.should_receive(:get).once.with("/categories", {:limit => 10})
|
26
|
-
api.categories(:limit => 10)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "request a resource with pagination and limit" do
|
30
|
-
api.connection.should_receive(:get).once.with("/customers", {:limit => 10, :page => 2})
|
31
|
-
api.customers(:limit => 10, :page => 2)
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
data/spec/unit/api_spec.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bigcommerce::Api do
|
4
|
-
include_context "mock api"
|
5
|
-
|
6
|
-
describe "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.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.orders_by_date('2012-1-1')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#create-orders-shipments" do
|
24
|
-
it "should accept an order id parameter" do
|
25
|
-
api.connection.should_receive(:post).once.with("/orders/123/shipments", {})
|
26
|
-
api.create_orders_shipments(123)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should accept an order id parameter and an options hash" do
|
30
|
-
options = Hash[*('A'..'Z').to_a.flatten]
|
31
|
-
api.connection.should_receive(:post).once.with("/orders/123/shipments", options)
|
32
|
-
api.create_orders_shipments(123, options)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#get-options-value" do
|
37
|
-
it "should accept an option id parameter" do
|
38
|
-
api.connection.should_receive(:get).once.with("/options/123/values", {})
|
39
|
-
api.options_value(123)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should accept an option id parameter and an options hash" do
|
43
|
-
options = Hash[*('A'..'Z').to_a.flatten]
|
44
|
-
api.connection.should_receive(:get).once.with("/options/123/values", options)
|
45
|
-
api.options_value(123, options)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for "request method accepting optional params and headers" do
|
4
|
-
it "sends request with no params" do
|
5
|
-
connection.should_receive(:request).once.with(http_method, path, {}, {})
|
6
|
-
connection.send(http_method, path)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "sends request with params" do
|
10
|
-
connection.should_receive(:request).once.with(http_method, path, {:page => 3}, {})
|
11
|
-
connection.send(http_method, path, {:page => 3})
|
12
|
-
end
|
13
|
-
|
14
|
-
it "sends request with headers" do
|
15
|
-
connection.should_receive(:request).once.with(http_method, "/orders", {}, {'Some-Header' => 'abc'})
|
16
|
-
connection.send(http_method, path, {}, {'Some-Header' => 'abc'})
|
17
|
-
end
|
18
|
-
|
19
|
-
it "sends request with params and headers" do
|
20
|
-
connection.should_receive(:request).once.with(http_method, "/orders", {:page => 6}, {'Some-Header' => 'abc'})
|
21
|
-
connection.send(http_method, path, {:page => 6}, {'Some-Header' => 'abc'})
|
22
|
-
end
|
23
|
-
end
|
data/spec/unit/date_time_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bigcommerce::Api do
|
4
|
-
|
5
|
-
let(:api) do
|
6
|
-
Bigcommerce::Api.new({
|
7
|
-
:store_url => "https://store-12345.mybigcommerce.com",
|
8
|
-
:username => "test", :api_key => "12345"
|
9
|
-
})
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:rfc2822_datetime) { "Tue, 13 Mar 2012 12:45:26 +0000" }
|
13
|
-
let(:rfc2822_date) { "Mon, 12 Mar 2012 00:00:00 +0000" }
|
14
|
-
|
15
|
-
describe "RFC 2822 DateTime format" do
|
16
|
-
|
17
|
-
it "converts raw date times to RFC 2822 format" do
|
18
|
-
api.to_rfc2822(DateTime.parse('2012-03-13 12:45:26 +0000')).should eql rfc2822_datetime
|
19
|
-
end
|
20
|
-
|
21
|
-
it "converts textual date times to RFC 2822 format" do
|
22
|
-
api.to_rfc2822(DateTime.parse('12th March 2012')).should eql rfc2822_date
|
23
|
-
end
|
24
|
-
|
25
|
-
it "converts ISO 8601 dates to RFC 2822 format" do
|
26
|
-
api.to_rfc2822(DateTime.parse('2012-03-12')).should eql rfc2822_date
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
data/spec/unit/version_spec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bigcommerce do
|
4
|
-
describe 'VERSION' do
|
5
|
-
it "should have a version number set" do
|
6
|
-
expect(Bigcommerce::VERSION).to_not be_nil
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should use a semantic version format" do
|
10
|
-
expect(Bigcommerce::VERSION).to match(/\d+\.\d+\.\d+(rc\d?)?/)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|