Class: Ari::Endpoint

Inherits:
Resource show all
Defined in:
lib/ari/resources/endpoint.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#add_listener, client, #client, #remove_all_listeners!, #remove_listener

Methods inherited from Model

#attributes=, #initialize

Constructor Details

This class inherits a constructor from Ari::Model

Instance Attribute Details

#channel_idsObject (readonly)

Returns the value of attribute channel_ids.



15
16
17
# File 'lib/ari/resources/endpoint.rb', line 15

def channel_ids
  @channel_ids
end

#resourceObject (readonly)

Returns the value of attribute resource.



15
16
17
# File 'lib/ari/resources/endpoint.rb', line 15

def resource
  @resource
end

#stateObject (readonly)

Returns the value of attribute state.



15
16
17
# File 'lib/ari/resources/endpoint.rb', line 15

def state
  @state
end

#technologyObject (readonly)

Returns the value of attribute technology.



15
16
17
# File 'lib/ari/resources/endpoint.rb', line 15

def technology
  @technology
end

Class Method Details

.get(options = {}) ⇒ Object

GET /endpoints/%tech/%#resource

Single endpoint

Parameters:

tech (required) - Technology of the endpoint resource (required) - ID of the endpoint

Raises:

  • (ArgumentError)


80
81
82
83
84
85
86
# File 'lib/ari/resources/endpoint.rb', line 80

def self.get(options = {})
  raise ArgumentError.new("Parameter tech must be passed in options hash.") unless options[:tech]
  raise ArgumentError.new("Parameter resource must be passed in options hash.") unless options[:resource]
  path = '/endpoints/%{tech}/%{resource}' % options
  response = client(options).get(path, options)
  Endpoint.new(response.merge(client: options[:client]))
end

.list(options = {}) ⇒ Object

GET /endpoints

Asterisk endpoints



23
24
25
26
27
# File 'lib/ari/resources/endpoint.rb', line 23

def self.list(options = {})
  path = '/endpoints'
  response = client(options).get(path, options)
  response.map { |hash| Endpoint.new(hash.merge(client: options[:client])) }
end

.list_by_tech(options = {}) ⇒ Object

GET /endpoints/%tech

Asterisk endpoints

Parameters:

tech (required) - Technology of the endpoints (sip,iax2,…)

Raises:

  • (ArgumentError)


58
59
60
61
62
63
# File 'lib/ari/resources/endpoint.rb', line 58

def self.list_by_tech(options = {})
  raise ArgumentError.new("Parameter tech must be passed in options hash.") unless options[:tech]
  path = '/endpoints/%{tech}' % options
  response = client(options).get(path, options)
  response.map { |hash| Endpoint.new(hash.merge(client: options[:client])) }
end

.listByTechObject

GET /endpoints/%tech

Asterisk endpoints

Parameters:

tech (required) - Technology of the endpoints (sip,iax2,…)

Raises:

  • (ArgumentError)


64
65
66
67
68
69
# File 'lib/ari/resources/endpoint.rb', line 64

def self.list_by_tech(options = {})
  raise ArgumentError.new("Parameter tech must be passed in options hash.") unless options[:tech]
  path = '/endpoints/%{tech}' % options
  response = client(options).get(path, options)
  response.map { |hash| Endpoint.new(hash.merge(client: options[:client])) }
end

.send_message(options = {}) ⇒ Object Also known as: sendMessage

PUT /endpoints/sendMessage

Send a message to some technology URI or endpoint.

Parameters:

to (required) - The endpoint resource or technology specific URI to send the message to. Valid resources are sip, pjsip, and xmpp. from (required) - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. body - The body of the message variables -

Raises:

  • (ArgumentError)


41
42
43
44
45
46
# File 'lib/ari/resources/endpoint.rb', line 41

def self.send_message(options = {})
  raise ArgumentError.new("Parameter to must be passed in options hash.") unless options[:to]
  raise ArgumentError.new("Parameter from must be passed in options hash.") unless options[:from]
  path = '/endpoints/sendMessage'
  response = client(options).put(path, options)
end

.send_message_to_endpoint(options = {}) ⇒ Object

PUT /endpoints/%tech/%#resource/sendMessage

Send a message to some endpoint in a technology.

Parameters:

tech (required) - Technology of the endpoint resource (required) - ID of the endpoint from (required) - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. body - The body of the message variables -

Raises:

  • (ArgumentError)


105
106
107
108
109
110
111
# File 'lib/ari/resources/endpoint.rb', line 105

def self.send_message_to_endpoint(options = {})
  raise ArgumentError.new("Parameter tech must be passed in options hash.") unless options[:tech]
  raise ArgumentError.new("Parameter resource must be passed in options hash.") unless options[:resource]
  raise ArgumentError.new("Parameter from must be passed in options hash.") unless options[:from]
  path = '/endpoints/%{tech}/%{resource}/sendMessage' % options
  response = client(options).put(path, options)
end

.sendMessageToEndpointObject

PUT /endpoints/%tech/%#resource/sendMessage

Send a message to some endpoint in a technology.

Parameters:

tech (required) - Technology of the endpoint resource (required) - ID of the endpoint from (required) - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. body - The body of the message variables -

Raises:

  • (ArgumentError)


112
113
114
115
116
117
118
# File 'lib/ari/resources/endpoint.rb', line 112

def self.send_message_to_endpoint(options = {})
  raise ArgumentError.new("Parameter tech must be passed in options hash.") unless options[:tech]
  raise ArgumentError.new("Parameter resource must be passed in options hash.") unless options[:resource]
  raise ArgumentError.new("Parameter from must be passed in options hash.") unless options[:from]
  path = '/endpoints/%{tech}/%{resource}/sendMessage' % options
  response = client(options).put(path, options)
end

Instance Method Details

#get(options = {}) ⇒ Object



88
89
90
# File 'lib/ari/resources/endpoint.rb', line 88

def get(options = {})
  self.class.get(options.merge(endpointId: self.id, client: @client))
end

#list_by_tech(options = {}) ⇒ Object



66
67
68
# File 'lib/ari/resources/endpoint.rb', line 66

def list_by_tech(options = {})
  self.class.list_by_tech(options.merge(endpointId: self.id, client: @client))
end

#send_message_to_endpoint(options = {}) ⇒ Object



114
115
116
# File 'lib/ari/resources/endpoint.rb', line 114

def send_message_to_endpoint(options = {})
  self.class.send_message_to_endpoint(options.merge(endpointId: self.id, client: @client))
end