chargify_api_ares 0.4.4 → 0.5.0
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 +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +57 -0
- data/Guardfile +15 -0
- data/README.md +29 -37
- data/Rakefile +12 -5
- data/chargify_api_ares.gemspec +25 -63
- data/examples/coupons.rb +50 -0
- data/{samples → examples}/customers.rb +1 -1
- data/{samples → examples}/metered_components.rb +5 -2
- data/{samples → examples}/products.rb +1 -1
- data/{samples → examples}/subscriptions.rb +2 -2
- data/{samples → examples}/transactions.rb +2 -3
- data/lib/chargify_api_ares.rb +14 -314
- data/lib/chargify_api_ares/config.rb +16 -0
- data/lib/chargify_api_ares/resources/base.rb +14 -0
- data/lib/chargify_api_ares/resources/component.rb +4 -0
- data/lib/chargify_api_ares/resources/coupon.rb +19 -0
- data/lib/chargify_api_ares/resources/customer.rb +21 -0
- data/lib/chargify_api_ares/resources/payment_profile.rb +4 -0
- data/lib/chargify_api_ares/resources/product.rb +25 -0
- data/lib/chargify_api_ares/resources/product_family.rb +34 -0
- data/lib/chargify_api_ares/resources/site.rb +7 -0
- data/lib/chargify_api_ares/resources/statement.rb +4 -0
- data/lib/chargify_api_ares/resources/subscription.rb +123 -0
- data/lib/chargify_api_ares/resources/transaction.rb +17 -0
- data/lib/chargify_api_ares/resources/usage.rb +11 -0
- data/spec/factories.rb +28 -24
- data/spec/remote/remote.example.yml +6 -0
- data/spec/remote/remote_spec.rb +347 -452
- data/spec/remote/spec_helper.rb +11 -15
- data/spec/{base_spec.rb → resources/base_spec.rb} +1 -1
- data/spec/resources/coupon_spec.rb +35 -0
- data/spec/resources/customer_spec.rb +36 -0
- data/spec/resources/product_family_spec.rb +57 -0
- data/spec/resources/product_spec.rb +23 -0
- data/spec/{subscriptions_component_spec.rb → resources/subscription_component_spec.rb} +2 -2
- data/spec/{subscription_spec.rb → resources/subscription_spec.rb} +2 -2
- data/spec/resources/usage_spec.rb +44 -0
- data/spec/spec_helper.rb +6 -8
- data/spec/{mocks → support}/fake_resource.rb +0 -0
- metadata +148 -29
- data/VERSION +0 -1
- data/config/remote.example.yml +0 -7
- data/spec/components_spec.rb +0 -48
- data/spec/customer_spec.rb +0 -23
- data/spec/product_spec.rb +0 -23
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.9
|
data/config/remote.example.yml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# Copy this file to config/remote.yml and make adjustments as necessary.
|
2
|
-
#
|
3
|
-
# Note: Remote tests will only work when configured to run on a test site that uses the Bogus gateway.
|
4
|
-
# Warning: all data in the site specified by 'subdomain' will be cleared and replaced with test data.
|
5
|
-
run_tests: true
|
6
|
-
subdomain: yoursubdomain
|
7
|
-
api_key: xxx
|
data/spec/components_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Chargify::Component do
|
4
|
-
describe "Recording usage" do
|
5
|
-
before do
|
6
|
-
@subscription = Factory(:subscription)
|
7
|
-
@component = Factory(:component)
|
8
|
-
@now = DateTime.now.to_s
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should create a usage record" do
|
12
|
-
u = Chargify::Usage.new
|
13
|
-
u.subscription_id = @subscription.id
|
14
|
-
u.component_id = @component.id
|
15
|
-
u.quantity = 5
|
16
|
-
u.memo = @now
|
17
|
-
u.save
|
18
|
-
|
19
|
-
component = Chargify::Usage.find(:last, :params => {:subscription_id => @subscription.id, :component_id => @component.id})
|
20
|
-
component.memo.should == @now
|
21
|
-
component.quantity.should == 5
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "Listing usages" do
|
26
|
-
before do
|
27
|
-
@subscription = Factory(:subscription)
|
28
|
-
@component = Factory(:component)
|
29
|
-
@now = DateTime.now.to_s
|
30
|
-
create_usage
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should return all usages for a component and subscription" do
|
34
|
-
component = Chargify::Usage.find(:last, :params => {:subscription_id => @subscription.id, :component_id => @component.id})
|
35
|
-
component.quantity.should == 5
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def create_usage
|
40
|
-
u = Chargify::Usage.new
|
41
|
-
u.subscription_id = @subscription.id
|
42
|
-
u.component_id = @component.id
|
43
|
-
u.quantity = 5
|
44
|
-
u.memo = @now
|
45
|
-
u.save
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
data/spec/customer_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Chargify::Customer do
|
4
|
-
|
5
|
-
context 'find by reference' do
|
6
|
-
before do
|
7
|
-
@reference = 'ref0123'
|
8
|
-
@existing_customer = Factory(:customer, :reference => @reference, :id => FactoryGirl.generate(:customer_id))
|
9
|
-
FakeWeb.register_uri(:get, "#{test_domain}/customers/lookup.xml?reference=#{@existing_customer.reference}", :body => @existing_customer.attributes.to_xml)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'finds the correct customer by reference' do
|
13
|
-
customer = Chargify::Customer.find_by_reference(@reference)
|
14
|
-
customer.should eql(@existing_customer)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'is an instance of Chargify::Customer' do
|
18
|
-
customer = Chargify::Customer.find_by_reference(@reference)
|
19
|
-
customer.should be_instance_of(Chargify::Customer)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/spec/product_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Chargify::Product do
|
4
|
-
|
5
|
-
context 'find by handle' do
|
6
|
-
before do
|
7
|
-
@handle = 'handle1'
|
8
|
-
@existing_product = Factory(:product, :handle => @handle, :id => FactoryGirl.generate(:product_id))
|
9
|
-
FakeWeb.register_uri(:get, "#{test_domain}/products/lookup.xml?handle=#{@existing_product.handle}", :body => @existing_product.attributes.to_xml)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'finds the correct product by handle' do
|
13
|
-
product = Chargify::Product.find_by_handle(@handle)
|
14
|
-
product.should eql(@existing_product)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'is an instance of Chargify::Product' do
|
18
|
-
product = Chargify::Product.find_by_handle(@handle)
|
19
|
-
product.should be_instance_of(Chargify::Product)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|