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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7762b872f5e635edf9da78afd40176ca1f61469c
4
- data.tar.gz: c8d358f84e5d72479f65bc1db419ebc56a96eb14
3
+ metadata.gz: 18d3cbfe259be3700b30379d0a68c59aea9be212
4
+ data.tar.gz: b762d05518e15a05b1da35f31b849ff543c7afa6
5
5
  SHA512:
6
- metadata.gz: df525f141c80e4c625761855cf3044fdcc17eb93ee7309e288e0fe9467091f75203462299940e0df8d0c122c9b4c808211aaa0ebe34e0af3af46480a3e9e3960
7
- data.tar.gz: 44dfc600c43296034fa5c89bec8fb6717707052ae5808ee1b9cd2712eac4454485e4bb5e2c8e7489444ae76d732dc0f847da636b5b07756e22e15a824c5c6e0d
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::Ruby
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-ruby)
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
- TODO: Add description.
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-ruby'
16
+ gem 'aptible-billing'
14
17
 
15
18
  And then run `bundle install`.
16
19
 
17
20
  ## Usage
18
21
 
19
- TODO: Add usage notes.
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), Blake Pettersson, and contributors.
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'
@@ -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: ENV['APTIBLE_BILLING_ROOT_URL'] || 'https://billing.aptible.com'
12
- end
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 :billing_contact_id
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
@@ -14,4 +14,4 @@ module Aptible
14
14
  end
15
15
  end
16
16
 
17
- require 'aptible/billing/billing_detail'
17
+ require 'aptible/billing/billing_detail'
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Billing
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  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 be_true
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 be_false
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 be_true
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 be_false
23
+ expect(subject.subscribed?).to be false
25
24
  end
26
25
  end
27
- end
26
+ end
@@ -4,4 +4,4 @@ require 'rspec/its'
4
4
  describe Aptible::Billing::Resource do
5
5
  its(:namespace) { should eq 'Aptible::Billing' }
6
6
  its(:root_url) { should eq 'https://billing.aptible.com' }
7
- end
7
+ 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 |config|
24
- config.root_url = 'http://foobar.com'
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
@@ -1,4 +1,4 @@
1
- def set_env(*args, &block)
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
@@ -9,7 +9,6 @@ end
9
9
  # Require library up front
10
10
  require 'aptible/billing'
11
11
 
12
-
13
12
  RSpec.configure do |config|
14
13
  config.before { Aptible::Billing.configuration.reset }
15
- end
14
+ end
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.0
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-05 00:00:00.000000000 Z
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: []