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
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
Bigcommerce.configure do |config|
|
5
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
6
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
7
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
8
|
+
end
|
9
|
+
|
10
|
+
# List all customer groups
|
11
|
+
puts Bigcommerce::CustomerGroup.all
|
12
|
+
|
13
|
+
# Get a customer group
|
14
|
+
puts Bigcommerce::CustomerGroup.find(1)
|
15
|
+
|
16
|
+
# Get a count of all customer groups
|
17
|
+
puts Bigcommerce::CustomerGroup.count
|
18
|
+
|
19
|
+
# Create a customer group
|
20
|
+
@customer_group = Bigcommerce::CustomerGroup.create(
|
21
|
+
name: "Customer Group #{SecureRandom.hex}"
|
22
|
+
)
|
23
|
+
puts @customer_group
|
24
|
+
|
25
|
+
# Update a customer group
|
26
|
+
puts Bigcommerce::CustomerGroup.update(
|
27
|
+
@customer_group.id,
|
28
|
+
name: "Customer_group #{SecureRandom.hex}"
|
29
|
+
)
|
30
|
+
|
31
|
+
# Delete a customer group
|
32
|
+
puts Bigcommerce::CustomerGroup.destroy(@customer_group.id)
|
33
|
+
|
34
|
+
# Delete all customer groups
|
35
|
+
# puts Bigcommerce::CustomerGroup.destroy_all
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
# rubocop:disable MethodLength, Metrics/AbcSize:
|
10
|
+
def bc_handle_exception(&block)
|
11
|
+
# Below is a list of all the errors we will throw
|
12
|
+
block.call
|
13
|
+
rescue Bigcommerce::BadRequest => e
|
14
|
+
puts e.inspect
|
15
|
+
rescue Bigcommerce::Unauthorized => e
|
16
|
+
puts e.inspect
|
17
|
+
rescue Bigcommerce::Forbidden => e
|
18
|
+
puts e.inspect
|
19
|
+
rescue Bigcommerce::NotFound => e
|
20
|
+
puts e.inspect
|
21
|
+
rescue Bigcommerce::MethodNotAllowed => e
|
22
|
+
puts e.inspect
|
23
|
+
rescue Bigcommerce::NotAccepted => e
|
24
|
+
puts e.inspect
|
25
|
+
rescue Bigcommerce::TimeOut => e
|
26
|
+
puts e.inspect
|
27
|
+
rescue Bigcommerce::ResourceConflict => e
|
28
|
+
puts e.inspect
|
29
|
+
rescue Bigcommerce::TooManyRequests => e
|
30
|
+
puts e.inspect
|
31
|
+
rescue Bigcommerce::InternalServerError => e
|
32
|
+
puts e.inspect
|
33
|
+
rescue Bigcommerce::BadGateway => e
|
34
|
+
puts e.inspect
|
35
|
+
rescue Bigcommerce::ServiceUnavailable => e
|
36
|
+
puts e.inspect
|
37
|
+
rescue Bigcommerce::GatewayTimeout => e
|
38
|
+
puts e.inspect
|
39
|
+
rescue Bigcommerce::BandwidthLimitExceeded => e
|
40
|
+
puts e.inspect
|
41
|
+
rescue => e
|
42
|
+
puts "Some other Error #{e.inspect}"
|
43
|
+
end
|
44
|
+
|
45
|
+
Bigcommerce::HttpError::ERRORS.each do |k, v|
|
46
|
+
bc_handle_exception do
|
47
|
+
# This will be your request that you want to protect from exceptions
|
48
|
+
fail v, k
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
# List countries
|
10
|
+
puts Bigcommerce::Country.all(page: 1)
|
11
|
+
|
12
|
+
# Get a country
|
13
|
+
puts Bigcommerce::Country.find(226)
|
14
|
+
|
15
|
+
# Get a count of countries
|
16
|
+
puts Bigcommerce::Country.count
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
# List countries
|
10
|
+
puts Bigcommerce::State.all(226)
|
11
|
+
|
12
|
+
# Get a country
|
13
|
+
puts Bigcommerce::State.find(226, 10)
|
14
|
+
|
15
|
+
# Get a count of countries
|
16
|
+
puts Bigcommerce::State.count(226)
|
17
|
+
|
18
|
+
# Get a count of all states for all countries
|
19
|
+
puts Bigcommerce::State.count_all
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
Bigcommerce.configure do |config|
|
5
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
6
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
7
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
8
|
+
end
|
9
|
+
|
10
|
+
# List coupons
|
11
|
+
@coupons = Bigcommerce::Coupon.all
|
12
|
+
puts @coupons
|
13
|
+
|
14
|
+
# Get a coupon
|
15
|
+
puts Bigcommerce::Coupon.find(@coupons[0].id)
|
16
|
+
|
17
|
+
# Get a count of coupons
|
18
|
+
puts Bigcommerce::Coupon.count
|
19
|
+
|
20
|
+
# Create a coupon
|
21
|
+
@coupon = Bigcommerce::Coupon.create(
|
22
|
+
name: SecureRandom.hex,
|
23
|
+
code: SecureRandom.hex,
|
24
|
+
type: 'per_item_discount',
|
25
|
+
amount: 5,
|
26
|
+
applies_to: {
|
27
|
+
entity: 'categories',
|
28
|
+
ids: [0]
|
29
|
+
}
|
30
|
+
)
|
31
|
+
puts @coupon
|
32
|
+
|
33
|
+
# Update a coupon
|
34
|
+
puts Bigcommerce::Coupon.update(
|
35
|
+
@coupon.id,
|
36
|
+
name: SecureRandom.hex,
|
37
|
+
amount: 10
|
38
|
+
)
|
39
|
+
|
40
|
+
# Delete a coupon
|
41
|
+
puts Bigcommerce::Coupon.destroy(@coupon.id)
|
42
|
+
|
43
|
+
# Delete all coupons
|
44
|
+
# puts Bigcommerce::Coupon.destroy_all
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
# List orders
|
10
|
+
@orders = Bigcommerce::Order.all
|
11
|
+
puts @orders
|
12
|
+
|
13
|
+
# Get an order
|
14
|
+
@order = @orders[0]
|
15
|
+
puts Bigcommerce::Order.find(@order.id)
|
16
|
+
|
17
|
+
# Get a count of orders
|
18
|
+
puts Bigcommerce::Order.count
|
19
|
+
|
20
|
+
# Create an order
|
21
|
+
@order = Bigcommerce::Order.create(
|
22
|
+
billing_address: {
|
23
|
+
first_name: 'Karl',
|
24
|
+
last_name: 'The Fog',
|
25
|
+
street_1: '685 Market St.',
|
26
|
+
city: 'San Francisco',
|
27
|
+
state: 'California',
|
28
|
+
zip: '94019',
|
29
|
+
country: 'United States',
|
30
|
+
email: 'test@example.com'
|
31
|
+
},
|
32
|
+
products: [
|
33
|
+
{
|
34
|
+
product_id: 34,
|
35
|
+
quantity: 2
|
36
|
+
}
|
37
|
+
]
|
38
|
+
)
|
39
|
+
puts @order
|
40
|
+
|
41
|
+
# Update an order
|
42
|
+
puts Bigcommerce::Order.update(
|
43
|
+
@order.id,
|
44
|
+
billing_address: {
|
45
|
+
last_name: 'TheFog'
|
46
|
+
}
|
47
|
+
)
|
48
|
+
|
49
|
+
# Delete an order
|
50
|
+
puts Bigcommerce::Order.destroy(@order.id)
|
51
|
+
|
52
|
+
# Delete all orders
|
53
|
+
# puts Bigcommerce::Order.destroy_all
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
@order = Bigcommerce::Order.all[0]
|
10
|
+
|
11
|
+
# List order coupons
|
12
|
+
@order_coupons = Bigcommerce::OrderCoupon.all(@order.id)
|
13
|
+
puts @order_coupons
|
14
|
+
|
15
|
+
# Get an order coupon
|
16
|
+
@order_coupon = @order_coupons[0]
|
17
|
+
puts Bigcommerce::OrderCoupon.find(@order.id, @order_coupon.id)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
@order = Bigcommerce::Order.all[0]
|
10
|
+
|
11
|
+
# List order messages
|
12
|
+
@order_messages = Bigcommerce::OrderMessage.all(@order.id)
|
13
|
+
puts @order_messages
|
14
|
+
|
15
|
+
# Get an order message
|
16
|
+
@order_message = @order_messages[0]
|
17
|
+
puts Bigcommerce::OrderMessage.find(@order.id, @order_message.id)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
@order = Bigcommerce::Order.all[0]
|
10
|
+
|
11
|
+
# List order products
|
12
|
+
@order_products = Bigcommerce::OrderProduct.all(@order.id)
|
13
|
+
puts @order_products
|
14
|
+
|
15
|
+
# Get an order product
|
16
|
+
@order_product = @order_products[0]
|
17
|
+
puts Bigcommerce::OrderProduct.find(@order.id, @order_product.id)
|
18
|
+
|
19
|
+
# Get a count of order products
|
20
|
+
puts Bigcommerce::OrderProduct.count(@order.id)
|
21
|
+
|
22
|
+
# Get a count of all order products for all orders
|
23
|
+
puts Bigcommerce::OrderProduct.count_all
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
@order = Bigcommerce::Order.all[0]
|
10
|
+
|
11
|
+
# List order shipping address
|
12
|
+
@order_shipping_addresses = Bigcommerce::OrderShippingAddress.all(@order.id)
|
13
|
+
puts @order_shipping_addresses
|
14
|
+
|
15
|
+
# Get an order shipping address
|
16
|
+
@order_shipping_address = @order_shipping_addresses[0]
|
17
|
+
puts Bigcommerce::OrderShippingAddress.find(@order.id, @order_shipping_address.id)
|
18
|
+
|
19
|
+
# Get a count of order shipping addresses
|
20
|
+
puts Bigcommerce::OrderShippingAddress.count(@order.id)
|
21
|
+
|
22
|
+
# Get a count of all order shipping addresses for all order
|
23
|
+
puts Bigcommerce::OrderShippingAddress.count_all
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
# List order statuses
|
10
|
+
@order_statuses = Bigcommerce::OrderStatus.all
|
11
|
+
puts @order_statuses
|
12
|
+
|
13
|
+
# Get an order status
|
14
|
+
@order_status = @order_statuses[0]
|
15
|
+
puts Bigcommerce::OrderStatus.find(@order_status.id)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
@order = Bigcommerce::Order.find(109)
|
10
|
+
|
11
|
+
# List order taxes
|
12
|
+
@order_taxes = Bigcommerce::OrderTax.all(@order.id)
|
13
|
+
puts @order_taxes
|
14
|
+
|
15
|
+
# Get an order tax
|
16
|
+
@order_tax = @order_taxes[0]
|
17
|
+
puts Bigcommerce::OrderTax.find(@order.id, @order_tax.id)
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
@order = Bigcommerce::Order.all[0]
|
10
|
+
|
11
|
+
# Create a shipment
|
12
|
+
@order_product = Bigcommerce::OrderProduct.all(@order.id)[0]
|
13
|
+
|
14
|
+
@order_address = Bigcommerce::OrderShippingAddress.all(@order.id)[0]
|
15
|
+
|
16
|
+
@shipment = Bigcommerce::Shipment.create(
|
17
|
+
@order.id,
|
18
|
+
tracking_number: 'ups12345',
|
19
|
+
comments: 'Notes about the shipment',
|
20
|
+
order_address_id: @order_address.id,
|
21
|
+
items: [
|
22
|
+
{
|
23
|
+
order_product_id: @order_product.id,
|
24
|
+
quantity: 1
|
25
|
+
}
|
26
|
+
]
|
27
|
+
)
|
28
|
+
puts @shipment
|
29
|
+
|
30
|
+
# List shipments
|
31
|
+
@shipments = Bigcommerce::Shipment.all(@order.id)
|
32
|
+
puts @shipments
|
33
|
+
|
34
|
+
# Get a shipment
|
35
|
+
@shipment = @shipments[0]
|
36
|
+
puts Bigcommerce::Shipment.find(@order.id, @shipment.id)
|
37
|
+
|
38
|
+
# Get a count of shipments
|
39
|
+
puts Bigcommerce::Shipment.count(@order.id)
|
40
|
+
|
41
|
+
# Get a count of all shipments for all orders
|
42
|
+
puts Bigcommerce::Shipment.count_all
|
43
|
+
|
44
|
+
# Update a shipment
|
45
|
+
puts Bigcommerce::Shipment.update(
|
46
|
+
@order.id,
|
47
|
+
@shipment.id,
|
48
|
+
tracking_number: 'fedex1245',
|
49
|
+
comments: 'Notes about the shipment',
|
50
|
+
order_address_id: @order_address.id
|
51
|
+
)
|
52
|
+
|
53
|
+
# Delete a shipment
|
54
|
+
puts Bigcommerce::Shipment.destroy(@order.id, @shipment.id)
|
55
|
+
|
56
|
+
# Delete multiple shipments
|
57
|
+
# puts Bigcommerce::Shipment.destroy_all(@order.id)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
|
3
|
+
Bigcommerce.configure do |config|
|
4
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
5
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
6
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
# List payment methods
|
10
|
+
puts Bigcommerce::PaymentMethod.all
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'bigcommerce'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
Bigcommerce.configure do |config|
|
5
|
+
config.store_hash = ENV['BC_STORE_HASH']
|
6
|
+
config.client_id = ENV['BC_CLIENT_ID']
|
7
|
+
config.access_token = ENV['BC_ACCESS_TOKEN']
|
8
|
+
end
|
9
|
+
|
10
|
+
# List brands
|
11
|
+
puts Bigcommerce::Brand.all(page: 2)
|
12
|
+
|
13
|
+
# Get a brand
|
14
|
+
puts Bigcommerce::Brand.find(10)
|
15
|
+
|
16
|
+
# Get a count of brands
|
17
|
+
puts Bigcommerce::Brand.count
|
18
|
+
|
19
|
+
# Create a brand
|
20
|
+
@brand = Bigcommerce::Brand.create(
|
21
|
+
name: SecureRandom.hex,
|
22
|
+
page_title: "Title #{SecureRandom.hex}"
|
23
|
+
)
|
24
|
+
puts @brand
|
25
|
+
|
26
|
+
# Update a brand
|
27
|
+
puts Bigcommerce::Brand.update(
|
28
|
+
@brand.id,
|
29
|
+
name: 'Foobar'
|
30
|
+
)
|
31
|
+
|
32
|
+
# Delete a brand
|
33
|
+
puts Bigcommerce::Brand.destroy(@brand.id)
|
34
|
+
|
35
|
+
# Delete all brands
|
36
|
+
# Bigcommerce::Brand.destroy_all
|