class Plivo::Resources::Shortcode

Public Class Methods

new(client, options = nil) click to toggle source
Calls superclass method Plivo::Base::Resource::new
# File lib/plivo/resources/powerpacks.rb, line 542
def initialize(client, options = nil)
  @_name = 'Shortcode'
  @_identifier_string = 'number_pool_id'
  super
end

Public Instance Methods

find(shortcode) click to toggle source
# File lib/plivo/resources/powerpacks.rb, line 570
def find(shortcode)
  perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Shortcode/' + shortcode.to_s ,
               'GET')
end
list(options = nil) click to toggle source
# File lib/plivo/resources/powerpacks.rb, line 547
def list(options = nil)
  return perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Shortcode',
               'GET') if options.nil?
  params = {}
  %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
  
  if options.key?(:offset) && options[:offset] < 0
    raise_invalid_request("Offset can't be negative")
  end
  perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Shortcode',
               'GET')
end
remove(shortcode) click to toggle source
# File lib/plivo/resources/powerpacks.rb, line 575
def remove(shortcode)
  perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Shortcode/' + shortcode.to_s ,
               'DELETE', { unrent: false }, false)
end