Class: Plivo::Resources::Application

Inherits:
Base::Resource show all
Defined in:
lib/plivo/resources/applications.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Attribute Summary

Attributes inherited from Base::Resource

#id

Instance Method Summary collapse

Methods included from Utils

expected_type?, expected_value?, raise_invalid_request, valid_account?, valid_mainaccount?, valid_param?, valid_signature?, valid_subaccount?

Constructor Details

#initialize(client, options = nil) ⇒ Application



7
8
9
10
11
# File 'lib/plivo/resources/applications.rb', line 7

def initialize(client, options = nil)
  @_name = 'Application'
  @_identifier_string = 'app_id'
  super
end

Instance Method Details

#deleteObject



60
61
62
# File 'lib/plivo/resources/applications.rb', line 60

def delete
  perform_delete
end

#to_sObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/plivo/resources/applications.rb', line 64

def to_s
  {
    answer_method: @answer_method,
    answer_url: @answer_url,
    app_id: @app_id,
    api_id: @api_id,
    app_name: @app_name,
    default_app: @default_app,
    default_endpoint_app: @default_endpoint_app,
    enabled: @enabled,
    fallback_answer_url: @fallback_answer_url,
    fallback_method: @fallback_method,
    hangup_method: @hangup_method,
    hangup_url: @hangup_url,
    message_method: @message_method,
    message_url: @message_url,
    public_uri: @public_uri,
    resource_uri: @resource_uri,
    sip_uri: @sip_uri,
    sub_account: ,
    log_incoming_messages: @log_incoming_messages
  }.to_s
end

#update(options = nil) ⇒ Application

Returns Application.

Options Hash (options):

  • :answer_url (String)
    • The URL invoked by Plivo when a call executes this application.

  • :answer_method (String)
    • The method used to call the answer_url. Defaults to POST.

  • :hangup_url (String)
    • The URL that will be notified by Plivo when the call hangs up. Defaults to answer_url.

  • :hangup_method (String)
    • The method used to call the hangup_url. Defaults to POST.

  • :fallback_answer_url (String)
    • Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.

  • :fallback_method (String)
    • The method used to call the fallback_answer_url. Defaults to POST.

  • :message_url (String)
    • The URL that will be notified by Plivo when an inbound message is received. Defaults not set.

  • :message_method (String)
    • The method used to call the message_url. Defaults to POST.

  • :default_number_app (Boolean)
    • If set to true, this parameter ensures that newly created numbers, which don’t have an app_id, point to this application.

  • :default_endpoint_app (Boolean)
    • If set to true, this parameter ensures that newly created endpoints, which don’t have an app_id, point to this application.

  • :subaccount (String)
    • Id of the subaccount, in case only subaccount applications are needed.

  • :log_incoming_messages (Boolean)
    • If set to true, this parameter ensures that incoming messages are logged.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/plivo/resources/applications.rb', line 27

def update(options = nil)
  return perform_update({}) if options.nil?

  valid_param?(:options, options, Hash, true)

  params = {}

  i[answer_url hangup_url fallback_answer_url message_url subaccount]
    .each do |param|
    if options.key?(param) &&
       valid_param?(param, options[param], [String, Symbol], true)
      params[param] = options[param]
    end
  end

  i[answer_method hangup_method fallback_method message_method]
    .each do |param|
    if options.key?(param) &&
       valid_param?(param, options[param], [String, Symbol], true, %w[GET POST])
      params[param] = options[param]
    end
  end

  i[default_number_app default_endpoint_app log_incoming_messages].each do |param|
    if options.key?(param) &&
       valid_param?(param, options[param], [TrueClass, FalseClass], true)
      params[param] = options[param]
    end
  end

  perform_update(params)
end