Class: BandwidthIris::Subscription

Inherits:
Object
  • Object
show all
Extended by:
ClientWrapper
Includes:
ApiItem
Defined in:
lib/bandwidth-iris/subscription.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClientWrapper

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.(SUBSCRIPTION_PATH), {:subscription => item})[1][:location]
  id = Client.get_id_from_location_header(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.(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.(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

#deleteObject



38
39
40
# File 'lib/bandwidth-iris/subscription.rb', line 38

def delete()
  @client.make_request(:delete,"#{@client.(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.(SUBSCRIPTION_PATH)}/#{id}", {:subscription => data})
end