agilecrm-wrapper 1.2.2 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d15b190a01703b24915e62505a8a6b8b78b7612
4
- data.tar.gz: c5ed615856075d490c1f268256a3698fecc40ce9
3
+ metadata.gz: cb6498156df658dd013f55a0ef648db8e1a4be19
4
+ data.tar.gz: 284ce3090e82ccd8521ef743ced830ad331a6ccf
5
5
  SHA512:
6
- metadata.gz: a31a718cf288d1357b8871129d4975200596cfa8633236e5615c6f4c6fd231af2b184688a6a539309c945aeebcd215b8b320c70c4a79d43a5c735dae64ef0008
7
- data.tar.gz: 5eb132546b3cbd9f39ab1b9d44c8a3704ee24c212921711f5f43f024609e5eaf9469bc137de600138852e1ad4de4061d6b6e891d4dda70aa4d0efafb9ef675bb
6
+ metadata.gz: 73cf475fad4d0bb0488590c290e521aa8325a46ab78ebf0f9633cc28a6628663e53a4ceafbd1e3806e0736060bda7e7bf47ebfa04c319dad7d36c49e244a4bd5
7
+ data.tar.gz: a45386c38df87c6c4265641968c3ca7253e9c421699ec8a261594eeaa1b1e95fcc5675ffbd557cb684e951d687e3068a677f60fdf9a57006ccf8fa76a2131b77
data/README.md CHANGED
@@ -56,6 +56,11 @@ contacts = AgileCRMWrapper::Contact.search_by_email(
56
56
  )
57
57
  ```
58
58
 
59
+ ###### To find contacts by any field
60
+ ```ruby
61
+ contacts = AgileCRMWrapper::Contact.search("foo")
62
+ ```
63
+
59
64
  ###### To create a new contact
60
65
  ```ruby
61
66
  AgileCRMWrapper::Contact.create(
@@ -39,6 +39,17 @@ module AgileCRMWrapper
39
39
  end
40
40
  end
41
41
 
42
+ def search(query, type="PERSON", page_size=10)
43
+ response = AgileCRMWrapper.connection.get(
44
+ "search?q=#{query}&type=#{type}&page_size=#{page_size}"
45
+ )
46
+ if response.status == 200
47
+ return response.body.map { |body| new body }
48
+ else
49
+ return response
50
+ end
51
+ end
52
+
42
53
  def create(options = {})
43
54
  payload = parse_contact_fields(options)
44
55
  response = AgileCRMWrapper.connection.post('contacts', payload)
@@ -1,3 +1,3 @@
1
1
  module AgileCRMWrapper
2
- VERSION = '1.2.2'
2
+ VERSION = '1.3.2'
3
3
  end
@@ -62,6 +62,15 @@ describe AgileCRMWrapper::Contact do
62
62
  end
63
63
  end
64
64
 
65
+ describe '.search' do
66
+ let(:name) { 'Anita' }
67
+ subject { AgileCRMWrapper::Contact.search(name) }
68
+
69
+ it 'should return a contact by matching any field' do
70
+ expect(subject[0].get_property('user_name')).to eq name
71
+ end
72
+ end
73
+
65
74
  describe '.create' do
66
75
  subject do
67
76
  AgileCRMWrapper::Contact.create(
@@ -0,0 +1,104 @@
1
+ [
2
+ {
3
+ "count":1,
4
+ "id":5675267779461120,
5
+ "type":"PERSON",
6
+ "created_time":1434553133,
7
+ "updated_time":1434553134,
8
+ "last_contacted":0,
9
+ "last_emailed":0,
10
+ "last_campaign_emaild":0,
11
+ "last_called":0,
12
+ "viewed_time":0,
13
+ "viewed":{
14
+ "viewed_time":0
15
+ },
16
+ "star_value":0,
17
+ "lead_score":0,
18
+ "tags":[
19
+
20
+ ],
21
+ "tagsWithTime":[
22
+
23
+ ],
24
+ "properties":[
25
+ {
26
+ "type":"SYSTEM",
27
+ "name":"email",
28
+ "value":"anita@test.net"
29
+ },
30
+ {
31
+ "type":"CUSTOM",
32
+ "name":"user_name",
33
+ "value":"Anita"
34
+ }
35
+ ],
36
+ "campaignStatus":[
37
+
38
+ ],
39
+ "entity_type":"contact_entity",
40
+ "unsubscribeStatus":[
41
+
42
+ ],
43
+ "emailBounceStatus":[
44
+
45
+ ],
46
+ "formId":0,
47
+ "owner":{
48
+ "id":111111111111,
49
+ "domain":"test",
50
+ "email":"test@test.net",
51
+ "referer":{
52
+ "referral_count":0
53
+ },
54
+ "is_admin":true,
55
+ "is_account_owner":true,
56
+ "is_disabled":false,
57
+ "scopes":[
58
+ "VIEW_CONTACTS",
59
+ "IMPORT_CONTACTS",
60
+ "EXPORT_CONTACTS",
61
+ "UPDATE_CONTACT",
62
+ "DELETE_CONTACTS",
63
+ "CREATE_CONTACT"
64
+ ],
65
+ "newscopes":[
66
+ "VIEW_CONTACTS",
67
+ "IMPORT_CONTACTS",
68
+ "EXPORT_CONTACTS",
69
+ "UPDATE_CONTACT",
70
+ "DELETE_CONTACTS",
71
+ "CREATE_CONTACT"
72
+ ],
73
+ "newMenuScopes":[
74
+ "CONTACT",
75
+ "CALENDAR",
76
+ "DEALS",
77
+ "CAMPAIGN",
78
+ "CASES",
79
+ "SOCIAL",
80
+ "WEBRULE",
81
+ "DOCUMENT",
82
+ "ACTIVITY",
83
+ "REPORT"
84
+ ],
85
+ "menu_scopes":[
86
+ "CONTACT",
87
+ "CALENDAR",
88
+ "DEALS",
89
+ "CAMPAIGN",
90
+ "CASES",
91
+ "SOCIAL",
92
+ "WEBRULE",
93
+ "DOCUMENT",
94
+ "ACTIVITY",
95
+ "REPORT"
96
+ ],
97
+ "restricted_menu_scopes":[
98
+
99
+ ],
100
+ "name":"Test Test",
101
+ "password":"PASSWORD"
102
+ }
103
+ }
104
+ ]
@@ -26,6 +26,10 @@ class FakeAgileCRM < Sinatra::Base
26
26
  end
27
27
  end
28
28
 
29
+ get '/dev/api/search' do
30
+ json_response 200, 'contacts', 'search'
31
+ end
32
+
29
33
  post '/dev/api/notes' do
30
34
  json_response 200, 'notes', 'create_note'
31
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agilecrm-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-10 00:00:00.000000000 Z
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -223,6 +223,7 @@ files:
223
223
  - spec/fixtures/contacts/get_contact.json
224
224
  - spec/fixtures/contacts/get_contact_notes.json
225
225
  - spec/fixtures/contacts/list_contacts.json
226
+ - spec/fixtures/contacts/search.json
226
227
  - spec/fixtures/contacts/search_by_email.json
227
228
  - spec/fixtures/contacts/search_by_email_no_results.json
228
229
  - spec/fixtures/contacts/updated_contact.json
@@ -264,6 +265,7 @@ test_files:
264
265
  - spec/fixtures/contacts/get_contact.json
265
266
  - spec/fixtures/contacts/get_contact_notes.json
266
267
  - spec/fixtures/contacts/list_contacts.json
268
+ - spec/fixtures/contacts/search.json
267
269
  - spec/fixtures/contacts/search_by_email.json
268
270
  - spec/fixtures/contacts/search_by_email_no_results.json
269
271
  - spec/fixtures/contacts/updated_contact.json
@@ -272,4 +274,3 @@ test_files:
272
274
  - spec/fixtures/tags/list_tags.json
273
275
  - spec/spec_helper.rb
274
276
  - spec/support/fake_agilecrm.rb
275
- has_rdoc: