-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from bc-AlyssNoland/0.1.0
Add gift certs and banners as resources
- Loading branch information
Showing
5 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |