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

GetSortedQueryParamString?, compute_signatureV3?, expected_type?, expected_value?, generate_url?, getMapFromQueryString?, raise_invalid_request, valid_account?, valid_mainaccount?, valid_param?, valid_signature?, valid_signatureV3?, valid_subaccount?

Constructor Details

#initialize(client, options = nil) ⇒ Application



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

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

Instance Method Details

#delete(options = nil) ⇒ Object

Options Hash (options):

  • :cascade (Boolean)
    • delete associated endpoints

  • :new_endpoint_application (String)
    • Link associated endpoints to this app



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/plivo/resources/applications.rb', line 64

def delete(options = nil)
  return perform_delete if options.nil?
  params = {}

  if options.key?(:cascade) && valid_param?(:cascade, options[:cascade], [TrueClass, FalseClass], false, [true, false])
    params[:cascade] = options[:cascade]
  end

  if options.key?(:new_endpoint_application) && valid_param?(:new_endpoint_application, options[:new_endpoint_application], [String, Symbol])
    params[:new_endpoint_application] = options[:new_endpoint_application]
  end

  perform_delete(params)
end

#to_sObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/plivo/resources/applications.rb', line 79

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.



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
59
# File 'lib/plivo/resources/applications.rb', line 28

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