capsule_crm 0.10.0 → 0.10.2
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/organization.rb +4 -5
- data/lib/capsule_crm/party.rb +12 -4
- data/lib/capsule_crm/person.rb +2 -4
- data/lib/capsule_crm/version.rb +1 -1
- data/spec/lib/capsule_crm/case_spec.rb +1 -1
- data/spec/lib/capsule_crm/organization_spec.rb +30 -0
- data/spec/support/no_parties.json +3 -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: fe0200eaa38f56d70ebe6aac7a0753b881cd57d5
|
4
|
+
data.tar.gz: 3fddf33fe50156ea8949b456dd072544e01d2b59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 186db3ab34a48f0417c7a50e31b7f77952a12a39c7e1053c1889c9a0e83b3299308899d308d8357e4fcd6dafdb23b5092267a98f90df01ef9bf95f06398bfc90
|
7
|
+
data.tar.gz: 0def9e908692cad017f50a03c8d8d88abdc9362e79ae7f1f4c5fa3d2413e18ffc0a019ad9c6b621b2675dbb48e22e8a124116125274fa353b18c83fb2c11484e
|
@@ -20,7 +20,8 @@ module CapsuleCRM
|
|
20
20
|
validates :name, presence: true
|
21
21
|
|
22
22
|
has_many :people, class_name: 'CapsuleCRM::Person', source: :organization
|
23
|
-
has_many :custom_fields, class_name: 'CapsuleCRM::CustomField',
|
23
|
+
has_many :custom_fields, class_name: 'CapsuleCRM::CustomField',
|
24
|
+
source: :organization
|
24
25
|
|
25
26
|
# Public: Get all people from Capsule. The list can be restricted
|
26
27
|
# and/or paginated with various query parameters sent through the options
|
@@ -44,10 +45,8 @@ module CapsuleCRM
|
|
44
45
|
#
|
45
46
|
# Returns a ResultsProxy of organisations
|
46
47
|
def self.all(options = {})
|
47
|
-
|
48
|
-
CapsuleCRM::
|
49
|
-
get('/api/party', options)['parties']['organisation']
|
50
|
-
)
|
48
|
+
CapsuleCRM::Party.all(options).
|
49
|
+
delete_if { |item| !item.is_a?(CapsuleCRM::Organization) }
|
51
50
|
end
|
52
51
|
|
53
52
|
# Public: Get an organization by ID
|
data/lib/capsule_crm/party.rb
CHANGED
@@ -9,7 +9,9 @@ class CapsuleCRM::Party
|
|
9
9
|
has_many :tasks, class_name: 'CapsuleCRM::Task', source: :party
|
10
10
|
|
11
11
|
def self.all(options = {})
|
12
|
+
process_options(options)
|
12
13
|
attributes = CapsuleCRM::Connection.get('/api/party', options)
|
14
|
+
|
13
15
|
init_collection(attributes['parties'])
|
14
16
|
end
|
15
17
|
|
@@ -25,6 +27,7 @@ class CapsuleCRM::Party
|
|
25
27
|
def self.init_collection(collection)
|
26
28
|
CapsuleCRM::ResultsProxy.new(
|
27
29
|
collection.map do |key, value|
|
30
|
+
next unless %w(organisation person).include?(key)
|
28
31
|
[collection[key]].flatten.map do |attrs|
|
29
32
|
party_classes[key].constantize.new(attrs)
|
30
33
|
end.flatten
|
@@ -33,9 +36,14 @@ class CapsuleCRM::Party
|
|
33
36
|
end
|
34
37
|
|
35
38
|
def self.party_classes
|
36
|
-
{
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
{ person: 'CapsuleCRM::Person', organisation: 'CapsuleCRM::Organization' }.
|
40
|
+
stringify_keys
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.process_options(options)
|
44
|
+
if options[:lastmodified] && options[:lastmodified].respond_to?(:strftime)
|
45
|
+
options[:lastmodified] = options[:lastmodified].
|
46
|
+
strftime("%Y%m%dT%H%M%SZ")
|
47
|
+
end
|
40
48
|
end
|
41
49
|
end
|
data/lib/capsule_crm/person.rb
CHANGED
@@ -54,10 +54,8 @@ module CapsuleCRM
|
|
54
54
|
#
|
55
55
|
# Returns a ResultsProxy of organisations
|
56
56
|
def self.all(options = {})
|
57
|
-
|
58
|
-
CapsuleCRM::
|
59
|
-
get('/api/party', options)['parties']['person']
|
60
|
-
)
|
57
|
+
CapsuleCRM::Party.all(options).
|
58
|
+
delete_if { |item| !item.is_a?(CapsuleCRM::Person) }
|
61
59
|
end
|
62
60
|
|
63
61
|
# Public: Create a new person in capsulecrm
|
data/lib/capsule_crm/version.rb
CHANGED
@@ -11,6 +11,36 @@ describe CapsuleCRM::Organization do
|
|
11
11
|
to_return(body: File.read('spec/support/all_users.json'))
|
12
12
|
end
|
13
13
|
|
14
|
+
describe '.all' do
|
15
|
+
context 'when some parties exist' do
|
16
|
+
before do
|
17
|
+
stub_request(:get, /\/api\/party$/).
|
18
|
+
to_return(body: File.read('spec/support/all_parties.json'))
|
19
|
+
end
|
20
|
+
|
21
|
+
subject { CapsuleCRM::Organization.all }
|
22
|
+
|
23
|
+
it { expect(subject).to be_a(Array) }
|
24
|
+
|
25
|
+
it { expect(subject.length).to eql(1) }
|
26
|
+
|
27
|
+
it { expect(subject.first).to be_a(CapsuleCRM::Organization) }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when no parties exist' do
|
31
|
+
before do
|
32
|
+
stub_request(:get, /\/api\/party$/).
|
33
|
+
to_return(body: File.read('spec/support/no_parties.json'))
|
34
|
+
end
|
35
|
+
|
36
|
+
subject { CapsuleCRM::Organization.all }
|
37
|
+
|
38
|
+
it { expect(subject).to be_a(Array) }
|
39
|
+
|
40
|
+
it { expect(subject.length).to eql(0) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
14
44
|
describe '#people' do
|
15
45
|
let(:organization) { Fabricate.build(:organization, id: 1) }
|
16
46
|
|
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.10.
|
4
|
+
version: 0.10.2
|
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-
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -334,6 +334,7 @@ files:
|
|
334
334
|
- spec/support/milestones.json
|
335
335
|
- spec/support/no_customfields.json
|
336
336
|
- spec/support/no_history.json
|
337
|
+
- spec/support/no_parties.json
|
337
338
|
- spec/support/opportunity.json
|
338
339
|
- spec/support/organisation.json
|
339
340
|
- spec/support/person.json
|
@@ -412,6 +413,7 @@ test_files:
|
|
412
413
|
- spec/support/milestones.json
|
413
414
|
- spec/support/no_customfields.json
|
414
415
|
- spec/support/no_history.json
|
416
|
+
- spec/support/no_parties.json
|
415
417
|
- spec/support/opportunity.json
|
416
418
|
- spec/support/organisation.json
|
417
419
|
- spec/support/person.json
|