Class: Plivo::Resources::SessionInterface

Inherits:
Base::ResourceInterface show all
Defined in:
lib/plivo/resources/verify_session.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) ⇒ SessionInterface

Returns a new instance of SessionInterface.



33
34
35
36
37
38
# File 'lib/plivo/resources/verify_session.rb', line 33

def initialize(client, resource_list_json = nil)
    @_name = 'Verify/Session'
    @_resource_type = Session
    @_identifier_string = 'session_uuid'
    super
end

Instance Method Details

#create(app_uuid = nil, recipient = nil, channel = nil, url = nil, method = nil, locale = nil, brand_name = nil, app_hash = nil, code_length = nil, dtmf = nil, fraud_check = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/plivo/resources/verify_session.rb', line 45

def create(app_uuid = nil, recipient = nil,channel = nil, url = nil, method = nil, locale=nil, brand_name=nil, app_hash=nil, code_length=nil, dtmf=nil, fraud_check=nil)
    valid_param?(:app_uuid, app_uuid, [String, Symbol], false)
    valid_param?(:recipient, recipient, [Integer, String, Symbol], true)
    valid_param?(:channel, channel, [String, Symbol], false)
    valid_param?(:url, url, [String], false)
    valid_param?(:method, method, String, false, %w[POST GET])
    valid_param?(:locale, locale, [String, Symbol], false)
    valid_param?(:brand_name, brand_name, [String, Symbol], false)
    valid_param?(:app_hash, app_hash, [String, Symbol], false)
    valid_param?(:code_length, code_length,[Integer,Symbol], false)
    valid_param?(:dtmf, dtmf,[Integer,Symbol], false)
    valid_param?(:fraud_check, fraud_check, [String, Symbol], false)

    params = {
        app_uuid: app_uuid,
        recipient: recipient,
        channel: channel,
        url: url,
        method: method,
        locale: locale,
        brand_name: brand_name,
        app_hash: app_hash,
        code_length: code_length,
        dtmf:dtmf,
        fraud_check:fraud_check
    }
    perform_create(params)
end

#get(session_uuid) ⇒ Object

Parameters:

  • session_uuid (String)


41
42
43
# File 'lib/plivo/resources/verify_session.rb', line 41

def get(session_uuid)
    perform_get(session_uuid)
end

#list(options = nil) ⇒ Object



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
104
105
106
# File 'lib/plivo/resources/verify_session.rb', line 74

def list(options = nil)
    return perform_list if options.nil?
    valid_param?(:options, options, Hash, true)
    params = {}
    params_expected = %i[
    subaccount status session_time__gt session_time__gte
    session_time__lt session_time__lte session_time country alias app_uuid recipient brand_name app_hash
    ]

    params_expected.each do |param|
        if options.key?(param) &&
           valid_param?(param, options[param], [String, Symbol], true)
          params[param] = options[param]
        end
    end
          
    %i[offset limit].each do |param|
        if options.key?(param) &&
            valid_param?(param, options[param], [Integer, Integer], true)
            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

#validate(session_uuid = nil, otp = nil) ⇒ Object



108
109
110
111
112
113
114
115
116
# File 'lib/plivo/resources/verify_session.rb', line 108

def validate(session_uuid = nil, otp = nil)
    valid_param?(:session_uuid, session_uuid, [String, Symbol], true)
    valid_param?(:otp, otp, [String], true)
    id = session_uuid
    params = {
        otp: otp
    }
    perform_action_with_identifier(id, 'POST', params)
end