forked from bigcommerce/bigcommerce-api-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
product_review.rb
45 lines (36 loc) · 1.05 KB
/
product_review.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'bigcommerce'
Bigcommerce.configure do |config|
config.store_hash = ENV['BC_STORE_HASH']
config.client_id = ENV['BC_CLIENT_ID']
config.access_token = ENV['BC_ACCESS_TOKEN']
end
@product = Bigcommerce::Product.all[0]
# List product reviews
puts Bigcommerce::ProductReview.all(@product.id)
# List product review
@product_reviews = Bigcommerce::ProductReview.all(@product.id)
puts @product_reviews
# Create a product review
@product_review = Bigcommerce::ProductReview.create(
@product.id,
author: 'Jimmy Doe',
rating: 5,
review: 'It was grrrreat!',
title: 'A+'
)
puts @product_review
# Get a product review
puts Bigcommerce::ProductReview.find(@product.id, @product_review.id)
# Update a product review
puts Bigcommerce::ProductReview.update(
@product.id,
@product_review.id,
author: 'John Doe',
rating: 4,
review: 'It was great!',
title: 'A'
)
# Delete a product review
puts Bigcommerce::ProductReview.destroy(@product.id, @product_review.id)
# Delete all product review
# puts Bigcommerce::ProductReview.destroy_all(@product.id)