Class: Plivo::Resources::Account

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

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.



119
120
121
122
123
# File 'lib/plivo/resources/accounts.rb', line 119

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

Instance Method Details

#to_sObject



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/plivo/resources/accounts.rb', line 139

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



125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/plivo/resources/accounts.rb', line 125

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