Class: Unresponsys::SupplementalTable::Rows

Inherits:
Object
  • Object
show all
Defined in:
lib/unresponsys/supplemental_table.rb

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ Rows

Returns a new instance of Rows.



17
18
19
# File 'lib/unresponsys/supplemental_table.rb', line 17

def initialize(table)
  @table = table
end

Instance Method Details

#find(primary_key) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/unresponsys/supplemental_table.rb', line 21

def find(primary_key)
  options = { query: { qa: 'ID_', id: primary_key.to_responsys, fs: 'all' } }
  r       = @table.client.get("/folders/#{@table.folder.name}/suppData/#{@table.name}/members", options)

  fields = {}
  r['recordData']['fieldNames'].each_with_index do |field, index|
    fields[field] = r['recordData']['records'][0][index]
  end

  Unresponsys::Row.new(@table, fields)
end

#new(primary_key) ⇒ Object



33
34
35
# File 'lib/unresponsys/supplemental_table.rb', line 33

def new(primary_key)
  Unresponsys::Row.new(@table, { 'ID_' => primary_key })
end