Skip to content

Commit

Permalink
Merge pull request #103 from bc-AlyssNoland/0.1.0
Browse files Browse the repository at this point in the history
Add gift certs and banners as resources
  • Loading branch information
xyzjace committed Sep 11, 2015
2 parents 4a6e800 + 6cc4be0 commit 837e14e
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bigcommerce.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions examples/marketing/banner.rb
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
39 changes: 39 additions & 0 deletions examples/marketing/gift_certificates.rb
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
21 changes: 21 additions & 0 deletions lib/bigcommerce/resources/marketing/banner.rb
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
25 changes: 25 additions & 0 deletions lib/bigcommerce/resources/marketing/gift_certificates.rb
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

0 comments on commit 837e14e

Please sign in to comment.