Class: VoiceML::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/voiceml/models/accounts.rb

Overview

Twilio-compatible Account resource. The voiceml SDK is single-account (the credential's account is implicit on every call), so this model exists primarily to decode GET/POST /Accounts/{Sid}.json responses round-trip with the Twilio shape — useful for migration tooling that echoes the account record back to the caller.

Constant Summary collapse

ATTRIBUTES =
%w[
  sid friendly_name status type auth_token owner_account_sid
  date_created date_updated subresource_uris uri
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Account

Returns a new instance of Account.



19
20
21
22
23
24
# File 'lib/voiceml/models/accounts.rb', line 19

def initialize(attrs = {})
  ATTRIBUTES.each do |field|
    value = attrs.key?(field) ? attrs[field] : attrs[field.to_sym]
    instance_variable_set("@#{field}", value)
  end
end

Class Method Details

.from_hash(hash) ⇒ Object



26
27
28
29
30
# File 'lib/voiceml/models/accounts.rb', line 26

def self.from_hash(hash)
  return nil if hash.nil?

  new(hash)
end