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.



25
26
27
# File 'lib/unresponsys/supplemental_table.rb', line 25

def initialize(table)
  @table = table
end

Instance Method Details

#find(primary_key) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/unresponsys/supplemental_table.rb', line 29

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



41
42
43
# File 'lib/unresponsys/supplemental_table.rb', line 41

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