Class: Subsify::Client
- Inherits:
-
Object
- Object
- Subsify::Client
- Defined in:
- lib/subsify/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cancel_subscription(options = {}) ⇒ Object
- #create_token(options = {}) ⇒ Object
- #get_customer(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
4 5 6 7 8 9 |
# File 'lib/subsify/client.rb', line 4 def initialize(={}) @host = [:host] || 'subsify.com' @protocol = [:protocol] || 'https' @client_id = [:client_id] @client_secret = [:client_secret] end |
Class Method Details
.url ⇒ Object
37 38 39 |
# File 'lib/subsify/client.rb', line 37 def self.url "#{@protocol}://#{@client_id}:#{@client_secret}@#{@host}" end |
Instance Method Details
#cancel_subscription(options = {}) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/subsify/client.rb', line 30 def cancel_subscription(={}) res = RestClient.delete( "#{self.url}/v1/customers/#{[:id]}/subscription", ) JSON.parse(res) end |
#create_token(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/subsify/client.rb', line 11 def create_token(={}) res = RestClient.post( "#{self.url}/v1/tokens", { :ip_address => [:ip_address], :callback_url => [:callback], :plan => [:plan] } ) return Subsify::Token.new(JSON.parse(res)['token']) end |