class Plivo::Resources::Numbers
Public Class Methods
Source
# File lib/plivo/resources/powerpacks.rb, line 359 def initialize(client, options = nil) @_name = 'Numbers' @_identifier_string = 'number_pool_id' super end
Calls superclass method
Plivo::Base::Resource::new
Public Instance Methods
Source
# File lib/plivo/resources/powerpacks.rb, line 467 def add(number, options = nil) if options.nil? return perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s , 'POST') end params = {} if options.key?(:service) && valid_param?(:service, options[:service], String, true) params[:service] = options[:service] end perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s , 'POST', params) end
Source
# File lib/plivo/resources/powerpacks.rb, line 486 def buy_add_number(options = nil) params = {} params[:rent] = true if options.key?(:service) && valid_param?(:service, options[:service], String, true) params[:service] = options[:service] end if options.key?(:number) return perform_custom_action_apiresponse('NumberPool/' + number_pool_id + '/Number/' + options[:number].to_s , 'POST', params) end if options.key?(:country_iso2).nil? raise_invalid_request('country_iso is cannot be empty') end 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 if options.key?(:pattern) && valid_param?(:pattern, options[:pattern], String, true) params[:starts_with] = options[:pattern] end if options.key?(:country_iso2) && valid_param?(:country_iso2, options[:country_iso2], String, true) params[:country_iso] = options[:country_iso2] end if options.key?(:type) && valid_param?(:type, options[:type], String, true) params[:type] = options[:type] end response = perform_custom_action_apiresponse('PhoneNumber', 'GET', params, true) numbers = response['objects'][0]['number'] params[:rent] = true perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + numbers.to_s, 'POST', params) end
Source
# File lib/plivo/resources/powerpacks.rb, line 405 def count(options = nil) if options.nil? response = perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number', 'GET') meta = response['meta'] return meta['total_count'] end 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 if options.key?(:pattern) && valid_param?(:pattern, options[:pattern], String, true) params[:starts_with] = options[:pattern] end if options.key?(:country_iso2) && valid_param?(:country_iso2, options[:country_iso2], String, true) params[:country_iso2] = options[:country_iso2] end if options.key?(:type) && valid_param?(:type, options[:type], String, true) params[:type] = options[:type] end if options.key?(:service) && valid_param?(:service, options[:service], String, true) params[:service] = options[:service] end response = perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number', 'GET', params, true) meta = response['meta'] return meta['total_count'] end
Source
# File lib/plivo/resources/powerpacks.rb, line 453 def find(number, options = nil) if options.nil? return perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s , 'GET') end params = {} if options.key?(:service) && valid_param?(:service, options[:service], String, true) params[:service] = options[:service] end perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s , 'GET', params) end
Source
# File lib/plivo/resources/powerpacks.rb, line 365 def list(options = nil) return perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number', '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 if options.key?(:pattern) && valid_param?(:pattern, options[:pattern], String, true) params[:starts_with] = options[:pattern] end if options.key?(:country_iso2) && valid_param?(:country_iso2, options[:country_iso2], String, true) params[:country_iso2] = options[:country_iso2] end if options.key?(:type) && valid_param?(:type, options[:type], String, true) params[:type] = options[:type] end if options.key?(:service) && valid_param?(:service, options[:service], String, true) params[:service] = options[:service] end perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number', 'GET', params, true) end
Source
# File lib/plivo/resources/powerpacks.rb, line 481 def remove(number, unrent= false) perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s , 'DELETE', { unrent: unrent }, false) end