Class: Plivo::Resources::EndUsersInterface

Inherits:
Base::ResourceInterface show all
Defined in:
lib/plivo/resources/regulatory_compliance.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) ⇒ EndUsersInterface



51
52
53
54
55
56
# File 'lib/plivo/resources/regulatory_compliance.rb', line 51

def initialize(client, resource_list_json = nil)
  @_name = 'EndUser'
  @_resource_type = EndUser
  @_identifier_string = 'end_user'
  super
end

Instance Method Details

#create(name, last_name = nil, end_user_type) ⇒ Object

Create an EndUser return [EndUser] EndUser



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/plivo/resources/regulatory_compliance.rb', line 114

def create(name, last_name = nil , end_user_type)
  valid_param?(:name, name, [String, Symbol], true)
  valid_param?(:last_name, last_name, [String, Symbol], false)
  valid_param?(:end_user_type, end_user_type.capitalize, [String, Symbol], true, %w[Business Individual])

  params = {
    name: name,
    last_name: last_name,
    end_user_type: end_user_type.capitalize
  }

  return perform_create(params)
end

#delete(end_user_id) ⇒ Object

Delete an EndUser.



142
143
144
145
146
# File 'lib/plivo/resources/regulatory_compliance.rb', line 142

def delete(end_user_id)
  valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
  EndUser.new(@_client,
                  resource_id: end_user_id).delete
end

#get(end_user_id) ⇒ Object

Get an EndUser return [EndUser]



62
63
64
65
# File 'lib/plivo/resources/regulatory_compliance.rb', line 62

def get(end_user_id)
  valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
  perform_get(end_user_id)
end

#list(options = nil) ⇒ Hash

List all EndUser

Options Hash (options):

  • :offset (Int)
  • :limit (Int)


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/plivo/resources/regulatory_compliance.rb', line 73

def list(options = nil)
  return perform_list if options.nil?
  valid_param?(:options, options, Hash, true)

  params = {}
  params_expected = i[ name last_name ]
  params_expected.each do |param|
    if options.key?(param) &&
       valid_param?(param, options[param], [String, Symbol], false)
      params[param] = options[param]
    end
  end

  if options.key?(:end_user_type) &&
    valid_param?(:end_user_type, options[:end_user_type].capitalize,[String, Symbol], false,  %w[Business Individual])
    params[:end_user_type] = options[:end_user_type].capitalize
  end

  i[offset limit].each do |param|
    if options.key?(param) && valid_param?(param, options[param],
                                           [Integer], true)
      params[param] = options[param]
    end
  end

  raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0

  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

  perform_list(params)
end

#update(end_user_id, options = nil) ⇒ Object

Update an EndUser return [EndUser]



133
134
135
136
137
# File 'lib/plivo/resources/regulatory_compliance.rb', line 133

def update(end_user_id, options = nil)
  valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
  EndUser.new(@_client,
                  resource_id: end_user_id).update(options)
end