Skip to content

Commit 4f5f23c

Browse files
authored
Merge pull request #121 from pedelman/update_products
Update examples for product and update resources
2 parents 2f3e706 + 65bf73b commit 4f5f23c

File tree

12 files changed

+123
-95
lines changed

12 files changed

+123
-95
lines changed

examples/products/brand.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
end
99

1010
# List brands
11-
puts Bigcommerce::Brand.all(page: 2)
11+
@brands = Bigcommerce::Brand.all(page: 1)
1212

1313
# Get a brand
14-
puts Bigcommerce::Brand.find(10)
14+
puts Bigcommerce::Brand.find(@brands.first.id)
1515

1616
# Get a count of brands
1717
puts Bigcommerce::Brand.count

examples/products/configurable_field.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,20 @@
66
config.access_token = ENV['BC_ACCESS_TOKEN']
77
end
88

9-
@product = Bigcommerce::Product.all[0]
9+
@product = Bigcommerce::Product.find(6)
1010

1111
# List configurable fields
1212
@configurable_fields = Bigcommerce::ConfigurableField.all(@product.id)
1313
puts @configurable_fields
1414

1515
# Get a configurable field
16-
@configurable_field = @configurable_fields[0]
17-
puts Bigcommerce::ConfigurableField.all(@product.id, @configurable_field.id)
16+
puts Bigcommerce::ConfigurableField.all(@product.id, @configurable_fields.first)
1817

1918
# Get a count of configurable fields
2019
puts Bigcommerce::ConfigurableField.count(@product.id)
2120

22-
# Get a count of all configurable fields for all products
23-
puts Bigcommerce::ConfigurableField.count(@product.id)
24-
2521
# Delete a configurable field
26-
puts Bigcommerce::ConfigurableField.destroy(@product.id, @configurable_field.id)
22+
puts Bigcommerce::ConfigurableField.destroy(@product.id, @configurable_fields.first.id)
2723

2824
# Delete multiple configurable fields
2925
# puts Bigcommerce::ConfigurableField.destroy_all(@product.id)

examples/products/option_set_option.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
# List option set options
3030
puts Bigcommerce::OptionSetOption.all(@option_set.id)
3131

32-
puts Bigcommerce::OptionSetOption.count(@option_set.id)
33-
3432
# Get an option set option
3533
puts Bigcommerce::OptionSetOption.find(@option_set.id, @option_set_option.id)
3634

examples/products/product_option.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config.access_token = ENV['BC_ACCESS_TOKEN']
77
end
88

9-
@product = Bigcommerce::Product.all[0]
9+
@product = Bigcommerce::Product.find(6)
1010

1111
# List product options
1212
@product_options = Bigcommerce::ProductOption.all(@product.id)

examples/products/product_review.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,36 @@
1010

1111
# List product reviews
1212
puts Bigcommerce::ProductReview.all(@product.id)
13+
14+
# List product review
15+
@product_reviews = Bigcommerce::ProductReview.all(@product.id)
16+
puts @product_reviews
17+
18+
# Create a product review
19+
@product_review = Bigcommerce::ProductReview.create(
20+
@product.id,
21+
author: 'Jimmy Doe',
22+
rating: 5,
23+
review: 'It was grrrreat!',
24+
title: 'A+'
25+
)
26+
puts @product_review
27+
28+
# Get a product review
29+
puts Bigcommerce::ProductReview.find(@product.id, @product_review.id)
30+
31+
# Update a product review
32+
puts Bigcommerce::ProductReview.update(
33+
@product.id,
34+
@product_review.id,
35+
author: 'John Doe',
36+
rating: 4,
37+
review: 'It was great!',
38+
title: 'A'
39+
)
40+
41+
# Delete a product review
42+
puts Bigcommerce::ProductReview.destroy(@product.id, @product_review.id)
43+
44+
# Delete all product review
45+
# puts Bigcommerce::ProductReview.destroy_all(@product.id)

examples/products/product_rule.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config.access_token = ENV['BC_ACCESS_TOKEN']
77
end
88

9-
@product = Bigcommerce::Product.all[0]
9+
@product = Bigcommerce::Product.find(6)
1010

1111
# List product rules
1212
@product_rules = Bigcommerce::ProductRule.all(@product.id)
@@ -23,8 +23,8 @@
2323
@product.id,
2424
conditions: [
2525
{
26-
product_option_id: 95,
27-
option_value_id: 13,
26+
product_option_id: 3,
27+
option_value_id: 73,
2828
sku_id: nil
2929
}
3030
]
@@ -40,8 +40,8 @@
4040
@product_rule.id,
4141
conditions: [
4242
{
43-
product_option_id: 95,
44-
option_value_id: 12,
43+
product_option_id: 3,
44+
option_value_id: 73,
4545
sku_id: nil
4646
}
4747
]

examples/products/sku.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
@product.id,
1515
sku: SecureRandom.hex,
1616
options: [
17-
product_option_id: 95,
18-
option_value_id: 10
17+
product_option_id: 3,
18+
option_value_id: 73
1919
]
2020
)
2121
puts @sku
@@ -25,7 +25,10 @@
2525
puts @skus
2626

2727
# Get a count of product skus
28-
puts Bigcommerce::Sku.count
28+
puts Bigcommerce::Sku.count(@product.id)
29+
30+
# Get a count of all product skus
31+
puts Bigcommerce::Sku.count_all
2932

3033
# Get a product sku
3134
puts Bigcommerce::Sku.find(@product.id, @sku.id)
@@ -36,8 +39,8 @@
3639
@sku.id,
3740
sku: SecureRandom.hex,
3841
options: [
39-
product_option_id: 95,
40-
option_value_id: 7
42+
product_option_id: 3,
43+
option_value_id: 73
4144
]
4245
)
4346

lib/bigcommerce/resources/products/google_product_search_mapping.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ module Bigcommerce
66
class GoogleProductSearchMapping < Resource
77
include Bigcommerce::Request.new 'products/%d/googleproductsearch'
88

9+
property :size
10+
property :color
11+
property :gender
912
property :enabled
13+
property :pattern
14+
property :material
15+
property :age_group
1016
property :product_id
1117
property :category_id
1218
property :custom_item
1319
property :global_trade_item_number
1420
property :manufacturer_part_number
15-
property :gender
16-
property :age_group
17-
property :color
18-
property :size
19-
property :material
20-
property :pattern
21+
property :google_shopping_product_category_path
2122

2223
def self.all(product_id)
2324
get path.build(product_id)

lib/bigcommerce/resources/products/option_value.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ class OptionValue < Resource
1111
property :label
1212
property :sort_order
1313
property :value
14+
property :is_default
1415
end
1516
end

lib/bigcommerce/resources/products/product.rb

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,88 +7,88 @@ class Product < Resource
77
include Bigcommerce::ResourceActions.new uri: 'products/%d'
88

99
property :id
10-
property :count
11-
property :keyword_filter
10+
property :sku
11+
property :upc
1212
property :name
13+
property :skus
1314
property :type
14-
property :sku
15-
property :description
16-
property :search_keywords
17-
property :availability_description
15+
property :brand
16+
property :depth
1817
property :price
18+
property :rules
19+
property :width
20+
property :height
21+
property :images
22+
property :videos
23+
property :weight
24+
property :options
25+
property :brand_id
26+
property :warranty
27+
property :condition
28+
property :downloads
29+
property :tax_class
30+
property :categories
1931
property :cost_price
20-
property :retail_price
32+
property :custom_url
33+
property :is_visible
34+
property :option_set
35+
property :page_title
2136
property :sale_price
22-
property :calculated_price
2337
property :sort_order
24-
property :is_visible
25-
property :is_featured
26-
property :related_products
27-
property :inventory_level
28-
property :inventory_warning_level
29-
property :warranty
30-
property :weight
31-
property :width
32-
property :height
33-
property :depth
34-
property :fixed_cost_shipping_price
35-
property :is_free_shipping
36-
property :inventory_tracking
37-
property :rating_total
38-
property :rating_count
3938
property :total_sold
40-
property :date_created
41-
property :brand_id
4239
property :view_count
43-
property :page_title
44-
property :meta_keywords
45-
property :meta_description
40+
property :description
41+
property :is_featured
4642
property :layout_file
47-
property :is_price_hidden
48-
property :price_hidden_label
49-
property :categories
43+
property :availability
44+
property :date_created
45+
property :rating_count
46+
property :rating_total
47+
property :retail_price
48+
property :tax_class_id
49+
property :custom_fields
5050
property :date_modified
51-
property :event_date_field_name
51+
property :meta_keywords
52+
property :option_set_id
53+
property :discount_rules
54+
property :event_date_end
55+
property :keyword_filter
5256
property :event_date_type
57+
property :inventory_level
58+
property :is_price_hidden
59+
property :open_graph_type
60+
property :search_keywords
61+
property :calculated_price
5362
property :event_date_start
54-
property :event_date_end
63+
property :is_free_shipping
64+
property :is_preorder_only
65+
property :meta_description
66+
property :open_graph_title
67+
property :preorder_message
68+
property :related_products
69+
property :bin_picking_number
70+
property :date_last_imported
71+
property :inventory_tracking
72+
property :is_condition_shown
5573
property :myob_asset_account
74+
property :option_set_display
75+
property :price_hidden_label
76+
property :configurable_fields
5677
property :myob_income_account
5778
property :myob_expense_account
5879
property :peachtree_gl_account
59-
property :condition
60-
property :is_condition_shown
80+
property :event_date_field_name
6181
property :preorder_release_date
62-
property :is_preorder_only
63-
property :preorder_message
64-
property :order_quantity_minimum
65-
property :order_quantity_maximum
66-
property :open_graph_type
67-
property :open_graph_title
6882
property :open_graph_description
83+
property :order_quantity_maximum
84+
property :order_quantity_minimum
85+
property :inventory_warning_level
6986
property :is_open_graph_thumbnail
70-
property :upc
71-
property :date_last_imported
72-
property :option_set_id
73-
property :tax_class_id
74-
property :option_set_display
75-
property :bin_picking_number
76-
property :custom_url
77-
property :availability
78-
property :brand
79-
property :downloads
80-
property :images
81-
property :discount_rules
82-
property :configurable_fields
83-
property :custom_fields
84-
property :videos
85-
property :skus
86-
property :rules
87-
property :option_set
88-
property :options
89-
property :tax_class
87+
property :availability_description
9088
property :avalara_product_tax_code
89+
property :fixed_cost_shipping_price
9190
property :primary_image
91+
property :count
9292

9393
def self.count(params = {})
9494
get 'products/count', params

0 commit comments

Comments
 (0)