Class: Plivo::Resources::ProfileInterface

Inherits:
Base::ResourceInterface show all
Defined in:
lib/plivo/resources/profile.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

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, resource_list_json = nil) ⇒ ProfileInterface

Returns a new instance of ProfileInterface.



19
20
21
22
23
24
# 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

Instance Method Details

#create(options = nil) ⇒ Object

Create a new Profile



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# 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) ⇒ Object

Delete an Profile

Parameters:

  • profile_uuid (String)


57
58
59
60
# 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) ⇒ Profile

Get an Profile

Parameters:

  • profile_uuid (String)

Returns:



30
31
32
33
# 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) ⇒ Object

List all Profile



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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) ⇒ Object

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



87
88
89
90
# 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