Class: RIQ::Account
Overview
Accounts represent companies (or other entities).
Instance Attribute Summary collapse
-
#field_values ⇒ Object
Returns the value of attribute field_values.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from RIQObject
Class Method Summary collapse
Instance Method Summary collapse
-
#data ⇒ Hash
All relevant stored data.
- #field_value(key, value = nil) ⇒ Object
-
#node ⇒ String
Endpoint.
-
#payload ⇒ String
The JSON representation of #data.
Methods inherited from RIQObject
Constructor Details
This class inherits a constructor from RIQ::RIQObject
Instance Attribute Details
#field_values ⇒ Object
Returns the value of attribute field_values.
8 9 10 |
# File 'lib/riq/account.rb', line 8 def field_values @field_values end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/riq/account.rb', line 7 def name @name end |
Class Method Details
.node(arg = nil) ⇒ Object
16 17 18 |
# File 'lib/riq/account.rb', line 16 def self.node(arg = nil) "accounts" end |
Instance Method Details
#data ⇒ Hash
Returns all relevant stored data.
21 22 23 24 25 26 27 |
# File 'lib/riq/account.rb', line 21 def data { id: @id, name: @name, field_values: @field_values } end |
#field_value(key) ⇒ Array #field_value(key, value) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/riq/account.rb', line 45 def field_value(key, value = nil) # TODO: double check that this works with arrays of stuff # or, have a format function that casts ints to string on save if value.nil? @field_values.fetch(key.to_sym, nil) else @field_values[key.to_sym] = value.to_s {key.to_sym => value.to_s} end end |
#node ⇒ String
Returns endpoint.
11 12 13 |
# File 'lib/riq/account.rb', line 11 def node "accounts/#{@id}" end |
#payload ⇒ String
Returns the JSON representation of #data.
30 31 32 33 34 35 36 |
# File 'lib/riq/account.rb', line 30 def payload # TODO: find more elegant way to do this pld = data pld['fieldValues'] = @field_values.to_raw pld.delete(:field_values) pld.to_json end |