chargify_api_ares 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/chargify_api_ares.gemspec +47 -0
- data/lib/chargify_api_ares.rb +103 -0
- data/samples/customers.rb +51 -0
- data/samples/products.rb +24 -0
- data/samples/subscriptions.rb +43 -0
- metadata +65 -0
data/.gitignore
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2009 Grasshopper Group, LLC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
Chargify API wrapper for Ruby (using ActiveResource)
|
2
|
+
====================================================
|
3
|
+
|
4
|
+
chargify_api_ares
|
5
|
+
-----------------
|
6
|
+
|
7
|
+
This is a Ruby wrapper for the [Chargify](http://chargify.com) API that leverages ActiveResource.
|
8
|
+
It allows you to interface with the Chargify API using simple ActiveRecord-like syntax, i.e.:
|
9
|
+
|
10
|
+
Chargify::Subscription.create(
|
11
|
+
:customer_reference => 'moklett',
|
12
|
+
:product_handle => 'chargify-api-ares-test',
|
13
|
+
:credit_card_attributes => {
|
14
|
+
:first_name => "Michael",
|
15
|
+
:last_name => "Klett",
|
16
|
+
:expiration_month => 1,
|
17
|
+
:expiration_year => 2010,
|
18
|
+
:full_number => "1234-1234-1234-1234"
|
19
|
+
}
|
20
|
+
)
|
21
|
+
|
22
|
+
subscription.credit_card_attributes = {:expiration_year => 2013}
|
23
|
+
subscription.save
|
24
|
+
|
25
|
+
subscription.cancel
|
26
|
+
|
27
|
+
See the `samples` directory for more usage examples.
|
28
|
+
|
29
|
+
|
30
|
+
### Installation
|
31
|
+
|
32
|
+
This library can be installed as a gem. It is hosted on [Gemcutter](http://gemcutter.org).
|
33
|
+
|
34
|
+
If you don't have your system set up to use gemcutter, follow the instructions on their site
|
35
|
+
<http://gemcutter.org>, i.e.:
|
36
|
+
|
37
|
+
$ gem install gemcutter
|
38
|
+
$ gem tumble
|
39
|
+
|
40
|
+
This will install Gemcutter and set your gem sources to search the gemcutter repos.
|
41
|
+
|
42
|
+
Then you can install this library as a gem:
|
43
|
+
|
44
|
+
$ gem install chargify_api_ares
|
45
|
+
|
46
|
+
|
47
|
+
### Requirements
|
48
|
+
|
49
|
+
This library requires ActiveResource version 2.3.4.
|
50
|
+
|
51
|
+
$ gem install activeresource
|
52
|
+
|
53
|
+
|
54
|
+
### Usage
|
55
|
+
|
56
|
+
Simply require this library before you use it:
|
57
|
+
|
58
|
+
require 'chargify_api_ares'
|
59
|
+
|
60
|
+
|
61
|
+
If you're using Rails, you could include this gem in your configuration, i.e. in `environment.rb`
|
62
|
+
|
63
|
+
config.gem 'chargify_api_ares'
|
64
|
+
|
65
|
+
|
66
|
+
Now you'll have access to classes the interact with the Chargify API, such as:
|
67
|
+
|
68
|
+
`Chargify::Product`
|
69
|
+
`Chargify::Customer`
|
70
|
+
`Chargifiy::Subscription`
|
71
|
+
|
72
|
+
Check out the examples in the `samples` directory. If you're not familiar with how ActiveResource works,
|
73
|
+
you may be interested in some [ActiveResource Documentation](http://apidock.com/rails/ActiveResource/Base)
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
### Contributors
|
78
|
+
|
79
|
+
* Michael Klett (Grasshopper Labs and Chargify)
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "chargify_api_ares"
|
5
|
+
gemspec.summary = "A Chargify API wrapper for Ruby using ActiveResource"
|
6
|
+
gemspec.description = ""
|
7
|
+
gemspec.email = "mklett@grasshopper.com"
|
8
|
+
gemspec.homepage = "http://github.com/grasshopperlabs/chargify_api_ares"
|
9
|
+
gemspec.authors = ["Michael Klett"]
|
10
|
+
Jeweler::GemcutterTasks.new
|
11
|
+
end
|
12
|
+
rescue LoadError
|
13
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
14
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{chargify_api_ares}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Michael Klett"]
|
12
|
+
s.date = %q{2009-11-17}
|
13
|
+
s.description = %q{}
|
14
|
+
s.email = %q{mklett@grasshopper.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE.txt",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"chargify_api_ares.gemspec",
|
26
|
+
"lib/chargify_api_ares.rb",
|
27
|
+
"samples/customers.rb",
|
28
|
+
"samples/products.rb",
|
29
|
+
"samples/subscriptions.rb"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/grasshopperlabs/chargify_api_ares}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.5}
|
35
|
+
s.summary = %q{A Chargify API wrapper for Ruby using ActiveResource}
|
36
|
+
|
37
|
+
if s.respond_to? :specification_version then
|
38
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
39
|
+
s.specification_version = 3
|
40
|
+
|
41
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
42
|
+
else
|
43
|
+
end
|
44
|
+
else
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# Chargify API Wrapper using ActiveResource.
|
2
|
+
#
|
3
|
+
begin
|
4
|
+
require 'activeresource'
|
5
|
+
rescue LoadError
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
require 'activeresource'
|
9
|
+
rescue LoadError
|
10
|
+
abort <<-ERROR
|
11
|
+
The 'activeresource' library could not be loaded. If you have RubyGems
|
12
|
+
installed you can install ActiveResource by doing "gem install activeresource".
|
13
|
+
ERROR
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
# Version check
|
19
|
+
module Chargify
|
20
|
+
ARES_VERSION = '2.3.4'
|
21
|
+
end
|
22
|
+
require 'active_resource/version'
|
23
|
+
unless ActiveResource::VERSION::STRING == Chargify::ARES_VERSION
|
24
|
+
abort <<-ERROR
|
25
|
+
ActiveResource version #{Chargify::ARES_VERSION} is required.
|
26
|
+
ERROR
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# A patch for ActiveResource until a version after 2.3.4 fixes it.
|
31
|
+
module ActiveResource
|
32
|
+
# Errors returned from the API layer were not getting put into our object as of Rails 2.3.4
|
33
|
+
# See http://github.com/rails/rails/commit/1488c6cc9e6237ce794e3c4a6201627b9fd4ca09
|
34
|
+
class Base
|
35
|
+
def save
|
36
|
+
save_without_validation
|
37
|
+
true
|
38
|
+
rescue ResourceInvalid => error
|
39
|
+
case error.response['Content-Type']
|
40
|
+
when /application\/xml/
|
41
|
+
errors.from_xml(error.response.body)
|
42
|
+
when /application\/json/
|
43
|
+
errors.from_json(error.response.body)
|
44
|
+
end
|
45
|
+
false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
module Chargify
|
52
|
+
|
53
|
+
class << self
|
54
|
+
attr_accessor :subdomain, :api_key, :site, :format
|
55
|
+
|
56
|
+
def configure
|
57
|
+
yield self
|
58
|
+
|
59
|
+
Base.user = api_key
|
60
|
+
Base.password = 'X'
|
61
|
+
Base.site = site.blank? ? "https://#{subdomain}.chargify.com" : site
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Base < ActiveResource::Base
|
66
|
+
class << self
|
67
|
+
def element_name
|
68
|
+
name.split(/::/).last.underscore
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_xml(options = {})
|
73
|
+
options.merge!(:dasherize => false)
|
74
|
+
super
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Customer < Base
|
79
|
+
def self.find_by_reference(reference)
|
80
|
+
find(:all, :params => {:reference => reference})
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class Subscription < Base
|
85
|
+
# Strip off nested attributes of associations before saving, or type-mismatch errors will occur
|
86
|
+
def save
|
87
|
+
self.attributes.delete('customer')
|
88
|
+
self.attributes.delete('product')
|
89
|
+
self.attributes.delete('credit_card')
|
90
|
+
super
|
91
|
+
end
|
92
|
+
|
93
|
+
def cancel
|
94
|
+
destroy
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class Product < Base
|
99
|
+
def self.find_by_handle(handle)
|
100
|
+
find(:first, :conditions => {:handle => handle})
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'chargify_api_ares'
|
4
|
+
|
5
|
+
# You could load your credentials from a file...
|
6
|
+
chargify_config = YAML::load_file(File.join(File.dirname(__FILE__), '..', 'config', 'chargify.yml'))
|
7
|
+
|
8
|
+
Chargify.configure do |c|
|
9
|
+
c.subdomain = chargify_config['subdomain']
|
10
|
+
c.api_key = chargify_config['api_key']
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# Retrieve a list of all your customers
|
15
|
+
Chargify::Customer.find(:all)
|
16
|
+
# => [#<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}>]
|
17
|
+
|
18
|
+
|
19
|
+
customer = Chargify::Customer.find(325)
|
20
|
+
|
21
|
+
customer.first_name
|
22
|
+
# => Michael
|
23
|
+
|
24
|
+
customer.last_name
|
25
|
+
# => Klett
|
26
|
+
|
27
|
+
# Update a customer - success!
|
28
|
+
customer.first_name = "Miguel"
|
29
|
+
customer.save
|
30
|
+
# => true
|
31
|
+
|
32
|
+
customer.first_name
|
33
|
+
# => Miguel
|
34
|
+
|
35
|
+
# Update a customer - fail!
|
36
|
+
customer.first_name = ""
|
37
|
+
customer.save
|
38
|
+
# => false
|
39
|
+
|
40
|
+
customer.errors.full_messages.inspect
|
41
|
+
# => ["First name: cannot be blank."]
|
42
|
+
|
43
|
+
|
44
|
+
# Create a new customer - success!
|
45
|
+
Chargify::Customer.create(
|
46
|
+
:first_name => "Charlie",
|
47
|
+
:last_name => "Bull",
|
48
|
+
:email => "charlie@example.com",
|
49
|
+
:organization => "Chargify"
|
50
|
+
)
|
51
|
+
# => #<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"}>
|
data/samples/products.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'chargify_api_ares'
|
4
|
+
|
5
|
+
# You could load your credentials from a file...
|
6
|
+
chargify_config = YAML::load_file(File.join(File.dirname(__FILE__), '..', 'config', 'chargify.yml'))
|
7
|
+
|
8
|
+
Chargify.configure do |c|
|
9
|
+
c.subdomain = chargify_config['subdomain']
|
10
|
+
c.api_key = chargify_config['api_key']
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# Retrieve a list of all your products
|
15
|
+
products = Chargify::Product.find(:all)
|
16
|
+
# => [#<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}>]
|
17
|
+
|
18
|
+
# Find a single product by id
|
19
|
+
product = Chargify::Product.find(products.first.id)
|
20
|
+
# => #<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}>
|
21
|
+
|
22
|
+
# Find a single product by its handle
|
23
|
+
product = Chargify::Product.find_by_handle(products.first.handle)
|
24
|
+
# => #<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}>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'chargify_api_ares'
|
4
|
+
|
5
|
+
# You could load your credentials from a file...
|
6
|
+
chargify_config = YAML::load_file(File.join(File.dirname(__FILE__), '..', 'config', 'chargify.yml'))
|
7
|
+
|
8
|
+
Chargify.configure do |c|
|
9
|
+
c.subdomain = chargify_config['subdomain']
|
10
|
+
c.api_key = chargify_config['api_key']
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# Retrieve a list of all your customers
|
15
|
+
subscription = Chargify::Subscription.find(:all)
|
16
|
+
# => [#<Chargify::Subscription:0x1020fff70 @prefix_options={}, @attributes={"cancellation_message"=>nil, "activated_at"=>Tue Nov 17 15:51:42 UTC 2009, "expires_at"=>nil, "updated_at"=>Tue Nov 17 15:51:41 UTC 2009, "credit_card"=>#<Chargify::Subscription::CreditCard:0x1020f24d8 @prefix_options={}, @attributes={"card_type"=>"bogus", "expiration_year"=>2015, "masked_card_number"=>"XXXX-XXXX-XXXX-2", "first_name"=>"Michael", "expiration_month"=>1, "last_name"=>"Klett"}>, "product"=>#<Chargify::Product:0x1020f5a70 @prefix_options={}, @attributes={"price_in_cents"=>0, "name"=>"Chargify API Ares Test", "handle"=>"chargify-api-ares-test", "product_family"=>#<Chargify::Product::ProductFamily:0x1020f48f0 @prefix_options={}, @attributes={"name"=>"Chargify API ARes Test", "handle"=>"chargify-api-ares-test", "id"=>79, "accounting_code"=>nil}>, "id"=>153, "accounting_code"=>nil, "interval_unit"=>"month", "interval"=>1}>, "trial_ended_at"=>nil, "id"=>328, "current_period_ends_at"=>Thu Dec 17 15:51:41 UTC 2009, "trial_started_at"=>nil, "customer"=>#<Chargify::Customer:0x1020f6d80 @prefix_options={}, @attributes={"reference"=>"moklett", "updated_at"=>Tue Nov 17 15:51:02 UTC 2009, "id"=>331, "first_name"=>"Michael", "organization"=>"Chargify", "last_name"=>"Klett", "email"=>"moklett@example.com", "created_at"=>Tue Nov 17 15:51:02 UTC 2009}>, "balance_in_cents"=>0, "current_period_started_at"=>Tue Nov 17 15:51:41 UTC 2009, "state"=>"canceled", "created_at"=>Tue Nov 17 15:51:41 UTC 2009}>]]
|
17
|
+
|
18
|
+
|
19
|
+
# Create a subscription from a customer reference
|
20
|
+
subscription = Chargify::Subscription.create(
|
21
|
+
:customer_reference => 'moklett',
|
22
|
+
:product_handle => 'chargify-api-ares-test',
|
23
|
+
:credit_card_attributes => {
|
24
|
+
:first_name => "Michael",
|
25
|
+
:last_name => "Klett",
|
26
|
+
:expiration_month => 1,
|
27
|
+
:expiration_year => 2020,
|
28
|
+
:full_number => "1"
|
29
|
+
}
|
30
|
+
)
|
31
|
+
# => #<Chargify::Subscription:0x1020ed4b0 @prefix_options={}, @attributes={"cancellation_message"=>nil, "activated_at"=>Tue Nov 17 16:00:17 UTC 2009, "expires_at"=>nil, "updated_at"=>Tue Nov 17 16:00:17 UTC 2009, "credit_card"=>#<Chargify::Subscription::CreditCard:0x102046b10 @prefix_options={}, @attributes={"card_type"=>"bogus", "expiration_year"=>2020, "masked_card_number"=>"XXXX-XXXX-XXXX-1", "first_name"=>"Michael", "expiration_month"=>1, "last_name"=>"Klett"}>, "product"=>#<Chargify::Product:0x10204a2d8 @prefix_options={}, @attributes={"price_in_cents"=>0, "name"=>"Chargify API Ares Test", "handle"=>"chargify-api-ares-test", "product_family"=>#<Chargify::Product::ProductFamily:0x1020490b8 @prefix_options={}, @attributes={"name"=>"Chargify API ARes Test", "handle"=>"chargify-api-ares-test", "id"=>79, "accounting_code"=>nil}>, "id"=>153, "accounting_code"=>nil, "interval_unit"=>"month", "interval"=>1}>, "credit_card_attributes"=>#<Chargify::Subscription::CreditCardAttributes:0x1020ecab0 @prefix_options={}, @attributes={"expiration_year"=>2020, "full_number"=>"1", "first_name"=>"Michael", "expiration_month"=>1, "last_name"=>"Klett"}>, "trial_ended_at"=>nil, "id"=>331, "current_period_ends_at"=>Thu Dec 17 16:00:17 UTC 2009, "product_handle"=>"chargify-api-ares-test", "trial_started_at"=>nil, "customer"=>#<Chargify::Customer:0x10204b688 @prefix_options={}, @attributes={"reference"=>"moklett", "updated_at"=>Tue Nov 17 15:51:02 UTC 2009, "id"=>331, "first_name"=>"Michael", "organization"=>"Chargify", "last_name"=>"Klett", "email"=>"moklett@example.com", "created_at"=>Tue Nov 17 15:51:02 UTC 2009}>, "balance_in_cents"=>0, "current_period_started_at"=>Tue Nov 17 16:00:17 UTC 2009, "state"=>"active", "created_at"=>Tue Nov 17 16:00:17 UTC 2009, "customer_reference"=>"moklett"}>
|
32
|
+
|
33
|
+
|
34
|
+
# Update credit card information
|
35
|
+
subscription.credit_card_attributes = {:full_number => "2", :expiration_year => "2015"}
|
36
|
+
subscription.save
|
37
|
+
# => #<Chargify::Subscription:0x1020ed4b0 @prefix_options={}, @attributes={"cancellation_message"=>nil, "activated_at"=>Tue Nov 17 16:00:17 UTC 2009, "expires_at"=>nil, "updated_at"=>Tue Nov 17 16:00:17 UTC 2009, "credit_card"=>#<Chargify::Subscription::CreditCard:0x1023ba878 @prefix_options={}, @attributes={"card_type"=>"bogus", "expiration_year"=>2015, "masked_card_number"=>"XXXX-XXXX-XXXX-2", "first_name"=>"Michael", "expiration_month"=>1, "last_name"=>"Klett"}>, "product"=>#<Chargify::Product:0x1023baa80 @prefix_options={}, @attributes={"price_in_cents"=>0, "name"=>"Chargify API Ares Test", "handle"=>"chargify-api-ares-test", "product_family"=>#<Chargify::Product::ProductFamily:0x1023c04d0 @prefix_options={}, @attributes={"name"=>"Chargify API ARes Test", "handle"=>"chargify-api-ares-test", "id"=>79, "accounting_code"=>nil}>, "id"=>153, "accounting_code"=>nil, "interval_unit"=>"month", "interval"=>1}>, "credit_card_attributes"=>{:full_number=>"2", :expiration_year=>"2015"}, "trial_ended_at"=>nil, "id"=>331, "current_period_ends_at"=>Thu Dec 17 16:00:17 UTC 2009, "product_handle"=>"chargify-api-ares-test", "customer"=>#<Chargify::Customer:0x1023bae40 @prefix_options={}, @attributes={"reference"=>"moklett", "updated_at"=>Tue Nov 17 15:51:02 UTC 2009, "id"=>331, "first_name"=>"Michael", "organization"=>"Chargify", "last_name"=>"Klett", "email"=>"moklett@example.com", "created_at"=>Tue Nov 17 15:51:02 UTC 2009}>, "trial_started_at"=>nil, "balance_in_cents"=>0, "current_period_started_at"=>Tue Nov 17 16:00:17 UTC 2009, "state"=>"active", "created_at"=>Tue Nov 17 16:00:17 UTC 2009, "customer_reference"=>"moklett"}>
|
38
|
+
|
39
|
+
|
40
|
+
# Cancel a subscription
|
41
|
+
subscription.cancel
|
42
|
+
subscription.reload
|
43
|
+
# => #<Chargify::Subscription:0x1020ed4b0 @prefix_options={}, @attributes={"cancellation_message"=>nil, "activated_at"=>Tue Nov 17 16:00:17 UTC 2009, "expires_at"=>nil, "updated_at"=>Tue Nov 17 16:00:17 UTC 2009, "credit_card"=>#<Chargify::Subscription::CreditCard:0x10234f168 @prefix_options={}, @attributes={"card_type"=>"bogus", "expiration_year"=>2015, "masked_card_number"=>"XXXX-XXXX-XXXX-2", "first_name"=>"Michael", "expiration_month"=>1, "last_name"=>"Klett"}>, "product"=>#<Chargify::Product:0x10234f370 @prefix_options={}, @attributes={"price_in_cents"=>0, "name"=>"Chargify API Ares Test", "handle"=>"chargify-api-ares-test", "product_family"=>#<Chargify::Product::ProductFamily:0x102354708 @prefix_options={}, @attributes={"name"=>"Chargify API ARes Test", "handle"=>"chargify-api-ares-test", "id"=>79, "accounting_code"=>nil}>, "id"=>153, "accounting_code"=>nil, "interval_unit"=>"month", "interval"=>1}>, "credit_card_attributes"=>{:full_number=>"2", :expiration_year=>"2015"}, "trial_ended_at"=>nil, "id"=>331, "current_period_ends_at"=>Thu Dec 17 16:00:17 UTC 2009, "product_handle"=>"chargify-api-ares-test", "customer"=>#<Chargify::Customer:0x10234f730 @prefix_options={}, @attributes={"reference"=>"moklett", "updated_at"=>Tue Nov 17 15:51:02 UTC 2009, "id"=>331, "first_name"=>"Michael", "organization"=>"Chargify", "last_name"=>"Klett", "email"=>"moklett@example.com", "created_at"=>Tue Nov 17 15:51:02 UTC 2009}>, "trial_started_at"=>nil, "balance_in_cents"=>0, "current_period_started_at"=>Tue Nov 17 16:00:17 UTC 2009, "state"=>"canceled", "created_at"=>Tue Nov 17 16:00:17 UTC 2009, "customer_reference"=>"moklett"}>
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chargify_api_ares
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Klett
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-17 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: ""
|
17
|
+
email: mklett@grasshopper.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- LICENSE.txt
|
28
|
+
- README.md
|
29
|
+
- Rakefile
|
30
|
+
- VERSION
|
31
|
+
- chargify_api_ares.gemspec
|
32
|
+
- lib/chargify_api_ares.rb
|
33
|
+
- samples/customers.rb
|
34
|
+
- samples/products.rb
|
35
|
+
- samples/subscriptions.rb
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/grasshopperlabs/chargify_api_ares
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --charset=UTF-8
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.3.5
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: A Chargify API wrapper for Ruby using ActiveResource
|
64
|
+
test_files: []
|
65
|
+
|