Method: Plivo::Resources::NumberInterface#add_number

Defined in:
lib/plivo/resources/numbers.rb

#add_number(numbers, carrier, region, options = nil) ⇒ Object

Parameters:

  • numbers (Array)

    An array of numbers that need to be added for the carrier. Make sure that you configure the numbers to point to the sip server @sbc.plivo.com. Eg: If the number you own from your carrier is 18554675486 then the sip address it needs to point to is [email protected]

  • carrier (String)

    The carrier_id of the IncomingCarrier that the number is associated with. For more information, check our IncomingCarrier API /

  • region (String)

    This is the region that is associated with the Number. You can use it to organize numbers based on the area they are from.

  • options (Hash) (defaults to: nil)

Options Hash (options):

  • :number_type (String)

    This field does not impact the way Plivo uses this number. It is primarily adding more information about your number. You may use this field to categorize between local and tollfree numbers. Default is local.

  • :app_id (String)

    The application id of the application that is to be linked.

  • :subaccount (String)

    The auth_id of the subaccount to which this number should be added. This can only be performed by a main account holder.



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/plivo/resources/numbers.rb', line 269

def add_number(numbers, carrier, region, options = nil)
  valid_param?(:carrier, carrier, [String, Symbol], true)
  valid_param?(:region, region, [String, Symbol], true)
  valid_param?(:numbers, numbers, Array, true)
  numbers.each do |number|
    valid_param?(:number, number, [Integer, String, Symbol], true)
  end

  params = {
    numbers: numbers.join(','),
    carrier: carrier,
    region: region
  }

  return perform_post(params) if options.nil?

  if options.key?(:subaccount) &&
     valid_subaccount?(options[:subaccount], true)
    params[:subaccount] = options[:subaccount]
  end

  %i[number_type app_id].each do |param|
    if options.key?(param) &&
       valid_param?(param, options[param], [String, Symbol], true)
      params[param] = options[param]
    end
  end

  perform_post(params)
end