class Plivo::Resources::ProfileInterface

Public Class Methods

new(client, resource_list_json = nil) click to toggle source
Calls superclass method Plivo::Base::ResourceInterface::new
# File lib/plivo/resources/profile.rb, line 19
def initialize(client, resource_list_json = nil)
    @_name = 'Profile'
    @_resource_type = Profile
    @_identifier_string = 'profile_uuid'
    super
end

Public Instance Methods

create(options = nil) click to toggle source

Create a new Profile

# File lib/plivo/resources/profile.rb, line 64
def create(options = nil)
    valid_param?(:options, options, Hash, true)
    if not options[:profile_alias]
        raise_invalid_request("profile_alias must be provided")
    end
    if not options[:customer_type]
        raise_invalid_request("customer_type must be provided")
    end
    if not options[:entity_type]
        raise_invalid_request("entity_type must be provided")
    end
    if not options[:company_name]
        raise_invalid_request("company_name must be provided")
    end
    if not options[:vertical]
        raise_invalid_request("vertical must be provided")
    end
    perform_create(options)
end
delete(profile_uuid) click to toggle source

Delete an Profile @param [String] profile_uuid

# File lib/plivo/resources/profile.rb, line 57
def delete(profile_uuid)
    valid_param?(:profile_uuid, profile_uuid, [String, Symbol], true)
    perform_action_with_identifier(profile_uuid, 'DELETE', nil)
end
get(profile_uuid) click to toggle source

Get an Profile @param [String] profile_uuid @return [Profile] Profile

# File lib/plivo/resources/profile.rb, line 30
def get(profile_uuid)
    valid_param?(:profile_uuid, profile_uuid, [String, Symbol], true)
    perform_get(profile_uuid)
end
list(options = nil) click to toggle source

List all Profile

# File lib/plivo/resources/profile.rb, line 36
def list(options = nil)
  return perform_list_without_object 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_list_without_object(params)
end
update(profile_uuid, options = nil) click to toggle source

Update a Profile {‘address’: {}, ‘authorized_contact’: {}, ‘entity_type’:”, ‘vertical’: ”, ‘company_name’: ”, ‘website’:”}

# File lib/plivo/resources/profile.rb, line 87
def update(profile_uuid, options = nil)
  valid_param?(:options, options, Hash, true)
  perform_action_with_identifier(profile_uuid, "POST", options)
end