Class: QBFC::List

Inherits:
Element show all
Defined in:
lib/qbfc/list.rb

Overview

List objects are those with names, such as Accounts, Entities, and Items.

Note on the name: it doesn’t make sense since a List is actually a single object, but it fits with the SDK’s naming scheme, and I couldn’t think of a better one.

Direct Known Subclasses

Account, Entity, Item, QBClass, Terms

Constant Summary collapse

ID_NAME =
"ListID"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

base_class_find, #custom, find, #initialize, is_base_class, is_base_class?, #new_record?, #save

Methods inherited from Base

create_query, #initialize, is_base_class?, #method_missing, #ole_methods, parse_find_args, qb_name, #qb_name, #respond_to_ole?

Constructor Details

This class inherits a constructor from QBFC::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class QBFC::Base

Class Method Details

.find_by_id(sess, id, options = {}) ⇒ Object

Find by ListID of List record. options are the same as those for in find.



24
25
26
27
28
# File 'lib/qbfc/list.rb', line 24

def find_by_id(sess, id, options = {})
  q = create_query(sess)
  q.query.ListIDList.Add(id)
  find(sess, :first, q, options)
end

.find_by_name(sess, full_name, options = {}) ⇒ Object Also known as: find_by_full_name

Find by name (actually, FullName) of List record. options are the same as those for in find.



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

def find_by_name(sess, full_name, options = {})
  q = create_query(sess)
  q.query.FullNameList.Add(full_name)
  find(sess, :first, q, options)
end

.find_by_name_or_id(*args) ⇒ Object Also known as: find_by_unique_id

Find by either name or id. Tries id first, then name.



31
32
33
# File 'lib/qbfc/list.rb', line 31

def find_by_name_or_id(*args)
  find_by_id(*args) || find_by_name(*args)
end

Instance Method Details

#deleteObject

Delete this List record.



53
54
55
56
57
58
59
# File 'lib/qbfc/list.rb', line 53

def delete
  req = QBFC::Request.new(@sess, "ListDel")
  req.list_del_type = QBFC_CONST::const_get("Ldt#{qb_name}")
  req.list_id = id
  req.submit
  return true
end

#displayObject

Display the Transaction add (for new records) or edit dialog box



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/qbfc/list.rb', line 62

def display
  if new_record?
    req = QBFC::Request.new(@sess, "ListDisplayAdd")
    req.list_display_add_type = QBFC_CONST::const_get("Ldat#{qb_name}")
  else
    req = QBFC::Request.new(@sess, "ListDisplayMod")
    req.list_display_mod_type = QBFC_CONST::const_get("Ldmt#{qb_name}")
    req.list_id = id
  end
  req.submit
  return true
end

#full_nameObject

If an entity has a Name field but not a FullName field, use Name (which, by implication, is the FullName)



46
47
48
49
50
# File 'lib/qbfc/list.rb', line 46

def full_name
  respond_to_ole?("FullName") ?
    @ole.full_name :
    @ole.name
end

#idObject

Alias of ListID for this record. This is a unique within each type of List.



40
41
42
# File 'lib/qbfc/list.rb', line 40

def id
  @ole.list_id
end