asterisk-ari-client 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +85 -0
- data/Rakefile +54 -0
- data/asterisk-ari-client.gemspec +32 -0
- data/examples/list_channels.rb +14 -0
- data/examples/websocket.rb +33 -0
- data/lib/ari.rb +12 -0
- data/lib/ari/client.rb +124 -0
- data/lib/ari/generators/api.rb +23 -0
- data/lib/ari/generators/attribute.rb +35 -0
- data/lib/ari/generators/model.rb +38 -0
- data/lib/ari/generators/operation.rb +43 -0
- data/lib/ari/generators/parameter.rb +35 -0
- data/lib/ari/generators/property.rb +32 -0
- data/lib/ari/generators/resource_generator.rb +94 -0
- data/lib/ari/generators/templates/model.rb.erb +36 -0
- data/lib/ari/generators/templates/resource.rb.erb +97 -0
- data/lib/ari/list_resource.rb +23 -0
- data/lib/ari/model.rb +26 -0
- data/lib/ari/models.rb +47 -0
- data/lib/ari/models/.DS_Store +0 -0
- data/lib/ari/models/application_replaced.rb +17 -0
- data/lib/ari/models/asterisk_info.rb +35 -0
- data/lib/ari/models/bridge_attended_transfer.rb +63 -0
- data/lib/ari/models/bridge_blind_transfer.rb +35 -0
- data/lib/ari/models/bridge_created.rb +23 -0
- data/lib/ari/models/bridge_destroyed.rb +23 -0
- data/lib/ari/models/bridge_merged.rb +27 -0
- data/lib/ari/models/build_info.rb +19 -0
- data/lib/ari/models/caller_id.rb +19 -0
- data/lib/ari/models/channel_caller_id.rb +23 -0
- data/lib/ari/models/channel_created.rb +23 -0
- data/lib/ari/models/channel_destroyed.rb +23 -0
- data/lib/ari/models/channel_dialplan.rb +23 -0
- data/lib/ari/models/channel_dtmf_received.rb +23 -0
- data/lib/ari/models/channel_entered_bridge.rb +27 -0
- data/lib/ari/models/channel_hangup_request.rb +23 -0
- data/lib/ari/models/channel_left_bridge.rb +27 -0
- data/lib/ari/models/channel_state_change.rb +23 -0
- data/lib/ari/models/channel_talking_finished.rb +23 -0
- data/lib/ari/models/channel_talking_started.rb +23 -0
- data/lib/ari/models/channel_userevent.rb +35 -0
- data/lib/ari/models/channel_varset.rb +23 -0
- data/lib/ari/models/config_info.rb +27 -0
- data/lib/ari/models/device_state_changed.rb +23 -0
- data/lib/ari/models/dial.rb +31 -0
- data/lib/ari/models/dialed.rb +17 -0
- data/lib/ari/models/dialplan_cep.rb +19 -0
- data/lib/ari/models/endpoint_state_change.rb +23 -0
- data/lib/ari/models/format_lang_pair.rb +19 -0
- data/lib/ari/models/live_recording.rb +19 -0
- data/lib/ari/models/message.rb +19 -0
- data/lib/ari/models/missing_params.rb +19 -0
- data/lib/ari/models/playback_finished.rb +23 -0
- data/lib/ari/models/playback_started.rb +23 -0
- data/lib/ari/models/recording_failed.rb +23 -0
- data/lib/ari/models/recording_finished.rb +23 -0
- data/lib/ari/models/recording_started.rb +23 -0
- data/lib/ari/models/set_id.rb +19 -0
- data/lib/ari/models/stasis_end.rb +23 -0
- data/lib/ari/models/stasis_start.rb +27 -0
- data/lib/ari/models/status_info.rb +27 -0
- data/lib/ari/models/stored_recording.rb +19 -0
- data/lib/ari/models/system_info.rb +19 -0
- data/lib/ari/models/text_message.rb +23 -0
- data/lib/ari/models/text_message_received.rb +27 -0
- data/lib/ari/models/text_message_variable.rb +19 -0
- data/lib/ari/models/variable.rb +19 -0
- data/lib/ari/request_error.rb +8 -0
- data/lib/ari/resource.rb +37 -0
- data/lib/ari/resources.rb +11 -0
- data/lib/ari/resources/application.rb +101 -0
- data/lib/ari/resources/asterisk.rb +72 -0
- data/lib/ari/resources/bridge.rb +286 -0
- data/lib/ari/resources/channel.rb +610 -0
- data/lib/ari/resources/device_state.rb +98 -0
- data/lib/ari/resources/endpoint.rb +124 -0
- data/lib/ari/resources/event.rb +25 -0
- data/lib/ari/resources/mailbox.rb +99 -0
- data/lib/ari/resources/playback.rb +86 -0
- data/lib/ari/resources/recording.rb +241 -0
- data/lib/ari/resources/sound.rb +64 -0
- data/lib/ari/server_error.rb +8 -0
- data/lib/asterisk/ari/client.rb +10 -0
- data/lib/asterisk/ari/client/version.rb +7 -0
- data/test/fixtures/bridge_create.json +74 -0
- data/test/fixtures/bridge_get.json +74 -0
- data/test/fixtures/bridges_list.json +76 -0
- data/test/fixtures/channel_get.json +83 -0
- data/test/fixtures/channel_originate.json +83 -0
- data/test/fixtures/channel_originate_with_id.json +83 -0
- data/test/fixtures/channels_list.json +105 -0
- data/test/lib/asterisk-ari-client/.DS_Store +0 -0
- data/test/lib/asterisk-ari-client/bridge_test.rb +46 -0
- data/test/lib/asterisk-ari-client/channel_test.rb +59 -0
- data/test/test_helper.rb +42 -0
- metadata +265 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class RecordingFailed < Event
|
|
14
|
+
|
|
15
|
+
attr_reader :recording
|
|
16
|
+
|
|
17
|
+
def recording=(val)
|
|
18
|
+
@recording ||= LiveRecording.new(val)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class RecordingFinished < Event
|
|
14
|
+
|
|
15
|
+
attr_reader :recording
|
|
16
|
+
|
|
17
|
+
def recording=(val)
|
|
18
|
+
@recording ||= LiveRecording.new(val)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class RecordingStarted < Event
|
|
14
|
+
|
|
15
|
+
attr_reader :recording
|
|
16
|
+
|
|
17
|
+
def recording=(val)
|
|
18
|
+
@recording ||= LiveRecording.new(val)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class SetId < Model
|
|
14
|
+
|
|
15
|
+
attr_reader :user, :group
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class StasisEnd < Event
|
|
14
|
+
|
|
15
|
+
attr_reader :channel
|
|
16
|
+
|
|
17
|
+
def channel=(val)
|
|
18
|
+
@channel ||= Channel.new(val)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class StasisStart < Event
|
|
14
|
+
|
|
15
|
+
attr_reader :args, :channel, :replace_channel
|
|
16
|
+
|
|
17
|
+
def channel=(val)
|
|
18
|
+
@channel ||= Channel.new(val)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def replace_channel=(val)
|
|
22
|
+
@replace_channel ||= Channel.new(val)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class StatusInfo < Model
|
|
14
|
+
|
|
15
|
+
attr_reader :startup_time, :last_reload_time
|
|
16
|
+
|
|
17
|
+
def startup_time=(val)
|
|
18
|
+
@startup_time ||= Time.parse(val)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def last_reload_time=(val)
|
|
22
|
+
@last_reload_time ||= Time.parse(val)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class StoredRecording < Model
|
|
14
|
+
|
|
15
|
+
attr_reader :name, :format
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class SystemInfo < Model
|
|
14
|
+
|
|
15
|
+
attr_reader :version, :entity_id
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class TextMessage < Model
|
|
14
|
+
|
|
15
|
+
attr_reader :from, :to, :body, :variables
|
|
16
|
+
|
|
17
|
+
def variables=(val)
|
|
18
|
+
@variables ||= TextMessageVariable.new(val)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class TextMessageReceived < Event
|
|
14
|
+
|
|
15
|
+
attr_reader :message, :endpoint
|
|
16
|
+
|
|
17
|
+
def message=(val)
|
|
18
|
+
@message ||= TextMessage.new(val)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def endpoint=(val)
|
|
22
|
+
@endpoint ||= Endpoint.new(val)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class TextMessageVariable < Model
|
|
14
|
+
|
|
15
|
+
attr_reader :key, :value
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class Variable < Model
|
|
14
|
+
|
|
15
|
+
attr_reader :value
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/ari/resource.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Ari
|
|
2
|
+
class Resource < Model
|
|
3
|
+
|
|
4
|
+
def client(options = {})
|
|
5
|
+
return @client if @client
|
|
6
|
+
self.class.client(options)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.client(options = {})
|
|
10
|
+
client = options.fetch(:client, nil)
|
|
11
|
+
return client if client
|
|
12
|
+
Ari.client
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def add_listener(type, params = {}, &block)
|
|
16
|
+
client.class.instance_listeners[type.to_sym] ||= []
|
|
17
|
+
client.class.instance_listeners[type.to_sym] << self
|
|
18
|
+
client.add_listener "#{type}-#{self.id}", params, &block
|
|
19
|
+
end
|
|
20
|
+
alias_method :on, :add_listener
|
|
21
|
+
|
|
22
|
+
def remove_listener(type)
|
|
23
|
+
client.class.instance_listeners[type.to_sym] ||= []
|
|
24
|
+
client.class.instance_listeners[type].delete_if { |i| i.id == self.id }
|
|
25
|
+
client.remove_listener "#{type}-#{self.id}"
|
|
26
|
+
end
|
|
27
|
+
alias_method :off, :remove_listener
|
|
28
|
+
|
|
29
|
+
def remove_all_listeners!
|
|
30
|
+
client.class.instance_listeners.each do |type, _|
|
|
31
|
+
remove_listener type
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
alias_method :off_all!, :remove_all_listeners!
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'ari/resources/application'
|
|
2
|
+
require 'ari/resources/asterisk'
|
|
3
|
+
require 'ari/resources/bridge'
|
|
4
|
+
require 'ari/resources/channel'
|
|
5
|
+
require 'ari/resources/device_state'
|
|
6
|
+
require 'ari/resources/endpoint'
|
|
7
|
+
require 'ari/resources/event'
|
|
8
|
+
require 'ari/resources/mailbox'
|
|
9
|
+
require 'ari/resources/playback'
|
|
10
|
+
require 'ari/resources/recording'
|
|
11
|
+
require 'ari/resources/sound'
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#------------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# WARNING !
|
|
4
|
+
#
|
|
5
|
+
# This is a generated file. DO NOT EDIT THIS FILE! Your changes will
|
|
6
|
+
# be lost the next time this file is regenerated.
|
|
7
|
+
#
|
|
8
|
+
# This file was generated using asterisk-ari-client ruby gem.
|
|
9
|
+
#
|
|
10
|
+
#------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
module Ari
|
|
13
|
+
class Application < Resource
|
|
14
|
+
|
|
15
|
+
attr_reader :name, :channel_ids, :bridge_ids, :endpoint_ids, :device_names
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# GET /applications
|
|
19
|
+
#
|
|
20
|
+
# Stasis applications
|
|
21
|
+
#
|
|
22
|
+
#
|
|
23
|
+
def self.list(options = {})
|
|
24
|
+
path = '/applications'
|
|
25
|
+
response = client(options).get(path, options)
|
|
26
|
+
response.map { |hash| Application.new(hash.merge(client: options[:client])) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# GET /applications/%{applicationName}
|
|
30
|
+
#
|
|
31
|
+
# Stasis application
|
|
32
|
+
#
|
|
33
|
+
#
|
|
34
|
+
# Parameters:
|
|
35
|
+
#
|
|
36
|
+
# applicationName (required) - Application's name
|
|
37
|
+
#
|
|
38
|
+
def self.get(options = {})
|
|
39
|
+
raise ArgumentError.new("Parameter applicationName must be passed in options hash.") unless options[:applicationName]
|
|
40
|
+
path = '/applications/%{applicationName}' % options
|
|
41
|
+
response = client(options).get(path, options)
|
|
42
|
+
Application.new(response.merge(client: options[:client]))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def get(options = {})
|
|
46
|
+
self.class.get(options.merge(applicationName: self.id, client: @client))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# POST /applications/%{applicationName}/subscription
|
|
50
|
+
#
|
|
51
|
+
# Stasis application
|
|
52
|
+
#
|
|
53
|
+
#
|
|
54
|
+
# Parameters:
|
|
55
|
+
#
|
|
56
|
+
# applicationName (required) - Application's name
|
|
57
|
+
# eventSource (required) - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}
|
|
58
|
+
#
|
|
59
|
+
def self.subscribe(options = {})
|
|
60
|
+
raise ArgumentError.new("Parameter applicationName must be passed in options hash.") unless options[:applicationName]
|
|
61
|
+
raise ArgumentError.new("Parameter eventSource must be passed in options hash.") unless options[:eventSource]
|
|
62
|
+
path = '/applications/%{applicationName}/subscription' % options
|
|
63
|
+
response = client(options).post(path, options)
|
|
64
|
+
Application.new(response.merge(client: options[:client]))
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def subscribe(options = {})
|
|
68
|
+
self.class.subscribe(options.merge(applicationName: self.id, client: @client))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# DELETE /applications/%{applicationName}/subscription
|
|
72
|
+
#
|
|
73
|
+
# Stasis application
|
|
74
|
+
#
|
|
75
|
+
#
|
|
76
|
+
# Parameters:
|
|
77
|
+
#
|
|
78
|
+
# applicationName (required) - Application's name
|
|
79
|
+
# eventSource (required) - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}
|
|
80
|
+
#
|
|
81
|
+
def self.unsubscribe(options = {})
|
|
82
|
+
raise ArgumentError.new("Parameter applicationName must be passed in options hash.") unless options[:applicationName]
|
|
83
|
+
raise ArgumentError.new("Parameter eventSource must be passed in options hash.") unless options[:eventSource]
|
|
84
|
+
path = '/applications/%{applicationName}/subscription' % options
|
|
85
|
+
response = client(options).delete(path, options)
|
|
86
|
+
Application.new(response.merge(client: options[:client]))
|
|
87
|
+
rescue Ari::RequestError => e
|
|
88
|
+
raise unless e.code == '404'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def unsubscribe(options = {})
|
|
92
|
+
self.class.unsubscribe(options.merge(applicationName: self.id, client: @client))
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
Ari::Client.send :define_method, 'applications' do
|
|
100
|
+
Ari::ListResource.new(self, Ari::Application)
|
|
101
|
+
end
|