Class: CapsuleCRM::Organization

Inherits:
Party
  • Object
show all
Extended by:
ActiveModel::Callbacks, ActiveModel::Conversion, ActiveModel::Naming
Includes:
ActiveModel::Validations, Contactable, Persistence::Deletable, Persistence::Persistable, Querying::Configuration, Serializable
Defined in:
lib/capsule_crm/organization.rb

Class Method Summary collapse

Methods included from Serializable

included, #serializer, #to_capsule_json

Methods included from Querying::Configuration

included

Methods included from Persistence::Deletable

#build_destroy_path, #destroy

Methods included from Persistence::Persistable

#build_create_path, #build_update_path, #create_record, included, #new_record?, #persisted?, #save, #save!, #update_attributes, #update_attributes!, #update_record

Methods included from Contactable

#contacts, #contacts=

Methods included from Taggable

#add_tag, #api_singular_name, #remove_tag, #tags

Methods included from Querying::Findable

included

Methods included from Inspector

#inspect

Class Method Details

.all(options = {}) ⇒ Object

Public: Get all people from Capsule. The list can be restricted and/or paginated with various query parameters sent through the options hash.

options - The Hash of allowed query parameters for Capsule (default: {}):

:q      - The String search term that will be matched against
name,
:tag    - The String tag to search for
:start  - The Integer first record to be returned in
pagination.
The results start with an index of 1
:limit  - The Integer maximum number of matching records to be
returned

Examples

CapsuleCRM::Organization.all

CapsuleCRM::Organization.all(q: “a search query”, start: 10, limit: 20)

Returns a ResultsProxy of organisations



62
63
64
65
# File 'lib/capsule_crm/organization.rb', line 62

def self.all(options = {})
  CapsuleCRM::Party.all(options).
    delete_if { |item| !item.is_a?(CapsuleCRM::Organization) }
end

.firstObject

Raises:

  • (NotImplementedError)


67
68
69
70
71
72
73
74
75
76
77
# File 'lib/capsule_crm/organization.rb', line 67

def self.first
  raise NotImplementedError.new(
    [
      'Unfortunately the capsulecrm.com API returns people and',
      'organizations in one response. There is no way to query directly',
      'for people. This means that quite often the first item returned',
      'will actually be a person and so CapsuleCRM::Organization.first is',
      'not possible.'
    ].join(' ')
  )
end