aptible-billing 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -6
- data/aptible-billing-ruby.gemspec +1 -1
- data/lib/aptible/billing.rb +3 -2
- data/lib/aptible/billing/billing_detail.rb +3 -2
- data/lib/aptible/billing/resource.rb +1 -1
- data/lib/aptible/billing/version.rb +1 -1
- data/spec/aptible/billing/billing_detail_spec.rb +5 -6
- data/spec/aptible/billing/resource_spec.rb +1 -1
- data/spec/aptible/billing_spec.rb +3 -3
- data/spec/shared/set_env.rb +2 -2
- data/spec/spec_helper.rb +1 -2
- metadata +3 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18d3cbfe259be3700b30379d0a68c59aea9be212
|
4
|
+
data.tar.gz: b762d05518e15a05b1da35f31b849ff543c7afa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ff70c7f14861ce52fb3d97e6a8bbdbbe0f1b4b8f4111c7671435f4452f117ca43d1e4501004a2a2f9dde6035ca9698e897016928e264c567e68fe93046ce88d
|
7
|
+
data.tar.gz: 1d5b1c3a014c34b87ebc493a447e3930b7a6b75fb1a52c13e447a672cb87d7644cc42ee90495c4bf87340dd013a988f8ba796fbcddfb2a2831f8248815063c0f
|
data/README.md
CHANGED
@@ -1,22 +1,52 @@
|
|
1
|
-
# ![](https://raw.github.com/aptible/straptible/master/lib/straptible/rails/templates/public.api/icon-60px.png) Aptible::Billing
|
1
|
+
# ![](https://raw.github.com/aptible/straptible/master/lib/straptible/rails/templates/public.api/icon-60px.png) Aptible::Billing
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/aptible-billing-ruby.png)](https://rubygems.org/gems/aptible-billing
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/aptible-billing-ruby.png)](https://rubygems.org/gems/aptible-billing)
|
4
4
|
[![Build Status](https://travis-ci.org/aptible/aptible-billing-ruby.png?branch=master)](https://travis-ci.org/aptible/aptible-billing-ruby)
|
5
5
|
[![Dependency Status](https://gemnasium.com/aptible/aptible-billing-ruby.png)](https://gemnasium.com/aptible/aptible-billing-ruby)
|
6
6
|
|
7
|
-
|
7
|
+
Ruby client for [billing.aptible.com](https://billing.aptible.com/). Aptible's billing server is built on top of
|
8
|
+
[OAuth 2.0](http://tools.ietf.org/html/rfc6749) and [HAL+JSON](http://tools.ietf.org/html/draft-kelly-json-hal-06),
|
9
|
+
and so this client is just a thin layer on top of the [oauth2](https://github.com/intridea/oauth2)
|
10
|
+
and [HyperResource](https://github.com/gamache/hyperresource) gems.
|
8
11
|
|
9
12
|
## Installation
|
10
13
|
|
11
14
|
Add the following line to your application's Gemfile.
|
12
15
|
|
13
|
-
gem 'aptible-billing
|
16
|
+
gem 'aptible-billing'
|
14
17
|
|
15
18
|
And then run `bundle install`.
|
16
19
|
|
17
20
|
## Usage
|
18
21
|
|
19
|
-
|
22
|
+
First, get a token:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
token = Aptible::Auth::Token.create(email: 'user0@example.com', password: 'password')
|
26
|
+
```
|
27
|
+
|
28
|
+
From here, you can interact with the Billing API however you wish:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
billing_details = Aptible::Billing::BillingDetail.find(id: '1', token: token)
|
32
|
+
billing_details.href
|
33
|
+
# => "http://localhost:4000/billing_details/1"
|
34
|
+
```
|
35
|
+
|
36
|
+
## Configuration
|
37
|
+
|
38
|
+
| Parameter | Description | Default |
|
39
|
+
| --------- | ----------- | --------------- |
|
40
|
+
| `root_url` | Root URL of the billing server | `ENV['APTIBLE_BILLING_ROOT_URL']` or [https://billing.aptible.com](https://billing.aptible.com) |
|
41
|
+
|
42
|
+
To point the client at a different billing server (e.g., during development),
|
43
|
+
add the following to your application's initializers (or set the `APTIBLE_BILLING_ROOT_URL` environment variable):
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
Aptible::Billing.configure do |config|
|
47
|
+
config.root_url = 'http://some.other.url'
|
48
|
+
end
|
49
|
+
```
|
20
50
|
|
21
51
|
## Contributing
|
22
52
|
|
@@ -29,4 +59,6 @@ TODO: Add usage notes.
|
|
29
59
|
|
30
60
|
MIT License, see [LICENSE](LICENSE.md) for details.
|
31
61
|
|
32
|
-
Copyright (c) 2015 [Aptible](https://www.aptible.com),
|
62
|
+
Copyright (c) 2015 [Aptible](https://www.aptible.com), and contributors.
|
63
|
+
|
64
|
+
[<img src="https://s.gravatar.com/avatar/e5b35690e022507eb4df909d11ad4e23?s=60" style="border-radius: 50%;" alt="@blakepettersson" />](https://github.com/blakepettersson)
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.files = `git ls-files`.split($RS)
|
19
|
-
spec.test_files = spec.files.grep(/^spec
|
19
|
+
spec.test_files = spec.files.grep(%r{/^spec/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.add_dependency 'stripe', '>= 1.13.0'
|
data/lib/aptible/billing.rb
CHANGED
@@ -6,10 +6,11 @@ module Aptible
|
|
6
6
|
include GemConfig::Base
|
7
7
|
|
8
8
|
with_configuration do
|
9
|
+
override = ENV['APTIBLE_BILLING_ROOT_URL']
|
9
10
|
has :root_url,
|
10
11
|
classes: [String],
|
11
|
-
default:
|
12
|
-
|
12
|
+
default: override || 'https://billing.aptible.com'
|
13
|
+
end
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -10,7 +10,8 @@ module Aptible
|
|
10
10
|
field :stripe_subscription_id
|
11
11
|
field :stripe_subscription_status
|
12
12
|
field :plan
|
13
|
-
field :
|
13
|
+
field :billing_contact
|
14
|
+
field :organization
|
14
15
|
|
15
16
|
def stripe_customer
|
16
17
|
return nil if stripe_customer_id.nil?
|
@@ -32,4 +33,4 @@ module Aptible
|
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
35
|
-
end
|
36
|
+
end
|
@@ -1,27 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Aptible::Billing::BillingDetail do
|
4
|
-
|
5
4
|
describe '#can_manage_compliance?' do
|
6
5
|
it 'should return true with compliance plan' do
|
7
6
|
subject.stub(:plan) { 'production' }
|
8
|
-
expect(subject.can_manage_compliance?).to
|
7
|
+
expect(subject.can_manage_compliance?).to be true
|
9
8
|
end
|
10
9
|
|
11
10
|
it 'should return false without compliance plan' do
|
12
11
|
subject.stub(:plan) { 'platform' }
|
13
|
-
expect(subject.can_manage_compliance?).to
|
12
|
+
expect(subject.can_manage_compliance?).to be false
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
17
16
|
describe '#subscribed?' do
|
18
17
|
it 'should return true with valid subscription ID' do
|
19
18
|
subject.stub(:stripe_subscription_id) { 'sub_4YrmiVa3vMpaGA' }
|
20
|
-
expect(subject.subscribed?).to
|
19
|
+
expect(subject.subscribed?).to be true
|
21
20
|
end
|
22
21
|
|
23
22
|
it 'should return false without valid subscription ID' do
|
24
|
-
expect(subject.subscribed?).to
|
23
|
+
expect(subject.subscribed?).to be false
|
25
24
|
end
|
26
25
|
end
|
27
|
-
end
|
26
|
+
end
|
@@ -20,10 +20,10 @@ describe Aptible::Billing do
|
|
20
20
|
|
21
21
|
it 'should be able to override root_url programatically' do
|
22
22
|
config = described_class.configuration
|
23
|
-
Aptible::Billing.configure do |
|
24
|
-
|
23
|
+
Aptible::Billing.configure do |c|
|
24
|
+
c.root_url = 'http://foobar.com'
|
25
25
|
end
|
26
26
|
|
27
27
|
expect(config.root_url).to eq 'http://foobar.com'
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
data/spec/shared/set_env.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
def set_env(*args, &
|
1
|
+
def set_env(*args, &_block)
|
2
2
|
hash = args.first.is_a?(Hash) ? args.first : Hash[*args]
|
3
3
|
old_values = Hash[hash.map { |k, _| [k, ENV[k]] }]
|
4
4
|
begin
|
@@ -7,4 +7,4 @@ def set_env(*args, &block)
|
|
7
7
|
ensure
|
8
8
|
old_values.each { |k, v| ENV[k] = v }
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptible-billing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Pettersson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stripe
|
@@ -170,9 +170,4 @@ rubygems_version: 2.4.5
|
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Ruby client for billing.aptible.com
|
173
|
-
test_files:
|
174
|
-
- spec/aptible/billing/billing_detail_spec.rb
|
175
|
-
- spec/aptible/billing/resource_spec.rb
|
176
|
-
- spec/aptible/billing_spec.rb
|
177
|
-
- spec/shared/set_env.rb
|
178
|
-
- spec/spec_helper.rb
|
173
|
+
test_files: []
|