contactually-api 0.0.1
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 +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/Rakefile +7 -0
- data/lib/contactually-api.rb +34 -0
- data/lib/contactually/accounts.rb +31 -0
- data/lib/contactually/api.rb +70 -0
- data/lib/contactually/contact_groupings.rb +16 -0
- data/lib/contactually/contacts.rb +57 -0
- data/lib/contactually/contents.rb +38 -0
- data/lib/contactually/errors.rb +18 -0
- data/lib/contactually/groupings.rb +49 -0
- data/lib/contactually/middleware/error_detector.rb +27 -0
- data/lib/contactually/notes.rb +39 -0
- data/lib/contactually/representer/account_representer.rb +13 -0
- data/lib/contactually/representer/contact_representer.rb +46 -0
- data/lib/contactually/representer/content_representer.rb +16 -0
- data/lib/contactually/representer/grouping_representer.rb +28 -0
- data/lib/contactually/representer/grouping_statistics_representer.rb +12 -0
- data/lib/contactually/representer/note_representer.rb +13 -0
- data/lib/contactually/representer/task_representer.rb +19 -0
- data/lib/contactually/tasks.rb +12 -0
- data/lib/contactually/version.rb +3 -0
- data/spec/accounts_spec.rb +57 -0
- data/spec/api_spec.rb +87 -0
- data/spec/contact_groupings_spec.rb +43 -0
- data/spec/contacts_spec.rb +117 -0
- data/spec/contents_spec.rb +81 -0
- data/spec/fixtures/account.json +10 -0
- data/spec/fixtures/accounts_index.json +16 -0
- data/spec/fixtures/contact.json +38 -0
- data/spec/fixtures/contacts_index.json +169 -0
- data/spec/fixtures/content.json +10 -0
- data/spec/fixtures/contents_index.json +26 -0
- data/spec/fixtures/grouping.json +19 -0
- data/spec/fixtures/groupings_index.json +24 -0
- data/spec/fixtures/groupings_statistics.json +46 -0
- data/spec/fixtures/note.json +7 -0
- data/spec/fixtures/note_destroy.json +4 -0
- data/spec/fixtures/notes_index.json +27 -0
- data/spec/fixtures/task.json +27 -0
- data/spec/groupings_spec.rb +100 -0
- data/spec/notes_spec.rb +89 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/tasks_spec.rb +36 -0
- metadata +194 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Contactually::Contents do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
Contactually.configure { |c| c.api_key = 'VALID_API_KEY' }
|
7
|
+
@master = Contactually::API.new
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { described_class.new @master }
|
11
|
+
describe '#initialize' do
|
12
|
+
specify do
|
13
|
+
expect(subject).to be_kind_of Contactually::Contents
|
14
|
+
end
|
15
|
+
|
16
|
+
specify do
|
17
|
+
expect(subject.instance_variable_get(:@master)).to be_kind_of Contactually::API
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#create' do
|
22
|
+
it 'calls the api with correct params' do
|
23
|
+
json = File.read(File.join(File.dirname(__FILE__),"fixtures/content.json"))
|
24
|
+
allow(@master).to receive(:call).with('contents.json', :post, { content: { foo: :bar }}).and_return(JSON.load(json))
|
25
|
+
subject.create({ content: { foo: :bar }})
|
26
|
+
expect(@master).to have_received(:call)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns a content' do
|
30
|
+
json = File.read(File.join(File.dirname(__FILE__),"fixtures/content.json"))
|
31
|
+
allow(@master).to receive(:call).with('contents.json', :post, { content: { foo: :bar }}).and_return(JSON.load(json))
|
32
|
+
expect(subject.create({ content: { foo: :bar }})).to be_kind_of Contactually::Content
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#index' do
|
37
|
+
it 'calls the api with correct params' do
|
38
|
+
allow(@master).to receive(:call).with('contents.json', :get, { foo: :bar }).and_return({ 'contents' => [] })
|
39
|
+
subject.index({ foo: :bar })
|
40
|
+
expect(@master).to have_received(:call)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns contents from json response' do
|
44
|
+
json = File.read(File.join(File.dirname(__FILE__),"fixtures/contents_index.json"))
|
45
|
+
allow(@master).to receive(:call).with('contents.json', :get, {}).and_return(JSON.load(json))
|
46
|
+
expect(subject.index({})).to be_kind_of Array
|
47
|
+
expect(subject.index({})[0]).to be_kind_of Contactually::Content
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#destroy' do
|
52
|
+
it 'calls the api with correct params' do
|
53
|
+
allow(@master).to receive(:call).with('contents/115.json', :delete, { foo: :bar }).and_return({ 'success' => true })
|
54
|
+
subject.destroy(115, { foo: :bar })
|
55
|
+
expect(@master).to have_received(:call)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#show' do
|
60
|
+
it 'calls the api with correct params' do
|
61
|
+
allow(@master).to receive(:call).with('contents/1.json', :get, { foo: :bar }).and_return({ id: 1 })
|
62
|
+
subject.show(1, { foo: :bar })
|
63
|
+
expect(@master).to have_received(:call)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'returns a contact' do
|
67
|
+
json = File.read(File.join(File.dirname(__FILE__),"fixtures/content.json"))
|
68
|
+
allow(@master).to receive(:call).with('contents/1.json', :get, { foo: :bar }).and_return(JSON.load(json))
|
69
|
+
expect(subject.show(1, { foo: :bar })).to be_kind_of Contactually::Content
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#update' do
|
74
|
+
it 'calls the api with correct params' do
|
75
|
+
allow(@master).to receive(:call).with('contents/1.json', :put, { content: { foo: :bar }})
|
76
|
+
subject.update(1, { content: { foo: :bar } })
|
77
|
+
expect(@master).to have_received(:call)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"count": 1,
|
3
|
+
"total_count": 1,
|
4
|
+
"accounts": [
|
5
|
+
{
|
6
|
+
"id": 13123,
|
7
|
+
"username": "lol@rofl.com",
|
8
|
+
"remote_id": "lol@rofl.com",
|
9
|
+
"type": "Account::Google",
|
10
|
+
"disabled_at": null,
|
11
|
+
"name": "Google Contacts",
|
12
|
+
"nice_label": "lol@rofl.com",
|
13
|
+
"can_sync_contacts": true
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"id": 41296013,
|
3
|
+
"user_id": 7,
|
4
|
+
"first_name": "Test",
|
5
|
+
"last_name": "Ing",
|
6
|
+
"full_name": "Test Ing",
|
7
|
+
"initials": "TI",
|
8
|
+
"title": "",
|
9
|
+
"company": null,
|
10
|
+
"email": "testing@contact.com",
|
11
|
+
"avatar": "",
|
12
|
+
"avatar_url": "",
|
13
|
+
"last_contacted": null,
|
14
|
+
"visible": true,
|
15
|
+
"twitter": null,
|
16
|
+
"facebook_url": null,
|
17
|
+
"linkedin_url": null,
|
18
|
+
"first_contacted": null,
|
19
|
+
"created_at": "2013-07-02T15:45:01Z",
|
20
|
+
"updated_at": "2013-07-02T15:45:01Z",
|
21
|
+
"hits": 0,
|
22
|
+
"team_parent_id": null,
|
23
|
+
"snoozed_at": null,
|
24
|
+
"snooze_days": null,
|
25
|
+
"groupings": [],
|
26
|
+
"email_addresses": [
|
27
|
+
"testing@contact.com"
|
28
|
+
],
|
29
|
+
"tags": [],
|
30
|
+
"contact_status": null,
|
31
|
+
"team_last_contacted": null,
|
32
|
+
"team_last_contacted_by": null,
|
33
|
+
"phone_numbers": [],
|
34
|
+
"addresses": [],
|
35
|
+
"social_profiles": [],
|
36
|
+
"websites": [],
|
37
|
+
"custom_fields": []
|
38
|
+
}
|
@@ -0,0 +1,169 @@
|
|
1
|
+
{
|
2
|
+
"count": 4,
|
3
|
+
"total_count": 4,
|
4
|
+
"contacts": [
|
5
|
+
{
|
6
|
+
"id": 41296013,
|
7
|
+
"user_id": 7,
|
8
|
+
"first_name": "Test",
|
9
|
+
"last_name": "Ing",
|
10
|
+
"full_name": "Test Ing",
|
11
|
+
"initials": "TI",
|
12
|
+
"title": "",
|
13
|
+
"company": null,
|
14
|
+
"email": "testing@contact.com",
|
15
|
+
"avatar": "",
|
16
|
+
"avatar_url": "",
|
17
|
+
"last_contacted": null,
|
18
|
+
"visible": true,
|
19
|
+
"twitter": null,
|
20
|
+
"facebook_url": null,
|
21
|
+
"linkedin_url": null,
|
22
|
+
"first_contacted": null,
|
23
|
+
"created_at": "2013-07-02T15:45:01Z",
|
24
|
+
"updated_at": "2013-07-02T15:45:01Z",
|
25
|
+
"hits": 0,
|
26
|
+
"team_parent_id": null,
|
27
|
+
"snoozed_at": null,
|
28
|
+
"snooze_days": null,
|
29
|
+
"groupings": [],
|
30
|
+
"email_addresses": [
|
31
|
+
"testing@contact.com"
|
32
|
+
],
|
33
|
+
"tags": [],
|
34
|
+
"contact_status": null,
|
35
|
+
"team_last_contacted": null,
|
36
|
+
"team_last_contacted_by": null,
|
37
|
+
"phone_numbers": [],
|
38
|
+
"addresses": [],
|
39
|
+
"social_profiles": [],
|
40
|
+
"websites": [],
|
41
|
+
"custom_fields": []
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"id": 41314854,
|
45
|
+
"user_id": 7,
|
46
|
+
"first_name": "Whats",
|
47
|
+
"last_name": "Uppp",
|
48
|
+
"full_name": "Whats Uppp",
|
49
|
+
"initials": "WU",
|
50
|
+
"title": null,
|
51
|
+
"company": null,
|
52
|
+
"email": null,
|
53
|
+
"avatar": "",
|
54
|
+
"avatar_url": "",
|
55
|
+
"last_contacted": null,
|
56
|
+
"visible": true,
|
57
|
+
"twitter": null,
|
58
|
+
"facebook_url": null,
|
59
|
+
"linkedin_url": null,
|
60
|
+
"first_contacted": null,
|
61
|
+
"created_at": "2013-07-02T18:56:37Z",
|
62
|
+
"updated_at": "2013-07-02T18:56:37Z",
|
63
|
+
"hits": 0,
|
64
|
+
"team_parent_id": null,
|
65
|
+
"snoozed_at": null,
|
66
|
+
"snooze_days": null,
|
67
|
+
"groupings": [],
|
68
|
+
"email_addresses": [],
|
69
|
+
"tags": [],
|
70
|
+
"contact_status": null,
|
71
|
+
"team_last_contacted": null,
|
72
|
+
"team_last_contacted_by": null,
|
73
|
+
"phone_numbers": [],
|
74
|
+
"addresses": [],
|
75
|
+
"social_profiles": [],
|
76
|
+
"websites": [],
|
77
|
+
"custom_fields": []
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"id": 41438693,
|
81
|
+
"user_id": 7,
|
82
|
+
"first_name": "Adding",
|
83
|
+
"last_name": "Contactually",
|
84
|
+
"full_name": "Adding Contactually",
|
85
|
+
"initials": "AC",
|
86
|
+
"title": null,
|
87
|
+
"company": null,
|
88
|
+
"email": "addingto@contacsafasdf.com",
|
89
|
+
"avatar": "",
|
90
|
+
"avatar_url": "",
|
91
|
+
"last_contacted": null,
|
92
|
+
"visible": true,
|
93
|
+
"twitter": null,
|
94
|
+
"facebook_url": null,
|
95
|
+
"linkedin_url": null,
|
96
|
+
"first_contacted": null,
|
97
|
+
"created_at": "2013-07-03T14:35:29Z",
|
98
|
+
"updated_at": "2013-07-03T14:35:29Z",
|
99
|
+
"hits": 0,
|
100
|
+
"team_parent_id": null,
|
101
|
+
"snoozed_at": null,
|
102
|
+
"snooze_days": null,
|
103
|
+
"groupings": [],
|
104
|
+
"email_addresses": [
|
105
|
+
"addingto@contacsafasdf.com"
|
106
|
+
],
|
107
|
+
"tags": [],
|
108
|
+
"contact_status": null,
|
109
|
+
"team_last_contacted": null,
|
110
|
+
"team_last_contacted_by": null,
|
111
|
+
"phone_numbers": [],
|
112
|
+
"addresses": [],
|
113
|
+
"social_profiles": [],
|
114
|
+
"websites": [],
|
115
|
+
"custom_fields": []
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"id": 46013214,
|
119
|
+
"user_id": 7,
|
120
|
+
"first_name": "Gray",
|
121
|
+
"last_name": "Hammer",
|
122
|
+
"full_name": "Gray Hammer",
|
123
|
+
"initials": "GH",
|
124
|
+
"title": null,
|
125
|
+
"company": null,
|
126
|
+
"email": "grayhammer@email.com",
|
127
|
+
"avatar": "",
|
128
|
+
"avatar_url": "",
|
129
|
+
"last_contacted": null,
|
130
|
+
"visible": true,
|
131
|
+
"twitter": null,
|
132
|
+
"facebook_url": null,
|
133
|
+
"linkedin_url": null,
|
134
|
+
"first_contacted": null,
|
135
|
+
"created_at": "2013-08-26T19:17:54Z",
|
136
|
+
"updated_at": "2013-08-26T19:17:54Z",
|
137
|
+
"hits": 0,
|
138
|
+
"team_parent_id": null,
|
139
|
+
"snoozed_at": null,
|
140
|
+
"snooze_days": null,
|
141
|
+
"groupings": [],
|
142
|
+
"email_addresses": [
|
143
|
+
"grayhammer@email.com"
|
144
|
+
],
|
145
|
+
"tags": [],
|
146
|
+
"contact_status": null,
|
147
|
+
"team_last_contacted": null,
|
148
|
+
"team_last_contacted_by": null,
|
149
|
+
"phone_numbers": [
|
150
|
+
{
|
151
|
+
"_id": "521ba9e2b70ec689fe00000a",
|
152
|
+
"created_at": "2013-08-26T19:17:54Z",
|
153
|
+
"deleted_at": null,
|
154
|
+
"extra_data": null,
|
155
|
+
"label": "Main",
|
156
|
+
"primary": null,
|
157
|
+
"remote_id": null,
|
158
|
+
"updated_at": "2013-08-26T19:17:54Z",
|
159
|
+
"username": null,
|
160
|
+
"value": "587-658-7687"
|
161
|
+
}
|
162
|
+
],
|
163
|
+
"addresses": [],
|
164
|
+
"social_profiles": [],
|
165
|
+
"websites": [],
|
166
|
+
"custom_fields": []
|
167
|
+
}
|
168
|
+
]
|
169
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"count": 2,
|
3
|
+
"total_count": 2,
|
4
|
+
"contents": [
|
5
|
+
{
|
6
|
+
"id": 39,
|
7
|
+
"url": null,
|
8
|
+
"title": "Lolokopter",
|
9
|
+
"description": null,
|
10
|
+
"user_id": 62,
|
11
|
+
"created_at": "2014-09-05T15:28:40Z",
|
12
|
+
"article": null,
|
13
|
+
"groupings": []
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"id": 18,
|
17
|
+
"url": null,
|
18
|
+
"title": "Lolokopter",
|
19
|
+
"description": null,
|
20
|
+
"user_id": 62,
|
21
|
+
"created_at": "2014-09-05T15:26:47Z",
|
22
|
+
"article": null,
|
23
|
+
"groupings": []
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"id": 1234123,
|
3
|
+
"type": "Grouping::Bucket",
|
4
|
+
"name": "Acquaintance",
|
5
|
+
"stub": "acquaintance",
|
6
|
+
"user_id": 421232,
|
7
|
+
"domain_id": null,
|
8
|
+
"editable": null,
|
9
|
+
"conversable": null,
|
10
|
+
"locked": false,
|
11
|
+
"derived_from_id": null,
|
12
|
+
"created_at": "2014-08-19T11:29:55Z",
|
13
|
+
"updated_at": "2014-09-03T22:14:05Z",
|
14
|
+
"has_followups": true,
|
15
|
+
"num_days_to_followup": 90,
|
16
|
+
"program_id": null,
|
17
|
+
"objective": false,
|
18
|
+
"sort_order": 0
|
19
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"count": 1,
|
3
|
+
"groupings": [
|
4
|
+
{
|
5
|
+
"id": 1234123,
|
6
|
+
"type": "Grouping::Bucket",
|
7
|
+
"name": "Acquaintance",
|
8
|
+
"stub": "acquaintance",
|
9
|
+
"user_id": 421232,
|
10
|
+
"domain_id": null,
|
11
|
+
"editable": null,
|
12
|
+
"conversable": null,
|
13
|
+
"locked": false,
|
14
|
+
"derived_from_id": null,
|
15
|
+
"created_at": "2014-08-19T11:29:55Z",
|
16
|
+
"updated_at": "2014-09-03T22:14:05Z",
|
17
|
+
"has_followups": true,
|
18
|
+
"num_days_to_followup": 90,
|
19
|
+
"program_id": null,
|
20
|
+
"objective": false,
|
21
|
+
"sort_order": 0
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
{
|
2
|
+
"messages_sent": 0,
|
3
|
+
"messages_received": 0,
|
4
|
+
"status": [],
|
5
|
+
"contacts": [
|
6
|
+
{
|
7
|
+
"id": 123123,
|
8
|
+
"sent": 0,
|
9
|
+
"received": 0,
|
10
|
+
"link": 0,
|
11
|
+
"content": [],
|
12
|
+
"user_id": 62422,
|
13
|
+
"first_name": "aazxc",
|
14
|
+
"last_name": "sszx",
|
15
|
+
"email": "123123@gmail.com",
|
16
|
+
"hits": 0,
|
17
|
+
"visible": true,
|
18
|
+
"created_at": "2014-09-04T13:20:29Z",
|
19
|
+
"updated_at": "2014-09-04T13:20:34Z",
|
20
|
+
"company": "Meine kleine Farm",
|
21
|
+
"title": null,
|
22
|
+
"last_contacted": null,
|
23
|
+
"entry_method": null,
|
24
|
+
"domain_id": null,
|
25
|
+
"account_id": null,
|
26
|
+
"real_person": null,
|
27
|
+
"ignored_at": null,
|
28
|
+
"first_contacted": null,
|
29
|
+
"last_bucketed_at": "2014-09-04T13:20:29Z",
|
30
|
+
"snoozed_at": null,
|
31
|
+
"snooze_days": null,
|
32
|
+
"user_bucket_id": null,
|
33
|
+
"is_parent": false,
|
34
|
+
"master_contact_id": null,
|
35
|
+
"avatar": null,
|
36
|
+
"responsible": 1,
|
37
|
+
"team_parent_id": null,
|
38
|
+
"team_assigned_to_id": null,
|
39
|
+
"team_last_contacted_at": null,
|
40
|
+
"team_last_contacted_by_id": null,
|
41
|
+
"team_is_parent": null,
|
42
|
+
"confidential": null
|
43
|
+
}
|
44
|
+
],
|
45
|
+
"content": []
|
46
|
+
}
|