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.



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

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) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/plivo/resources/verify_session.rb', line 44

def create(app_uuid = nil, recipient = nil,channel = nil,url = nil, method = 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])

    params = {
        app_uuid: app_uuid,
        recipient: recipient,
        channel: channel,
        url: url,
        method: method
    }
    perform_create(params)
end

#get(session_uuid) ⇒ Object

Parameters:

  • session_uuid (String)


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

def get(session_uuid)
    perform_get(session_uuid)
end

#list(options = nil) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/plivo/resources/verify_session.rb', line 61

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
    ]

    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



95
96
97
98
99
100
101
102
103
# File 'lib/plivo/resources/verify_session.rb', line 95

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