Sha256: 9defadda9a332f0b73da721127f53def4bdd73756537714d5494d062c42f886b

Contents?: true

Size: 1.91 KB

Versions: 23

Compression:

Stored size: 1.91 KB

Contents

$: << File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'chargify_api_ares'

# You could load your credentials from a file...
chargify_config = YAML::load_file(File.join(File.dirname(__FILE__), '..', 'config', 'chargify.yml'))

Chargify.configure do |c|
  c.subdomain = chargify_config['subdomain']
  c.api_key   = chargify_config['api_key']
end


# Retrieve a list of all your products
products = Chargify::Product.find(:all)
# => [#<Chargify::Product:0x102cdcac8 @prefix_options={}, @attributes={"name"=>"Chargify API Ares Test", "price_in_cents"=>0, "handle"=>"chargify-api-ares-test", "product_family"=>#<Chargify::Product::ProductFamily:0x102cdbad8 @prefix_options={}, @attributes={"name"=>"Chargify API ARes Test", "handle"=>"chargify-api-ares-test", "id"=>78, "accounting_code"=>nil}>, "id"=>152, "accounting_code"=>nil, "interval_unit"=>"month", "interval"=>1}>]

# Find a single product by id
product = Chargify::Product.find(products.first.id)
# => #<Chargify::Product:0x102ce7540 @prefix_options={}, @attributes={"price_in_cents"=>0, "name"=>"Chargify API Ares Test", "handle"=>"chargify-api-ares-test", "product_family"=>#<Chargify::Product::ProductFamily:0x102ce6ca8 @prefix_options={}, @attributes={"name"=>"Chargify API ARes Test", "handle"=>"chargify-api-ares-test", "id"=>78, "accounting_code"=>nil}>, "id"=>152, "accounting_code"=>nil, "interval_unit"=>"month", "interval"=>1}>

# Find a single product by its handle
product = Chargify::Product.find_by_handle(products.first.handle)
# => #<Chargify::Product:0x102c7a828 @prefix_options={}, @attributes={"price_in_cents"=>0, "name"=>"Chargify API Ares Test", "handle"=>"chargify-api-ares-test", "product_family"=>#<Chargify::Product::ProductFamily:0x102c798b0 @prefix_options={}, @attributes={"name"=>"Chargify API ARes Test", "handle"=>"chargify-api-ares-test", "id"=>78, "accounting_code"=>nil}>, "id"=>152, "accounting_code"=>nil, "interval_unit"=>"month", "interval"=>1}>

Version data entries

23 entries across 23 versions & 4 rubygems

Version Path
chargify_api_ares-0.4.4 samples/products.rb
chargify_api_ares-0.4.3 samples/products.rb
chargify_api_ares-0.4.2 samples/products.rb
chargify_api_ares-0.4.1 samples/products.rb
chargify_api_ares-0.4.0 samples/products.rb
vitalish-chargify_api_ares-0.3.9 samples/products.rb
chargify_api_ares-0.3.9 samples/products.rb
chargify_api_ares-0.3.8 samples/products.rb
chargify_api_ares-0.3.7 samples/products.rb
chargify_api_ares-0.3.5 samples/products.rb
chargify_api_ares-0.3.4 samples/products.rb
micah_chargify_api_ares-0.3.4 samples/products.rb
chargify_api_ares-0.3.3 samples/products.rb
chargify_api_ares-0.3.2 samples/products.rb
ninjabutton_chargify_api_ares-0.3.1 samples/products.rb
chargify_api_ares-0.3.1 samples/products.rb
chargify_api_ares-0.2.5 samples/products.rb
chargify_api_ares-0.2.4 samples/products.rb
chargify_api_ares-0.2.3 samples/products.rb
chargify_api_ares-0.2.2 samples/products.rb