subsify 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +0 -0
- data/README.md +1 -0
- data/lib/subsify.rb +10 -0
- data/lib/subsify/account.rb +11 -0
- data/lib/subsify/card.rb +12 -0
- data/lib/subsify/client.rb +41 -0
- data/lib/subsify/customer.rb +13 -0
- data/lib/subsify/plan.rb +15 -0
- data/lib/subsify/subscription.rb +13 -0
- data/lib/subsify/token.rb +19 -0
- metadata +72 -0
data/LICENSE
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Subsify
|
data/lib/subsify.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative './lib/account'
|
2
|
+
require_relative './lib/card'
|
3
|
+
require_relative './lib/plan'
|
4
|
+
require_relative './lib/token'
|
5
|
+
require_relative './lib/customer'
|
6
|
+
require_relative './lib/subscription'
|
7
|
+
require_relative './lib/client'
|
8
|
+
|
9
|
+
module Subsify
|
10
|
+
end
|
data/lib/subsify/card.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Subsify
|
2
|
+
class Client
|
3
|
+
|
4
|
+
def initialize(options={})
|
5
|
+
@host = options[:host] || 'subsify.com'
|
6
|
+
@protocol = options[:protocol] || 'https'
|
7
|
+
@client_id = options[:client_id]
|
8
|
+
@client_secret = options[:client_secret]
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_token(options={})
|
12
|
+
res = RestClient.post(
|
13
|
+
"#{self.url}/v1/tokens",
|
14
|
+
{
|
15
|
+
:ip_address => options[:ip_address],
|
16
|
+
:callback_url => options[:callback],
|
17
|
+
:plan => options[:plan]
|
18
|
+
}
|
19
|
+
)
|
20
|
+
return Subsify::Token.new(JSON.parse(res)['token'])
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_customer(options={})
|
24
|
+
res = RestClient.get(
|
25
|
+
"#{self.url}/v1/customers/#{options[:id]}",
|
26
|
+
)
|
27
|
+
return Subsify::Customer.new(JSON.parse(res)['customer'])
|
28
|
+
end
|
29
|
+
|
30
|
+
def cancel_subscription(options={})
|
31
|
+
res = RestClient.delete(
|
32
|
+
"#{self.url}/v1/customers/#{options[:id]}/subscription",
|
33
|
+
)
|
34
|
+
JSON.parse(res)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.url
|
38
|
+
"#{@protocol}://#{@client_id}:#{@client_secret}@#{@host}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Subsify
|
2
|
+
|
3
|
+
class Customer
|
4
|
+
attr_reader :id, :account, :subscription, :card
|
5
|
+
def initialize(data)
|
6
|
+
@id = data['id']
|
7
|
+
@account = Account.new(data['account']) if data['account']
|
8
|
+
@subscription = Subscription.new(data['subscription']) if data['subscription']
|
9
|
+
@card = Card.new(data['card']) if data['card']
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/lib/subsify/plan.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Subsify
|
2
|
+
|
3
|
+
class Plan
|
4
|
+
attr_reader :id, :description, :amount, :currency, :currency_symbol, :interval
|
5
|
+
def initialize(data)
|
6
|
+
@id = data['id']
|
7
|
+
@description = data['description']
|
8
|
+
@amount = data['amount']
|
9
|
+
@currency = data['currency']
|
10
|
+
@currency_symbol = data['currency_symbol']
|
11
|
+
@interval = data['interval']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Subsify
|
2
|
+
|
3
|
+
class Subscription
|
4
|
+
attr_reader :status, :plan, :expires_on, :next_payment_due
|
5
|
+
def initialize(data)
|
6
|
+
@next_payment_due = Date.parse(data['next_payment_due'])
|
7
|
+
@status = data['status']
|
8
|
+
@expires_on = data['expires_on']
|
9
|
+
@plan = Plan.new(data['plan']) if data['plan']
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Subsify
|
2
|
+
|
3
|
+
class Token
|
4
|
+
attr_reader :id, :country, :vat, :customer_ip, :merchant_ip, :plan
|
5
|
+
def initialize(data)
|
6
|
+
@id = data['id']
|
7
|
+
@country = data['country']
|
8
|
+
@vat = data['vat']
|
9
|
+
@customer_ip = data['customer_ip']
|
10
|
+
@merchant_ip = data['merchant_ip']
|
11
|
+
@plan = Plan.new(data['plan']) if data['plan']
|
12
|
+
end
|
13
|
+
|
14
|
+
def vat?
|
15
|
+
@vat
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: subsify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Richard Taylor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.7
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.7
|
30
|
+
description: subsify is a Ruby client for the Subsify Subscription Payment API.
|
31
|
+
email: moomerman@gmail.com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- lib/subsify.rb
|
39
|
+
- lib/subsify/account.rb
|
40
|
+
- lib/subsify/card.rb
|
41
|
+
- lib/subsify/client.rb
|
42
|
+
- lib/subsify/customer.rb
|
43
|
+
- lib/subsify/plan.rb
|
44
|
+
- lib/subsify/subscription.rb
|
45
|
+
- lib/subsify/token.rb
|
46
|
+
homepage: http://github.com/moocode/subsify_ruby
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options:
|
50
|
+
- --inline-source
|
51
|
+
- --charset=UTF-8
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project: subsify
|
68
|
+
rubygems_version: 1.8.24
|
69
|
+
signing_key:
|
70
|
+
specification_version: 2
|
71
|
+
summary: subsify is a Ruby client for the Subsify Subscription Payment API.
|
72
|
+
test_files: []
|