Class: RIQ::List

Inherits:
RIQObject show all
Defined in:
lib/riq/list.rb

Overview

A List is an object that can be created and customized by a User to represent Accounts (companies) or Contacts (people) in a process (such as a sales pipeline).

Instance Attribute Summary collapse

Attributes inherited from RIQObject

#id, #modified_date

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RIQObject

#delete, #payload

Constructor Details

#initialize(id = nil) ⇒ RIQObject

Returns Self.

Parameters:

  • id (String, Hash) (defaults to: nil)

    ObjectId or well-formatted hash of data (usually provided by another object



15
16
17
18
# File 'lib/riq/list.rb', line 15

def initialize(id = nil)
  super
  @list_items = ListItemManager.new(@id)
end

Instance Attribute Details

#list_itemsObject (readonly)

Returns the value of attribute list_items.



10
11
12
# File 'lib/riq/list.rb', line 10

def list_items
  @list_items
end

#titleObject (readonly) Also known as: name

can’t create a list through API, so these don’t need to write



8
9
10
# File 'lib/riq/list.rb', line 8

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/riq/list.rb', line 9

def type
  @type
end

Class Method Details

.node(id = nil) ⇒ String

Returns endpoint.

Parameters:

  • id (String) (defaults to: nil)

    ObjectId

Returns:

  • (String)

    endpoint



26
27
28
# File 'lib/riq/list.rb', line 26

def self.node(id = nil)
  "lists/#{id}"
end

Instance Method Details

#dataHash

Returns all relevant stored data.

Returns:

  • (Hash)

    all relevant stored data



31
32
33
34
35
36
37
38
# File 'lib/riq/list.rb', line 31

def data
  {
    id: @id,
    title: @title,
    type: @type,
    fields: @fields
  }
end

#fields(id = nil) ⇒ Hash?

Gets field if it exists

Parameters:

  • id (String, Integer) (defaults to: nil)

    field ID

Returns:

  • (Hash, nil)

    info on the field specified



48
49
50
51
52
53
54
# File 'lib/riq/list.rb', line 48

def fields(id = nil)
  unless id.nil?
    @fields.select{|f| f[:id] == id.to_s}.first
  else
    @fields
  end
end

#list_item(oid = nil) ⇒ Object

Convenience method for fetching or creating a listitem from the given list

Parameters:

  • oid (String, nil) (defaults to: nil)

    ObjectId



58
59
60
# File 'lib/riq/list.rb', line 58

def list_item(oid = nil)
  RIQ::ListItem.new(oid, lid: @id)
end

#nodeString

Returns endpoint.

Returns:

  • (String)

    endpoint



21
22
23
# File 'lib/riq/list.rb', line 21

def node
  self.class.node(@id)
end

#saveObject

Overwriting parent because lists can’t be saved through the API



41
42
43
# File 'lib/riq/list.rb', line 41

def save
  raise NotImplementedError, "Lists can't be edited through the API"
end