Class: Plivo::Resources::Tollfree

Inherits:
Base::Resource show all
Defined in:
lib/plivo/resources/powerpacks.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Attribute Summary

Attributes inherited from Base::Resource

#id

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, options = nil) ⇒ Tollfree

Returns a new instance of Tollfree.



582
583
584
585
586
# File 'lib/plivo/resources/powerpacks.rb', line 582

def initialize(client, options = nil)
  @_name = 'Tollfree'
  @_identifier_string = 'number_pool_id'
  super
end

Instance Method Details

#add(tollfree) ⇒ Object



588
589
590
591
# File 'lib/plivo/resources/powerpacks.rb', line 588

def add(tollfree)
  perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Tollfree/' + tollfree.to_s ,
               'POST')
end

#find(tollfree) ⇒ Object



616
617
618
619
# File 'lib/plivo/resources/powerpacks.rb', line 616

def find(tollfree)
  perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Tollfree/' + tollfree.to_s ,
               'GET')
end

#list(options = nil) ⇒ Object



593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# File 'lib/plivo/resources/powerpacks.rb', line 593

def list(options = nil)
  return perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Tollfree',
               '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 + '/Tollfree',
               'GET')
end

#remove(tollfree, unrent = false) ⇒ Object



621
622
623
624
# File 'lib/plivo/resources/powerpacks.rb', line 621

def remove(tollfree, unrent= false)
  perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Tollfree/' + tollfree.to_s ,
               'DELETE', { unrent: unrent }, false)
end