class Plivo::Resources::SessionInterface

Public Class Methods

new(client, resource_list_json = nil) click to toggle source
Calls superclass method Plivo::Base::ResourceInterface::new
# 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

Public Instance Methods

create(app_uuid = nil, recipient = nil,channel = nil,url = nil, method = nil) click to toggle source
# 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) click to toggle source

@param [String] session_uuid

# File lib/plivo/resources/verify_session.rb, line 40
def get(session_uuid)
    perform_get(session_uuid)
end
list(options = nil) click to toggle source
# 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) click to toggle source
# 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