capsule_crm 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/capsule_crm/party.rb +11 -3
- data/lib/capsule_crm/person.rb +28 -0
- data/lib/capsule_crm/version.rb +1 -1
- data/spec/lib/capsule_crm/party_spec.rb +24 -0
- data/spec/lib/capsule_crm/person_spec.rb +14 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59e0eebbeda04a3250c97232ea18644a14122faf
|
4
|
+
data.tar.gz: ea18da6190a19d6d2d45b70950d1fbab38eeb92e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cb6dba2711c9b58643bf0770a62a1be126fce21e46846935c32e152517e4a32cc4345ae4ba79985dec406e07d11d2b5c8908cafc5718fb4cef114277d010bb8
|
7
|
+
data.tar.gz: 75c1f04e11c7d9dcbbd94736d4ba0feb7e8750c26e56bfd145325499a1caab8f2bf71d23f27121e2a9a9b35a4815414c4baa6ccd8f85a306dc18dc148b55fd27
|
data/lib/capsule_crm/party.rb
CHANGED
@@ -7,9 +7,7 @@ class CapsuleCRM::Party
|
|
7
7
|
|
8
8
|
def self.all(options = {})
|
9
9
|
attributes = CapsuleCRM::Connection.get('/api/party', options)
|
10
|
-
init_collection(
|
11
|
-
attributes['parties'].fetch('person', 'organisation')
|
12
|
-
)
|
10
|
+
init_collection(attributes['parties'])
|
13
11
|
end
|
14
12
|
|
15
13
|
def self.find(id)
|
@@ -21,6 +19,16 @@ class CapsuleCRM::Party
|
|
21
19
|
|
22
20
|
private
|
23
21
|
|
22
|
+
def self.init_collection(collection)
|
23
|
+
CapsuleCRM::ResultsProxy.new(
|
24
|
+
collection.map do |key, value|
|
25
|
+
[collection[key]].flatten.map do |attrs|
|
26
|
+
party_classes[key].constantize.new(attrs)
|
27
|
+
end.flatten
|
28
|
+
end.flatten
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
24
32
|
def self.party_classes
|
25
33
|
{
|
26
34
|
person: 'CapsuleCRM::Person',
|
data/lib/capsule_crm/person.rb
CHANGED
@@ -31,6 +31,34 @@ module CapsuleCRM
|
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
|
+
# Public: Get all people from Capsule. The list can be restricted
|
35
|
+
# and/or paginated with various query parameters sent through the options
|
36
|
+
# hash.
|
37
|
+
#
|
38
|
+
# options - The Hash of allowed query parameters for Capsule (default: {}):
|
39
|
+
# :q - The String search term that will be matched against
|
40
|
+
# name,
|
41
|
+
# :tag - The String tag to search for
|
42
|
+
# :start - The Integer first record to be returned in
|
43
|
+
# pagination.
|
44
|
+
# The results start with an index of 1
|
45
|
+
# :limit - The Integer maximum number of matching records to be
|
46
|
+
# returned
|
47
|
+
#
|
48
|
+
# Examples
|
49
|
+
#
|
50
|
+
# CapsuleCRM::Organization.all
|
51
|
+
#
|
52
|
+
# CapsuleCRM::Organization.all(q: "a search query", start: 10, limit: 20)
|
53
|
+
#
|
54
|
+
# Returns a ResultsProxy of organisations
|
55
|
+
def self.all(options = {})
|
56
|
+
init_collection(
|
57
|
+
CapsuleCRM::Connection.
|
58
|
+
get('/api/party', options)['parties']['person']
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
34
62
|
# Public: Set the attributes of a person
|
35
63
|
#
|
36
64
|
# attributes - The Hash of attributes (default: {}):
|
data/lib/capsule_crm/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CapsuleCRM::Party do
|
4
|
+
before { configure }
|
5
|
+
|
6
|
+
describe '.find' do
|
7
|
+
pending
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.all' do
|
11
|
+
before do
|
12
|
+
stub_request(:get, /\/api\/party$/).
|
13
|
+
to_return(body: File.read('spec/support/all_parties.json'))
|
14
|
+
end
|
15
|
+
|
16
|
+
subject { CapsuleCRM::Party.all }
|
17
|
+
|
18
|
+
it { subject.length.should eql(3) }
|
19
|
+
|
20
|
+
it { subject.first.should be_a(CapsuleCRM::Organization) }
|
21
|
+
|
22
|
+
it { subject.last.should be_a(CapsuleCRM::Person) }
|
23
|
+
end
|
24
|
+
end
|
@@ -6,6 +6,20 @@ describe CapsuleCRM::Person do
|
|
6
6
|
|
7
7
|
before { configure }
|
8
8
|
|
9
|
+
describe '._for_organization' do
|
10
|
+
context 'when there are many people for the organization' do
|
11
|
+
pending
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when there is 1 person for the organization' do
|
15
|
+
pending
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when there are no people for the organization' do
|
19
|
+
pending
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
9
23
|
describe '.all' do
|
10
24
|
before do
|
11
25
|
stub_request(:get, /\/api\/party$/).
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capsule_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Beedle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -287,6 +287,7 @@ files:
|
|
287
287
|
- spec/lib/capsule_crm/history_spec.rb
|
288
288
|
- spec/lib/capsule_crm/opportunity_spec.rb
|
289
289
|
- spec/lib/capsule_crm/organization_spec.rb
|
290
|
+
- spec/lib/capsule_crm/party_spec.rb
|
290
291
|
- spec/lib/capsule_crm/person_spec.rb
|
291
292
|
- spec/lib/capsule_crm/tag_spec.rb
|
292
293
|
- spec/lib/capsule_crm/taggable_spec.rb
|
@@ -354,6 +355,7 @@ test_files:
|
|
354
355
|
- spec/lib/capsule_crm/history_spec.rb
|
355
356
|
- spec/lib/capsule_crm/opportunity_spec.rb
|
356
357
|
- spec/lib/capsule_crm/organization_spec.rb
|
358
|
+
- spec/lib/capsule_crm/party_spec.rb
|
357
359
|
- spec/lib/capsule_crm/person_spec.rb
|
358
360
|
- spec/lib/capsule_crm/tag_spec.rb
|
359
361
|
- spec/lib/capsule_crm/taggable_spec.rb
|