Class: Plivo::Resources::Account

Inherits:
Base::Resource show all
Defined in:
lib/plivo/resources/accounts.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Attribute Summary

Attributes inherited from Base::Resource

#id

Instance Method Summary collapse

Methods included from Utils

expected_type?, expected_value?, raise_invalid_request, valid_account?, valid_mainaccount?, valid_param?, valid_signature?, valid_subaccount?

Constructor Details

#initialize(client, options = nil) ⇒ Account

Returns a new instance of Account.



126
127
128
129
130
# File 'lib/plivo/resources/accounts.rb', line 126

def initialize(client, options = nil)
  @_name = 'Account'
  @_identifier_string = 'auth_id'
  super
end

Instance Method Details

#to_sObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/plivo/resources/accounts.rb', line 146

def to_s
  {
    account_type: @account_type,
    address: @address,
    api_id: @api_id,
    auth_id: @auth_id,
    auto_recharge: @auto_recharge,
    billing_mode: @billing_mode,
    cash_credits: @cash_credits,
    city: @city,
    name: @name,
    resource_uri: @resource_uri,
    state: @state,
    timezone: @timezone
  }.to_s
end

#update(details) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/plivo/resources/accounts.rb', line 132

def update(details)
  valid_param?(:details, details, Hash, true)

  params = {}
  %i[name city address].each do |param|
    if details.key?(param) && valid_param?(param, details[param], [String, Symbol], true)
      params[param] = details[param]
    end
  end

  raise_invalid_request('One parameter of name, city and address is required') if params == {}
  perform_update(params)
end