bigcommerce 1.0.0.beta → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +115 -39
- data/bigcommerce.gemspec +12 -13
- data/lib/bigcommerce.rb +5 -34
- data/lib/bigcommerce/config.rb +14 -0
- data/lib/bigcommerce/connection.rb +26 -0
- data/lib/bigcommerce/exception.rb +25 -18
- data/lib/bigcommerce/request.rb +8 -9
- data/lib/bigcommerce/resource_actions.rb +11 -11
- data/lib/bigcommerce/resources/content/blog_post.rb +3 -5
- data/lib/bigcommerce/resources/content/blog_tag.rb +2 -3
- data/lib/bigcommerce/resources/content/redirect.rb +2 -2
- data/lib/bigcommerce/resources/customers/customer.rb +22 -2
- data/lib/bigcommerce/resources/customers/customer_address.rb +5 -5
- data/lib/bigcommerce/resources/customers/customer_group.rb +2 -2
- data/lib/bigcommerce/resources/geography/country.rb +4 -3
- data/lib/bigcommerce/resources/geography/state.rb +6 -5
- data/lib/bigcommerce/resources/marketing/banner.rb +21 -0
- data/lib/bigcommerce/resources/marketing/coupon.rb +2 -2
- data/lib/bigcommerce/resources/marketing/gift_certificates.rb +25 -0
- data/lib/bigcommerce/resources/orders/order.rb +46 -44
- data/lib/bigcommerce/resources/orders/order_coupon.rb +5 -5
- data/lib/bigcommerce/resources/orders/order_message.rb +8 -7
- data/lib/bigcommerce/resources/orders/order_product.rb +37 -36
- data/lib/bigcommerce/resources/orders/order_shipping_address.rb +24 -23
- data/lib/bigcommerce/resources/orders/order_status.rb +2 -1
- data/lib/bigcommerce/resources/orders/order_tax.rb +8 -7
- data/lib/bigcommerce/resources/orders/shipment.rb +11 -10
- data/lib/bigcommerce/resources/products/brand.rb +2 -2
- data/lib/bigcommerce/resources/products/bulk_pricing_rule.rb +6 -5
- data/lib/bigcommerce/resources/products/category.rb +2 -2
- data/lib/bigcommerce/resources/products/configurable_field.rb +6 -5
- data/lib/bigcommerce/resources/products/custom_field.rb +6 -5
- data/lib/bigcommerce/resources/products/google_product_search_mapping.rb +9 -8
- data/lib/bigcommerce/resources/products/option.rb +2 -2
- data/lib/bigcommerce/resources/products/option_set.rb +2 -2
- data/lib/bigcommerce/resources/products/option_set_option.rb +2 -1
- data/lib/bigcommerce/resources/products/option_value.rb +1 -0
- data/lib/bigcommerce/resources/products/product.rb +61 -61
- data/lib/bigcommerce/resources/products/product_image.rb +4 -4
- data/lib/bigcommerce/resources/products/product_option.rb +2 -1
- data/lib/bigcommerce/resources/products/product_review.rb +1 -5
- data/lib/bigcommerce/resources/products/product_rule.rb +4 -4
- data/lib/bigcommerce/resources/products/product_video.rb +4 -4
- data/lib/bigcommerce/resources/products/sku.rb +15 -9
- data/lib/bigcommerce/resources/shipping/shipping_method.rb +2 -1
- data/lib/bigcommerce/resources/store/store_information.rb +18 -14
- data/lib/bigcommerce/resources/system/time.rb +2 -2
- data/lib/bigcommerce/resources/tax/tax_class.rb +2 -1
- data/lib/bigcommerce/resources/webhooks/webhook.rb +2 -1
- data/lib/bigcommerce/subresource_actions.rb +14 -14
- data/lib/bigcommerce/version.rb +1 -1
- metadata +47 -166
- data/.gitignore +0 -17
- data/.rspec +0 -2
- data/.rubocop.yml +0 -620
- data/.travis.yml +0 -15
- data/CHANGELOG.md +0 -11
- data/CONTRIBUTING.md +0 -119
- data/DEPENDENCIES.md +0 -7
- data/Gemfile +0 -15
- data/Guardfile +0 -22
- data/LICENSE +0 -20
- data/RELEASING.md +0 -64
- data/Rakefile +0 -13
- data/examples/README.md +0 -148
- data/examples/configuration/legacy_auth.rb +0 -12
- data/examples/configuration/oauth.rb +0 -9
- data/examples/content/blog_post.rb +0 -39
- data/examples/content/blog_tag.rb +0 -10
- data/examples/content/redirect.rb +0 -43
- data/examples/customers/customer.rb +0 -36
- data/examples/customers/customer_address.rb +0 -50
- data/examples/customers/customer_group.rb +0 -35
- data/examples/exception_handling.rb +0 -50
- data/examples/geography/country.rb +0 -16
- data/examples/geography/state.rb +0 -19
- data/examples/marketing/coupon.rb +0 -44
- data/examples/orders/order.rb +0 -53
- data/examples/orders/order_coupon.rb +0 -17
- data/examples/orders/order_message.rb +0 -17
- data/examples/orders/order_product.rb +0 -23
- data/examples/orders/order_shipping_address.rb +0 -23
- data/examples/orders/order_status.rb +0 -15
- data/examples/orders/order_tax.rb +0 -17
- data/examples/orders/shipment.rb +0 -57
- data/examples/payments/payment_method.rb +0 -10
- data/examples/products/brand.rb +0 -36
- data/examples/products/bulk_pricing_rule.rb +0 -47
- data/examples/products/category.rb +0 -37
- data/examples/products/configurable_field.rb +0 -29
- data/examples/products/custom_field.rb +0 -44
- data/examples/products/google_product_search_mapping.rb +0 -12
- data/examples/products/option.rb +0 -37
- data/examples/products/option_set.rb +0 -35
- data/examples/products/option_set_option.rb +0 -50
- data/examples/products/option_value.rb +0 -43
- data/examples/products/product.rb +0 -44
- data/examples/products/product_image.rb +0 -42
- data/examples/products/product_option.rb +0 -17
- data/examples/products/product_review.rb +0 -12
- data/examples/products/product_rule.rb +0 -54
- data/examples/products/product_video.rb +0 -45
- data/examples/products/sku.rb +0 -48
- data/examples/shipping/shipping_method.rb +0 -13
- data/examples/store/store_info.rb +0 -10
- data/examples/system/time.rb +0 -10
- data/examples/tax/tax_class.rb +0 -13
- data/examples/webhooks/webhook.rb +0 -29
- data/spec/bigcommerce/bigcommerce_spec.rb +0 -76
- data/spec/bigcommerce/unit/actions_spec.rb +0 -151
- data/spec/bigcommerce/unit/exception_spec.rb +0 -53
- data/spec/bigcommerce/unit/middleware/auth_spec.rb +0 -18
- data/spec/bigcommerce/unit/middleware/http_exception_spec.rb +0 -40
- data/spec/bigcommerce/unit/request_spec.rb +0 -180
- data/spec/bigcommerce/unit/resources/content/blog_post_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/content/blog_tag_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/content/redirect_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/customers/customer_address_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/customers/customer_group_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/customers/customer_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/geography/country_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/geography/state_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/marketing/coupon_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/orders/order_product_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/orders/order_shipping_address_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/orders/order_spec.rb +0 -13
- data/spec/bigcommerce/unit/resources/orders/shipment_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/payments/payment_method_spec.rb +0 -23
- data/spec/bigcommerce/unit/resources/products/brand_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/products/bulk_pricing_rule_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/products/category_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/products/configurable_field_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/products/custom_field_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/products/google_product_search_mapping_spec.rb +0 -14
- data/spec/bigcommerce/unit/resources/products/option_set_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/products/option_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/products/product_image_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/products/product_review_spec.rb +0 -14
- data/spec/bigcommerce/unit/resources/products/product_rule_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/products/product_spec.rb +0 -13
- data/spec/bigcommerce/unit/resources/products/product_video_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/products/sku_spec.rb +0 -21
- data/spec/bigcommerce/unit/resources/resource_spec.rb +0 -4
- data/spec/bigcommerce/unit/resources/store_info/store_information_spec.rb +0 -12
- data/spec/bigcommerce/unit/resources/system/time_spec.rb +0 -12
- data/spec/bigcommerce/unit/version_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -11
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'bigcommerce'
|
2
|
-
|
3
|
-
Bigcommerce.configure do |config|
|
4
|
-
config.auth = 'legacy'
|
5
|
-
# You will get this url when registering for an API key
|
6
|
-
config.url = ENV['BC_API_ENDPOINT_LEGACY']
|
7
|
-
config.username = ENV['BC_USERNAME']
|
8
|
-
config.api_key = ENV['BC_API_KEY']
|
9
|
-
end
|
10
|
-
|
11
|
-
puts Bigcommerce::System.time
|
12
|
-
puts Bigcommerce.api_limit
|
@@ -1,39 +0,0 @@
|
|
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 blog posts
|
10
|
-
@posts = Bigcommerce::BlogPost.all(page: 1)
|
11
|
-
puts @posts
|
12
|
-
|
13
|
-
# Get a blog post
|
14
|
-
puts Bigcommerce::BlogPost.find(@posts[0].id)
|
15
|
-
|
16
|
-
# Get a count of blog posts
|
17
|
-
puts Bigcommerce::BlogPost.count
|
18
|
-
|
19
|
-
# Create a blog post
|
20
|
-
@post = Bigcommerce::BlogPost.create(
|
21
|
-
title: 'Brand new producrts for sale!',
|
22
|
-
body: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do \
|
23
|
-
eiusmod tempor incididunt ut labore et dolore magna aliqua. \
|
24
|
-
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui \
|
25
|
-
officia deserunt mollit anim id est laborum.'
|
26
|
-
)
|
27
|
-
puts @post
|
28
|
-
|
29
|
-
# Update a blog post
|
30
|
-
puts Bigcommerce::BlogPost.update(
|
31
|
-
@post.id,
|
32
|
-
title: 'Oops wrong title.'
|
33
|
-
)
|
34
|
-
|
35
|
-
# Delete a blog post
|
36
|
-
puts Bigcommerce::BlogPost.destroy(@post.id)
|
37
|
-
|
38
|
-
# Delete all blog posts
|
39
|
-
# puts Bigcommerce::BlogPost.destroy_all
|
@@ -1,43 +0,0 @@
|
|
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 redirects
|
10
|
-
@redirects = Bigcommerce::Redirect.all(page: 1)
|
11
|
-
puts @redirects
|
12
|
-
|
13
|
-
# Get a redirect
|
14
|
-
puts Bigcommerce::Redirect.find(@redirects[0].id)
|
15
|
-
|
16
|
-
# Get a count of redirects
|
17
|
-
puts Bigcommerce::Redirect.count
|
18
|
-
|
19
|
-
# Create a redirect
|
20
|
-
@redirect = Bigcommerce::Redirect.create(
|
21
|
-
path: '/womens_clothing',
|
22
|
-
forward: {
|
23
|
-
type: 'category',
|
24
|
-
ref: 3
|
25
|
-
}
|
26
|
-
)
|
27
|
-
puts @redirect
|
28
|
-
|
29
|
-
# Update a redirect
|
30
|
-
puts Bigcommerce::Redirect.update(
|
31
|
-
@redirect.id,
|
32
|
-
path: '/womens_clothing',
|
33
|
-
forward: {
|
34
|
-
type: 'category',
|
35
|
-
ref: 3
|
36
|
-
}
|
37
|
-
)
|
38
|
-
|
39
|
-
# Delete a redirect
|
40
|
-
puts Bigcommerce::Redirect.destroy(@redirect.id)
|
41
|
-
|
42
|
-
# Delete all redirects
|
43
|
-
# puts Bigcommerce::Redirect.destroy_all
|
@@ -1,36 +0,0 @@
|
|
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 customers
|
10
|
-
puts Bigcommerce::Customer.all(page: 1)
|
11
|
-
|
12
|
-
# Get a customer
|
13
|
-
puts Bigcommerce::Customer.find(1)
|
14
|
-
|
15
|
-
# Get a count of customers
|
16
|
-
puts Bigcommerce::Customer.count
|
17
|
-
|
18
|
-
# Create a customer
|
19
|
-
@customer = Bigcommerce::Customer.create(
|
20
|
-
first_name: 'Karl',
|
21
|
-
last_name: 'The Fog',
|
22
|
-
email: 'test@example.com'
|
23
|
-
)
|
24
|
-
puts @customer
|
25
|
-
|
26
|
-
# Update a customer
|
27
|
-
puts Bigcommerce::Customer.update(
|
28
|
-
@customer.id,
|
29
|
-
first_name: 'Karrrl'
|
30
|
-
)
|
31
|
-
|
32
|
-
# Delete a customer
|
33
|
-
puts Bigcommerce::Customer.destroy(@customer.id)
|
34
|
-
|
35
|
-
# Delete all customers
|
36
|
-
# puts Bigcommerce::Customer.destroy_all
|
@@ -1,50 +0,0 @@
|
|
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
|
-
@customer = Bigcommerce::Customer.all[0]
|
10
|
-
|
11
|
-
# List a customer address
|
12
|
-
@customer_addresses = Bigcommerce::CustomerAddress.all(@customer.id)
|
13
|
-
puts @customer_addresses
|
14
|
-
|
15
|
-
# Get a customer address
|
16
|
-
puts Bigcommerce::CustomerAddress.find(@customer.id, @customer_addresses[0].id)
|
17
|
-
|
18
|
-
# Get a count of customer addresses
|
19
|
-
puts Bigcommerce::CustomerAddress.count(@customer.id)
|
20
|
-
|
21
|
-
# Get a count of all customer addresses for all customers
|
22
|
-
puts Bigcommerce::CustomerAddress.count_all
|
23
|
-
|
24
|
-
# Create a customer address
|
25
|
-
@customer_address = Bigcommerce::CustomerAddress.create(
|
26
|
-
@customer.id,
|
27
|
-
first_name: 'Foo',
|
28
|
-
last_name: 'Bar',
|
29
|
-
phone: '5555555555',
|
30
|
-
street_1: '685 Market St.',
|
31
|
-
city: 'San Francisco',
|
32
|
-
state: 'California',
|
33
|
-
zip: '94019',
|
34
|
-
country: 'United States'
|
35
|
-
)
|
36
|
-
puts @customer_address
|
37
|
-
|
38
|
-
# Update a customer address
|
39
|
-
puts Bigcommerce::CustomerAddress.update(
|
40
|
-
@customer.id,
|
41
|
-
@customer_address.id,
|
42
|
-
first_name: 'Foo',
|
43
|
-
last_name: 'Bar'
|
44
|
-
)
|
45
|
-
|
46
|
-
# Delete a customer address
|
47
|
-
puts Bigcommerce::CustomerAddress.destroy(@customer.id, @customer_address.id)
|
48
|
-
|
49
|
-
# Delete all customer addresses
|
50
|
-
# puts Bigcommerce::CustomerAddress.destroy_all(@customer.id)
|
@@ -1,35 +0,0 @@
|
|
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
|
@@ -1,50 +0,0 @@
|
|
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
|
@@ -1,16 +0,0 @@
|
|
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
|
data/examples/geography/state.rb
DELETED
@@ -1,19 +0,0 @@
|
|
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
|
@@ -1,44 +0,0 @@
|
|
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
|
data/examples/orders/order.rb
DELETED
@@ -1,53 +0,0 @@
|
|
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
|
@@ -1,17 +0,0 @@
|
|
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)
|