Class: BandwidthIris::Subscription
- Inherits:
-
Object
- Object
- BandwidthIris::Subscription
show all
- Extended by:
- ClientWrapper
- Includes:
- ApiItem
- Defined in:
- lib/bandwidth-iris/subscription.rb
Class Method Summary
collapse
Instance Method Summary
collapse
wrap_client_arg
Methods included from ApiItem
#[], #[]=, #initialize, #to_data
Class Method Details
.create(client, item) ⇒ Object
26
27
28
29
30
|
# File 'lib/bandwidth-iris/subscription.rb', line 26
def self.create(client, item)
location = client.make_request(:post, client.concat_account_path(SUBSCRIPTION_PATH), {:subscription => item})[1][:location]
id = Client.(location)
self.get(client, id)
end
|
.get(client, id) ⇒ Object
19
20
21
22
23
|
# File 'lib/bandwidth-iris/subscription.rb', line 19
def self.get(client, id)
data = client.make_request(:get, "#{client.concat_account_path(SUBSCRIPTION_PATH)}/#{id}")[0][:subscriptions][:subscription]
data[:id] = data[:subscription_id]
Subscription.new(data, client)
end
|
.list(client, query = nil) ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'lib/bandwidth-iris/subscription.rb', line 8
def self.list(client, query = nil)
list = client.make_request(:get, client.concat_account_path(SUBSCRIPTION_PATH), query)[0][:subscriptions][:subscription]
return [] if !list
list = if list.is_a?(Array) then list else [list] end
list.map do |i|
i[:id] = i[:subscription_id]
Subscription.new(i, client)
end
end
|
Instance Method Details
#delete ⇒ Object
38
39
40
|
# File 'lib/bandwidth-iris/subscription.rb', line 38
def delete()
@client.make_request(:delete,"#{@client.concat_account_path(SUBSCRIPTION_PATH)}/#{id}")
end
|
#update(data) ⇒ Object
34
35
36
|
# File 'lib/bandwidth-iris/subscription.rb', line 34
def update(data)
@client.make_request(:put,"#{@client.concat_account_path(SUBSCRIPTION_PATH)}/#{id}", {:subscription => data})
end
|