class Plivo::Resources::BrandInterface

Public Class Methods

new(client, resource_list_json = nil) click to toggle source
Calls superclass method Plivo::Base::ResourceInterface::new
# File lib/plivo/resources/brand.rb, line 20
def initialize(client, resource_list_json = nil)
  @_name = '10dlc/Brand'
  @_resource_type = Brand
  @_identifier_string = 'brand_id'
  super
end

Public Instance Methods

create(options=nil) click to toggle source

Create a new brand

# File lib/plivo/resources/brand.rb, line 66
def create(options=nil)
  valid_param?(:options, options, Hash, true)
  if not options[:brand_alias]
    raise_invalid_request("brand_alias must be provided")
  end
  if not options[:brand_type]
    raise_invalid_request("brand_type must be provided")
  end
  if not options[:profile_uuid]
    raise_invalid_request("profile_uuid must be provided")
  end
  perform_create(options)
end
delete(brand_id) click to toggle source

Delete Brand @param [String] brand_id

# File lib/plivo/resources/brand.rb, line 92
def delete(brand_id)
  valid_param?(:brand_id, brand_id, [String, Symbol], true)
  perform_delete(brand_id)
end
get(brand_id) click to toggle source

Get an Brand @param [String] brand_id @return [Brand] Brand

# File lib/plivo/resources/brand.rb, line 31
def get(brand_id)
  valid_param?(:brand_id, brand_id, [String, Symbol], true)
  perform_get(brand_id)
end
get_usecases(brand_id) click to toggle source

Get BrandUsecase @param [String] brand_id

# File lib/plivo/resources/brand.rb, line 83
def get_usecases(brand_id)
  valid_param?(:brand_id, brand_id, [String, Symbol], true)
  identifier = brand_id + '/usecases'
  perform_action_with_identifier(identifier, 'GET', nil)
end
list(options=nil) click to toggle source

List all Brand @param [Hash] options @option options [String] :type @option options [Status] :status @option options [Status] :limit @option options [Status] :offset @return [Hash]

# File lib/plivo/resources/brand.rb, line 44
def list(options=nil)
  return perform_list_without_object if options.nil?
  
  params = {}
  %i[status type limit offset].each do |param|
    if options.key?(param) && valid_param?(param, options[param],
                                             [String, 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_list_without_object(params)
end