Sha256: c9e55b921a1adda99d88bfce46e15089bd48c2ba704d7ea6ef2d36098dd125f8

Contents?: true

Size: 1.56 KB

Versions: 34

Compression:

Stored size: 1.56 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__), '..', '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 customers
Chargify::Customer.find(:all)
# => [#<Chargify::Customer:0x102d0cef8 @prefix_options={}, @attributes={"reference"=>"moklett", "updated_at"=>Mon Nov 16 23:19:25 UTC 2009, "id"=>325, "first_name"=>"Michael", "organization"=>"Chargify", "last_name"=>"Klett", "email"=>"moklett@example.com", "created_at"=>Mon Nov 16 23:19:25 UTC 2009}>]


customer = Chargify::Customer.find(325)

customer.first_name
# => Michael

customer.last_name
# => Klett

# Update a customer - success!
customer.first_name = "Miguel"
customer.save
# => true

customer.first_name
# => Miguel

# Update a customer - fail!
customer.first_name = ""
customer.save
# => false

customer.errors.full_messages.inspect
# => ["First name: cannot be blank."]


# Create a new customer - success!
Chargify::Customer.create(
  :first_name   => "Charlie",
  :last_name    => "Bull",
  :email        => "charlie@example.com",
  :organization => "Chargify"
)
# => #<Chargify::Customer:0x102c27970 @prefix_options={}, @attributes={"reference"=>nil, "updated_at"=>Mon Nov 16 23:43:33 UTC 2009, "id"=>327, "organization"=>"Chargify", "first_name"=>"Charlie", "last_name"=>"Bull", "created_at"=>Mon Nov 16 23:43:33 UTC 2009, "email"=>"charlie@example.com"}>

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
chargify_api_ares-1.4.15 examples/customers.rb
chargify_api_ares-1.4.14 examples/customers.rb
chargify_api_ares-1.4.13 examples/customers.rb
chargify_api_ares-1.4.11 examples/customers.rb
chargify_api_ares-1.4.10 examples/customers.rb
chargify_api_ares-1.4.7 examples/customers.rb
chargify_api_ares-1.4.6 examples/customers.rb
chargify_api_ares-1.4.5 examples/customers.rb
chargify_api_ares-1.4.4 examples/customers.rb
chargify_api_ares-1.4.3 examples/customers.rb
chargify_api_ares-1.4.2 examples/customers.rb
chargify_api_ares-1.4.1 examples/customers.rb
chargify_api_ares-1.4.0 examples/customers.rb
chargify_api_ares-1.3.5 examples/customers.rb
chargify_api_ares-1.3.4 examples/customers.rb
chargify_api_ares-1.3.3 examples/customers.rb
chargify_api_ares-1.3.2 examples/customers.rb
chargify_api_ares-1.3.1 examples/customers.rb
chargify_api_ares-1.3.0 examples/customers.rb
chargify_api_ares-1.2.1 examples/customers.rb