diff --git a/bigcommerce.gemspec b/bigcommerce.gemspec index 6ce8921..78dc240 100644 --- a/bigcommerce.gemspec +++ b/bigcommerce.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.authors = ['Patrick Edelman'] s.homepage = 'https://github.com/bigcommerce/bigcommerce-api-ruby' s.summary = 'Ruby client library for the Bigcommerce v2 API' - s.description = <<-EOF + s.description = <<-EOF Bigcommerce API Ruby client library. Allows developer access to the Bigcommerce API, for CLI tools or public apps. More info: https://developer.bigcommerce.com diff --git a/examples/marketing/banner.rb b/examples/marketing/banner.rb new file mode 100644 index 0000000..582215f --- /dev/null +++ b/examples/marketing/banner.rb @@ -0,0 +1,39 @@ +require 'bigcommerce' + +Bigcommerce.configure do |config| + config.auth = 'legacy' + # You will get this url when registering for an API key + config.url = ENV.fetch('BC_API_ENDPOINT_LEGACY') + config.username = ENV.fetch('BC_USERNAME') + config.api_key = ENV.fetch('BC_API_KEY') +end + +# List banners +@banners = Bigcommerce::Banner.all +puts @banners + +# Get a banner +puts Bigcommerce::Banner.find(@banner.first.id) + +# Create a banner +# For 'page', you can use: 'home_page', 'category_page', 'brand_page', and 'searchpage'. +# For 'location', you can use: 'top' or 'bottom'. +# For 'date_type', you can use: 'always' or 'custom'. +# When using date_type: 'custom', you must add 'date_from' and 'date_to' values. +@banner = Bigcommerce::Banner.create( + name: 'Fourth of July Banner', + content: '10% sale for our grand closing until February 24th! Use code: DUSTY10', + page: 'home_page', + location: 'top', + date_type: 'always' +) +puts @banner + +# Update a banner +@banner.update(content: 'I have been updated.') + +# Delete a banner +puts Bigcommerce::Banner.destroy(@banner.id) + +# Delete all banners +puts Bigcommerce::Banner.destroy_all diff --git a/examples/marketing/gift_certificates.rb b/examples/marketing/gift_certificates.rb new file mode 100644 index 0000000..097610b --- /dev/null +++ b/examples/marketing/gift_certificates.rb @@ -0,0 +1,39 @@ +require 'bigcommerce' + +Bigcommerce.configure do |config| + config.auth = 'legacy' + # You will get this url when registering for an API key + config.url = ENV.fetch('BC_API_ENDPOINT_LEGACY') + config.username = ENV.fetch('BC_USERNAME') + config.api_key = ENV.fetch('BC_API_KEY') +end + +# List gift certificates +@gift_certificates = Bigcommerce::Giftcertificates.all +puts @gift_certificates + +# Get a gift certificate +puts Bigcommerce::GiftCertificates.find(@gift_certificates.first.id) + +# Create a gift certificate +@gift_certificates = Bigcommerce::GiftCertificates.create( + to_name: 'Test', + to_email: 'test@test.com', + from_name: 'Test2', + from_email: 'othertest@test.com', + code: SecureRandom.hex, + amount: 100 +) +puts @gift_certificates + +# Update an instance of a gift certificate +puts @gift_certificates.first.update(balance: 50) + +# Update a gift certificate +puts Bigcommerce::GiftCertificates.update(@gift_certificates.first.id, balance: 50) + +# Delete a gift certificate +puts Bigcommerce::GiftCertificates.destroy(@gift_certificates.first.id) + +# Delete all gift certificates +puts Bigcommerce::GiftCertificates.destroy_all diff --git a/lib/bigcommerce/resources/marketing/banner.rb b/lib/bigcommerce/resources/marketing/banner.rb new file mode 100644 index 0000000..cbe3db4 --- /dev/null +++ b/lib/bigcommerce/resources/marketing/banner.rb @@ -0,0 +1,21 @@ +# Banner +# HTML element on webpages to advertise discounts or other content relevant to shoppers. +# No URL as of yet + +module Bigcommerce + class Banner < Resource + include Bigcommerce::ResourceActions.new uri: 'banners/%d' + + property :id + property :name + property :content + property :page + property :catorbrandid + property :location + property :date_created + property :date_type + property :date_from + property :date_to + property :status + end +end diff --git a/lib/bigcommerce/resources/marketing/gift_certificates.rb b/lib/bigcommerce/resources/marketing/gift_certificates.rb new file mode 100644 index 0000000..7537723 --- /dev/null +++ b/lib/bigcommerce/resources/marketing/gift_certificates.rb @@ -0,0 +1,25 @@ +# Gift Certificates +# Code that can be applied by customers to their order to provide full or partial payment. +# No URL at this time + +module Bigcommerce + class GiftCertificates < Resource + include Bigcommerce::ResourceActions.new uri: 'gift_certificates/%d' + + property :id + property :customer_id + property :order_id + property :code + property :to_name + property :to_email + property :from_name + property :from_email + property :amount + property :balance + property :status + property :template + property :message + property :purchase_date + property :expiry_date + end +end