class Provide::Services::Bookie

Public Class Methods

new(scheme = 'http', host, token) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 5
def initialize(scheme = 'http', host, token)
  @scheme = scheme
  @host = host
  @token = token
end

Public Instance Methods

billing_account_details(billing_account_id) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 15
def billing_account_details(billing_account_id)
  parse client.get "billing_accounts/#{billing_account_id}"
end
billing_accounts(params = nil) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 11
def billing_accounts(params = nil)
  parse client.get 'billing_accounts', (params || {})
end
channel_details(channel_id) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 67
def channel_details(channel_id)
  parse client.get "channels/#{channel_id}"
end
channels(params = nil) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 63
def channels(params = nil)
  parse client.get 'channels', (params || {})
end
connect(params = nil) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 27
def connect(params = nil)
  parse client.get 'connect', (params || {})
end
create_billing_account(params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 19
def create_billing_account(params)
  parse client.post 'billing_accounts', params
end
create_channel(params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 71
def create_channel(params)
  parse client.post 'channels', params
end
create_connection(params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 31
def create_connection(params)
  parse client.post 'connect', params
end
create_payment_hub(params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 43
def create_payment_hub(params)
  parse client.post 'payment_hubs', params
end
create_payment_method(params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 55
def create_payment_method(params)
  parse client.post 'payment_methods', params
end
create_thread(channel_id, params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 79
def create_thread(channel_id, params)
  parse client.post "channels/#{channel_id}/threads", params
end
delete_payment_hub(payment_hub_id) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 47
def delete_payment_hub(payment_hub_id)
  parse client.delete "payment_hubs/#{payment_hub_id}"
end
delete_payment_method(payment_method_id) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 59
def delete_payment_method(payment_method_id)
  parse client.delete "payment_methods/#{payment_method_id}"
end
network(params = nil) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 87
def network(params = nil)
  parse client.get 'network', (params || {})
end
network_invite(params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 91
def network_invite(params)
  parse client.post 'network', params
end
payment_hub_details(payment_hub_id) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 39
def payment_hub_details(payment_hub_id)
  parse client.get "payment_hubs/#{payment_hub_id}"
end
payment_hubs(params = nil) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 35
def payment_hubs(params = nil)
  parse client.get 'payment_hubs', (params || {})
end
payment_methods(params = nil) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 51
def payment_methods(params = nil)
  parse client.get 'payment_methods', (params || {})
end
update_billing_account(billing_account_id, params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 23
def update_billing_account(billing_account_id, params)
  parse client.put "billing_accounts/#{billing_account_id}", params
end
update_channel_state(channel_id, params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 75
def update_channel_state(channel_id, params)
  parse client.post "channels/#{channel_id}/states", params
end
update_thread_state(channel_id, thread_id, params) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 83
def update_thread_state(channel_id, thread_id, params)
  parse client.post "channels/#{channel_id}/threads/#{thread_id}/states", params
end

Private Instance Methods

client() click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 97
def client
  @client ||= begin
  Provide::ApiClient.new(@scheme, @host, 'api/v1/', @token)
  end
end
parse(response) click to toggle source
# File lib/provide-ruby/services/bookie.rb, line 103
def parse(response)
  begin
    body = response.code == 204 ? nil : JSON.parse(response.body)
    return response.code, response.headers, body
  rescue
    raise Exception.new({
      :code => response.code,
    })
  end
end