Class: Plivo::Resources::VerifyCallerIdInterface

Inherits:
Base::ResourceInterface show all
Defined in:
lib/plivo/resources/verify_caller_id.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Method Summary collapse

Methods included from Utils

GetSortedQueryParamString?, compute_signatureV3?, expected_type?, expected_value?, generate_url?, getMapFromQueryString?, is_one_among_string_url?, multi_valid_param?, raise_invalid_request, valid_account?, valid_date_format?, valid_mainaccount?, valid_multiple_destination_integers?, valid_multiple_destination_nos?, valid_param?, valid_range?, valid_signature?, valid_signatureV3?, valid_subaccount?, valid_url?

Constructor Details

#initialize(client, resource_list_json = nil) ⇒ VerifyCallerIdInterface

Returns a new instance of VerifyCallerIdInterface.



25
26
27
28
29
30
# File 'lib/plivo/resources/verify_caller_id.rb', line 25

def initialize(client, resource_list_json = nil)
  @_name = 'VerifiedCallerId'
  @_resource_type = Verify
  @_identifier_string = 'api_id'
  super
end

Instance Method Details

#delete(phone_number) ⇒ Object



105
106
107
# File 'lib/plivo/resources/verify_caller_id.rb', line 105

def delete(phone_number)
  perform_delete(phone_number, nil)
end

#get(phone_number = nil) ⇒ Object



68
69
70
71
# File 'lib/plivo/resources/verify_caller_id.rb', line 68

def get(phone_number = nil)
  valid_param?(:phone_number, phone_number, [String], true)
  perform_get(phone_number)
end

#initiate(phone_number = nil, channel = nil, alias_ = nil, subaccount = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/plivo/resources/verify_caller_id.rb', line 32

def initiate(phone_number = nil, channel = nil, alias_ = nil, subaccount = nil)
  valid_param?(:phone_number, phone_number, [String], true)
  valid_param?(:channel, channel, [String], false)
  valid_param?(:alias, alias_, [String], false)
  valid_param?(:subaccount, subaccount, [String], false)

  params = {
    phone_number: phone_number,
    channel: channel,
    alias: alias_,
    subaccount: subaccount
  }
  perform_create(params)
end

#list(options = nil) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/plivo/resources/verify_caller_id.rb', line 73

def list(options = nil)
  return perform_list_without_object if options.nil?
  valid_param?(:options, options, Hash, false)

  params = {}
  params_expected = %i[subaccount country alias]

  params_expected.each do |param|
    if options.key?(param) &&
      valid_param?(param, options[param], [String, Symbol], false)
      params[param] = options[param]
    end
  end

  %i[offset limit].each do |param|
    if options.key?(param) &&
      valid_param?(param, options[param], [Integer, Integer], false)
      params[param] = options[param]
    end
  end

  if options.key?(:limit) &&
    (options[:limit] > 20 || options[:limit] <= 0)
    raise_invalid_request('The maximum number of results that can be '\
                            "fetched is 20. limit can't be more than 20 or less than 1")
  end

  raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0

  perform_list_without_object(params)
end

#update(phone_number = nil, subaccount = nil, alias_ = nil) ⇒ Object



57
58
59
60
61
62
63
64
65
66
# File 'lib/plivo/resources/verify_caller_id.rb', line 57

def update(phone_number = nil, subaccount = nil, alias_ = nil)
  valid_param?(:phone_number, phone_number, [String], true)
  valid_param?(:subaccount, subaccount, [String], false)
  valid_param?(:alias, alias_, [String], false)
  params = {
    subaccount: subaccount,
    alias: alias_
  }
  perform_action_with_identifier(phone_number, 'POST', params)
end

#verify(verification_uuid = nil, otp = nil) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'lib/plivo/resources/verify_caller_id.rb', line 47

def verify(verification_uuid = nil, otp = nil)
  valid_param?(:verification_uuid, verification_uuid, [String], true)
  valid_param?(:otp, otp, [String], true)
  id = 'Verification/' + verification_uuid
  params = {
    otp: otp
  }
  perform_action_with_identifier(id, 'POST', params)
end