chargify_api_ares 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg
5
5
  .ruby-version
6
6
  .bundle/
7
7
  bin/
8
+ .rbenv-version
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chargify_api_ares (0.6.0)
4
+ chargify_api_ares (0.6.1)
5
5
  activeresource (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -67,6 +67,7 @@ DEPENDENCIES
67
67
  fakeweb (~> 1.3.0)
68
68
  growl (~> 1.0.3)
69
69
  guard-rspec (~> 2.4.0)
70
+ pry (~> 0.9.12)
70
71
  rake (~> 10.0.3)
71
72
  rb-fsevent (~> 0.9.2)
72
73
  rspec (~> 2.12.0)
data/README.md CHANGED
@@ -6,6 +6,42 @@ Chargify API wrapper for Ruby (using ActiveResource)
6
6
 
7
7
  This is a Ruby wrapper for the [Chargify](http://chargify.com) API that leverages ActiveResource.
8
8
 
9
+ To configure api key, site, domain, and protocol you can do the
10
+ following. Please note that this step is required.
11
+
12
+ Most common usage
13
+ ----------------
14
+
15
+ ``` ruby
16
+ Chargify.configure do |c|
17
+ c.api_key = "your_key_goes_here"
18
+ c.subdomain = "test-site"
19
+ end
20
+ ```
21
+
22
+ Overriding the endpoint
23
+ --------------
24
+
25
+ ``` ruby
26
+ Chargify.configure do |c|
27
+ c.api_key = "your_key_goes_here"
28
+ c.site = "https://test-site.some-domain.com"
29
+ end
30
+ ```
31
+
32
+ Available configuration options
33
+ -------------------------------
34
+
35
+ | Name | Description | Default | Required |
36
+ | ----------------- | ----------------------------------------------------------------------------------- | --------- | -------------------------- |
37
+ | api_key | The api_key credentials that are used to access your chargify account. | N/A | Yes |
38
+ | subdomain | The subdomain (site name) of the chargify endpoint you are trying to interact with | test | Yes (unless site was used) |
39
+ | domain | The domain of the endpoint, in which you want to interact with. | chargify.com | No |
40
+ | protocol | The endpoint protocol that you wish to use (http / https) | https | No |
41
+ | site | This is meant to override all three of the previous settings eg: http://foo.bar.com | N/A | No |
42
+ | format | The format of the request and response type that you want to deal with | xml | No |
43
+ | timeout | The time in seconds for a request to be valid. Will raise a timeout error if exceeds time limit. | N/A | No |
44
+
9
45
  It allows you to interface with the Chargify API using simple ActiveRecord-like syntax, i.e.:
10
46
 
11
47
  ``` ruby
@@ -4,11 +4,11 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.7'
5
5
 
6
6
  s.name = 'chargify_api_ares'
7
- s.version = '0.6.0'
8
- s.date = '2013-02-16'
7
+ s.version = '0.6.1'
8
+ s.date = '2013-02-26'
9
9
  s.summary = 'A Chargify API wrapper for Ruby using ActiveResource'
10
10
  s.description = ''
11
- s.authors = ["Michael Klett", "Nathan Verni", "Graham McIntire", "Rodrigo Franco", "Shay Frendt"]
11
+ s.authors = ["Michael Klett", "Nathan Verni", "Graham McIntire", "Jeremy W. Rowe", "Rodrigo Franco", "Shay Frendt"]
12
12
  s.email = 'support@chargify.com'
13
13
  s.homepage = 'http://github.com/chargify/chargify_api_ares'
14
14
 
@@ -28,4 +28,5 @@ Gem::Specification.new do |s|
28
28
  s.add_development_dependency('guard-rspec', '~> 2.4.0')
29
29
  s.add_development_dependency('growl', '~> 1.0.3')
30
30
  s.add_development_dependency('rb-fsevent', '~> 0.9.2')
31
+ s.add_development_dependency('pry', '~> 0.9.12')
31
32
  end
@@ -1,18 +1,18 @@
1
1
  module Chargify
2
2
  class << self
3
- attr_accessor :subdomain, :api_key, :site, :format, :timeout
3
+ attr_accessor :subdomain, :api_key, :site, :format, :timeout, :domain, :protocol
4
4
 
5
5
  def configure
6
6
  yield self
7
-
7
+ self.protocol = protocol || "https"
8
+ self.domain = domain || "chargify.com"
9
+ self.format = format || :xml
10
+ self.subdomain = subdomain || "test"
8
11
  Base.user = api_key
9
12
  Base.password = 'X'
10
13
  Base.timeout = timeout unless (timeout.blank?)
11
-
12
- self.site ||= "https://#{subdomain}.chargify.com"
13
- Base.site = site
14
- self.format ||= :xml
15
- Base.format = format
14
+ Base.site = site || "#{protocol}://#{subdomain}.#{domain}"
15
+ Base.format = format
16
16
  end
17
17
  end
18
18
  end
@@ -2,5 +2,8 @@
2
2
  #
3
3
  # Note: Remote tests will only work when configured to run on a test site that uses the Bogus gateway.
4
4
  # Warning: All data in the site specified will be cleared and replaced with test data.
5
- api_key: your_api_key
6
- site: your_site
5
+ api_key: your_api_key # your api key for your login (Required)
6
+ subdomain: your_site # the subdomain for the site you wish to test (Required)
7
+ #domain: ".foo.dev" # this is optional to point to a local version of chargify
8
+ #protocol: "http" # this is an optional value to use https or http
9
+ #site: "http://doo.foo-com" # this is optional to override the entire url
@@ -10,8 +10,11 @@ end
10
10
  RSpec.configure do |config|
11
11
  config.before(:all) do
12
12
  Chargify.configure do |c|
13
- c.api_key = remote_configuration['api_key']
14
- c.site = remote_configuration['site']
13
+ c.api_key = remote_configuration['api_key']
14
+ c.protocol = remote_configuration['protocol'] if remote_configuration['protocol']
15
+ c.domain = remote_configuration['domain'] if remote_configuration['domain']
16
+ c.subdomain = remote_configuration['subdomain'] if remote_configuration['subdomain']
17
+ c.site = remote_configuration['site'] if remote_configuration['site']
15
18
  end
16
19
  end
17
20
  end
@@ -34,9 +34,9 @@ describe "Remote" do
34
34
  :email => "john.doe@example.com",
35
35
  :reference => "johndoe")
36
36
  end
37
-
37
+
38
38
  let(:johnadoes_credit_card) { Chargify::PaymentProfile.create(good_payment_profile_attributes.merge(:customer_id => johnadoe.id)) }
39
-
39
+
40
40
  before(:all) do
41
41
  # Make sure the test site data is set up correctly
42
42
  clear_site_data; acme_projects; basic_plan; pro_plan; johnadoe; johnadoes_credit_card
@@ -46,16 +46,16 @@ describe "Remote" do
46
46
  context "when providing valid attributes for the customer and the payment profile" do
47
47
  before(:all) do
48
48
  @subscription = Chargify::Subscription.create(
49
- :product_handle => basic_plan.handle,
49
+ :product_handle => basic_plan.handle,
50
50
  :customer_attributes => {
51
51
  :first_name => "Rick",
52
52
  :last_name => "James",
53
53
  :email => "rick@example.com",
54
54
  :reference => "rickjames"
55
- },
56
- :payment_profile_attributes => good_payment_profile_attributes)
55
+ },
56
+ :payment_profile_attributes => good_payment_profile_attributes)
57
57
  end
58
-
58
+
59
59
  it "sets the current_period_started_at attribute to now" do
60
60
  @subscription.current_period_started_at.utc.should be_within(60).of(now.utc)
61
61
  end
@@ -128,7 +128,7 @@ describe "Remote" do
128
128
  :last_name => "Marley",
129
129
  :email => "ziggy@example.com",
130
130
  :reference => "ziggy"
131
- },
131
+ },
132
132
  :payment_profile_attributes => unstorable_payment_profile_attributes)
133
133
  end
134
134
 
@@ -155,7 +155,7 @@ describe "Remote" do
155
155
  :last_name => "Denver",
156
156
  :email => "john.denver@example.com",
157
157
  :reference => "johndenver"
158
- },
158
+ },
159
159
  :payment_profile_attributes => pretokenized_card_attributes,
160
160
  :next_billing_at => ten_days_from_now.utc)
161
161
  @subscription.should be_a(Chargify::Subscription)
@@ -185,10 +185,14 @@ describe "Remote" do
185
185
  :last_name => "Sinatra",
186
186
  :email => "frank.sinatra@example.com",
187
187
  :reference => "franksinatra"
188
- },
188
+ },
189
189
  :payment_profile_attributes => declined_payment_profile_attributes)
190
190
  end
191
191
 
192
+ it "returns the correct error message" do
193
+ @subscription.errors[:base].should include "Bogus Gateway: Forced failure"
194
+ end
195
+
192
196
  it "does not create the subscription" do
193
197
  @subscription.should_not be_valid
194
198
  end
@@ -281,7 +285,7 @@ describe "Remote" do
281
285
  context "via Chargify::Subscription#refund" do
282
286
  it "creates a refund" do
283
287
  lambda{
284
- @subscription.refund :payment_id => @payment.id, :amount => 7,
288
+ @subscription.refund :payment_id => @payment.id, :amount => 7,
285
289
  :memo => 'Refunding One Time Charge'
286
290
  }.should change{@subscription.reload.transactions.size}.by(1)
287
291
 
@@ -313,7 +317,7 @@ describe "Remote" do
313
317
  tx.transaction_type.should == 'refund'
314
318
  end
315
319
  end
316
-
320
+
317
321
  describe 'Webhooks' do
318
322
  before(:all) do
319
323
  @subscription = Chargify::Subscription.create(
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'bundler'
4
4
  Bundler.require(:default, :development)
5
5
 
6
6
  require 'support/fake_resource'
7
+ require 'pry'
7
8
 
8
9
  FactoryGirl.find_definitions
9
10
  ActiveResource::Base.send :include, ActiveResource::FakeResource
@@ -13,7 +14,7 @@ Chargify.configure do |c|
13
14
  c.subdomain = 'test'
14
15
  c.api_key = 'test'
15
16
  end
16
-
17
+
17
18
  RSpec.configure do |config|
18
19
  config.filter_run :focused => true
19
20
  config.run_all_when_everything_filtered = true
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chargify_api_ares
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Klett
9
9
  - Nathan Verni
10
10
  - Graham McIntire
11
+ - Jeremy W. Rowe
11
12
  - Rodrigo Franco
12
13
  - Shay Frendt
13
14
  autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
- date: 2013-02-16 00:00:00.000000000 Z
17
+ date: 2013-02-26 00:00:00.000000000 Z
17
18
  dependencies:
18
19
  - !ruby/object:Gem::Dependency
19
20
  name: activeresource
@@ -159,6 +160,22 @@ dependencies:
159
160
  - - ~>
160
161
  - !ruby/object:Gem::Version
161
162
  version: 0.9.2
163
+ - !ruby/object:Gem::Dependency
164
+ name: pry
165
+ requirement: !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ~>
169
+ - !ruby/object:Gem::Version
170
+ version: 0.9.12
171
+ type: :development
172
+ prerelease: false
173
+ version_requirements: !ruby/object:Gem::Requirement
174
+ none: false
175
+ requirements:
176
+ - - ~>
177
+ - !ruby/object:Gem::Version
178
+ version: 0.9.12
162
179
  description: ''
163
180
  email: support@chargify.com
164
181
  executables: []
@@ -225,6 +242,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
242
  - - ! '>='
226
243
  - !ruby/object:Gem::Version
227
244
  version: '0'
245
+ segments:
246
+ - 0
247
+ hash: 4368782760728078099
228
248
  required_rubygems_version: !ruby/object:Gem::Requirement
229
249
  none: false
230
250
  requirements: