Class: Brickwall::API::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/brickwall/api/subscription.rb

Class Method Summary collapse

Class Method Details

.cancel(subscription_id) ⇒ Object



22
23
24
25
26
27
# File 'lib/brickwall/api/subscription.rb', line 22

def self.cancel(subscription_id)
  response = RestClient.post API.url("subscription/#{subscription_id}/cancel"), {}, {
    'X-ApiKey' => Brickwall.configuration.brick_private_key
  }
  JSON.parse response
end

.create(params = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/brickwall/api/subscription.rb', line 5

def self.create(params = {})
  response = RestClient.post API.url('subscription'), params, {
    'X-ApiKey' => Brickwall.configuration.brick_private_key
  }
  JSON.parse response
rescue RestClient::Exception => e
  err = JSON.parse e.response
  Error.new err['type'], err['error'], err['code']
end

.get(subscription_id) ⇒ Object



15
16
17
18
19
20
# File 'lib/brickwall/api/subscription.rb', line 15

def self.get(subscription_id)
  response = RestClient.get API.url("subscription/#{subscription_id}"), {
    'X-ApiKey' => Brickwall.configuration.brick_private_key
  }
  JSON.parse response
end