contactually-ruby 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +7 -0
- data/lib/contactually-ruby.rb +38 -0
- data/lib/contactually/accounts.rb +22 -0
- data/lib/contactually/api.rb +87 -0
- data/lib/contactually/buckets.rb +49 -0
- data/lib/contactually/contact_groupings.rb +16 -0
- data/lib/contactually/contacts.rb +54 -0
- data/lib/contactually/contents.rb +30 -0
- data/lib/contactually/errors.rb +21 -0
- data/lib/contactually/groupings.rb +36 -0
- data/lib/contactually/middleware/error_detector.rb +31 -0
- data/lib/contactually/notes.rb +31 -0
- data/lib/contactually/representer/account_representer.rb +15 -0
- data/lib/contactually/representer/bucket_representer.rb +16 -0
- data/lib/contactually/representer/contact_representer.rb +48 -0
- data/lib/contactually/representer/content_representer.rb +18 -0
- data/lib/contactually/representer/grouping_representer.rb +30 -0
- data/lib/contactually/representer/grouping_statistic_representer.rb +14 -0
- data/lib/contactually/representer/note_representer.rb +15 -0
- data/lib/contactually/representer/task_representer.rb +21 -0
- data/lib/contactually/tasks.rb +49 -0
- data/lib/contactually/utils.rb +44 -0
- data/lib/contactually/version.rb +3 -0
- data/spec/accounts_spec.rb +58 -0
- data/spec/api_spec.rb +125 -0
- data/spec/buckets_spec.rb +97 -0
- data/spec/contact_groupings_spec.rb +44 -0
- data/spec/contacts_spec.rb +133 -0
- data/spec/contents_spec.rb +80 -0
- data/spec/error_detector_spec.rb +24 -0
- data/spec/fixtures/account.json +10 -0
- data/spec/fixtures/accounts_index.json +19 -0
- data/spec/fixtures/bucket.json +8 -0
- data/spec/fixtures/buckets_index.json +41 -0
- data/spec/fixtures/contact.json +38 -0
- data/spec/fixtures/contacts_index.json +172 -0
- data/spec/fixtures/content.json +10 -0
- data/spec/fixtures/contents_index.json +29 -0
- data/spec/fixtures/grouping.json +19 -0
- data/spec/fixtures/groupings_index.json +28 -0
- data/spec/fixtures/note.json +7 -0
- data/spec/fixtures/note_destroy.json +4 -0
- data/spec/fixtures/notes_index.json +30 -0
- data/spec/fixtures/task.json +27 -0
- data/spec/fixtures/tasks_index.json +41 -0
- data/spec/groupings_spec.rb +85 -0
- data/spec/notes_spec.rb +85 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/tasks_spec.rb +127 -0
- metadata +205 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Contactually::Middleware::ErrorDetector do
|
4
|
+
|
5
|
+
describe '#cast_error' do
|
6
|
+
|
7
|
+
it 'detects invalid parameter errors' do
|
8
|
+
body = { error: 'Invalid parameters' }.to_json
|
9
|
+
expect{ subject.send(:cast_error, body) }.to raise_error Contactually::InvalidParametersError
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'detects duplication errors' do
|
13
|
+
body = { error: 'We already have' }.to_json
|
14
|
+
expect{ subject.send(:cast_error, body) }.to raise_error Contactually::DuplicatedContactError
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'rescues json parse errors' do
|
18
|
+
body = ";foobar;"
|
19
|
+
expect{ subject.send(:cast_error, body) }.to raise_error Contactually::APIError
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"meta": {
|
3
|
+
"total": 1,
|
4
|
+
"next_page": null,
|
5
|
+
"previous_page": null
|
6
|
+
},
|
7
|
+
"data": [
|
8
|
+
{
|
9
|
+
"id": 13123,
|
10
|
+
"username": "lol@rofl.com",
|
11
|
+
"remote_id": "lol@rofl.com",
|
12
|
+
"type": "Account::Google",
|
13
|
+
"disabled_at": null,
|
14
|
+
"name": "Google Contacts",
|
15
|
+
"nice_label": "lol@rofl.com",
|
16
|
+
"can_sync_contacts": true
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"data": [
|
3
|
+
{
|
4
|
+
"id": 41296011,
|
5
|
+
"name": "Bucket Test 1",
|
6
|
+
"goal": "Test 1",
|
7
|
+
"reminder_interval": 11,
|
8
|
+
"created_at": "2013-07-02T15:45:01Z",
|
9
|
+
"updated_at": "2013-07-02T15:45:01Z"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"id": 41296012,
|
13
|
+
"name": "Bucket Test 2",
|
14
|
+
"goal": "Test 2",
|
15
|
+
"reminder_interval": 22,
|
16
|
+
"created_at": "2013-07-02T15:45:01Z",
|
17
|
+
"updated_at": "2013-07-02T15:45:01Z"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"id": 41296013,
|
21
|
+
"name": "Bucket Test 3",
|
22
|
+
"goal": "Test 3",
|
23
|
+
"reminder_interval": 33,
|
24
|
+
"created_at": "2013-07-02T15:45:01Z",
|
25
|
+
"updated_at": "2013-07-02T15:45:01Z"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"id": 41296014,
|
29
|
+
"name": "Bucket Test 4",
|
30
|
+
"goal": "Test 4",
|
31
|
+
"reminder_interval": 44,
|
32
|
+
"created_at": "2013-07-02T15:45:01Z",
|
33
|
+
"updated_at": "2013-07-02T15:45:01Z"
|
34
|
+
}
|
35
|
+
],
|
36
|
+
"meta": {
|
37
|
+
"total": 4,
|
38
|
+
"next_page": null,
|
39
|
+
"previous_page": null
|
40
|
+
}
|
41
|
+
}
|
@@ -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,172 @@
|
|
1
|
+
{
|
2
|
+
"meta": {
|
3
|
+
"total": 4,
|
4
|
+
"next_page": null,
|
5
|
+
"previous_page": null
|
6
|
+
},
|
7
|
+
"data": [
|
8
|
+
{
|
9
|
+
"id": 41296013,
|
10
|
+
"user_id": 7,
|
11
|
+
"first_name": "Test",
|
12
|
+
"last_name": "Ing",
|
13
|
+
"full_name": "Test Ing",
|
14
|
+
"initials": "TI",
|
15
|
+
"title": "",
|
16
|
+
"company": null,
|
17
|
+
"email": "testing@contact.com",
|
18
|
+
"avatar": "",
|
19
|
+
"avatar_url": "",
|
20
|
+
"last_contacted": null,
|
21
|
+
"visible": true,
|
22
|
+
"twitter": null,
|
23
|
+
"facebook_url": null,
|
24
|
+
"linkedin_url": null,
|
25
|
+
"first_contacted": null,
|
26
|
+
"created_at": "2013-07-02T15:45:01Z",
|
27
|
+
"updated_at": "2013-07-02T15:45:01Z",
|
28
|
+
"hits": 0,
|
29
|
+
"team_parent_id": null,
|
30
|
+
"snoozed_at": null,
|
31
|
+
"snooze_days": null,
|
32
|
+
"groupings": [],
|
33
|
+
"email_addresses": [
|
34
|
+
"testing@contact.com"
|
35
|
+
],
|
36
|
+
"tags": [],
|
37
|
+
"contact_status": null,
|
38
|
+
"team_last_contacted": null,
|
39
|
+
"team_last_contacted_by": null,
|
40
|
+
"phone_numbers": [],
|
41
|
+
"addresses": [],
|
42
|
+
"social_profiles": [],
|
43
|
+
"websites": [],
|
44
|
+
"custom_fields": []
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"id": 41314854,
|
48
|
+
"user_id": 7,
|
49
|
+
"first_name": "Whats",
|
50
|
+
"last_name": "Uppp",
|
51
|
+
"full_name": "Whats Uppp",
|
52
|
+
"initials": "WU",
|
53
|
+
"title": null,
|
54
|
+
"company": null,
|
55
|
+
"email": null,
|
56
|
+
"avatar": "",
|
57
|
+
"avatar_url": "",
|
58
|
+
"last_contacted": null,
|
59
|
+
"visible": true,
|
60
|
+
"twitter": null,
|
61
|
+
"facebook_url": null,
|
62
|
+
"linkedin_url": null,
|
63
|
+
"first_contacted": null,
|
64
|
+
"created_at": "2013-07-02T18:56:37Z",
|
65
|
+
"updated_at": "2013-07-02T18:56:37Z",
|
66
|
+
"hits": 0,
|
67
|
+
"team_parent_id": null,
|
68
|
+
"snoozed_at": null,
|
69
|
+
"snooze_days": null,
|
70
|
+
"groupings": [],
|
71
|
+
"email_addresses": [],
|
72
|
+
"tags": [],
|
73
|
+
"contact_status": null,
|
74
|
+
"team_last_contacted": null,
|
75
|
+
"team_last_contacted_by": null,
|
76
|
+
"phone_numbers": [],
|
77
|
+
"addresses": [],
|
78
|
+
"social_profiles": [],
|
79
|
+
"websites": [],
|
80
|
+
"custom_fields": []
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"id": 41438693,
|
84
|
+
"user_id": 7,
|
85
|
+
"first_name": "Adding",
|
86
|
+
"last_name": "Contactually",
|
87
|
+
"full_name": "Adding Contactually",
|
88
|
+
"initials": "AC",
|
89
|
+
"title": null,
|
90
|
+
"company": null,
|
91
|
+
"email": "addingto@contacsafasdf.com",
|
92
|
+
"avatar": "",
|
93
|
+
"avatar_url": "",
|
94
|
+
"last_contacted": null,
|
95
|
+
"visible": true,
|
96
|
+
"twitter": null,
|
97
|
+
"facebook_url": null,
|
98
|
+
"linkedin_url": null,
|
99
|
+
"first_contacted": null,
|
100
|
+
"created_at": "2013-07-03T14:35:29Z",
|
101
|
+
"updated_at": "2013-07-03T14:35:29Z",
|
102
|
+
"hits": 0,
|
103
|
+
"team_parent_id": null,
|
104
|
+
"snoozed_at": null,
|
105
|
+
"snooze_days": null,
|
106
|
+
"groupings": [],
|
107
|
+
"email_addresses": [
|
108
|
+
"addingto@contacsafasdf.com"
|
109
|
+
],
|
110
|
+
"tags": [],
|
111
|
+
"contact_status": null,
|
112
|
+
"team_last_contacted": null,
|
113
|
+
"team_last_contacted_by": null,
|
114
|
+
"phone_numbers": [],
|
115
|
+
"addresses": [],
|
116
|
+
"social_profiles": [],
|
117
|
+
"websites": [],
|
118
|
+
"custom_fields": []
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"id": 46013214,
|
122
|
+
"user_id": 7,
|
123
|
+
"first_name": "Gray",
|
124
|
+
"last_name": "Hammer",
|
125
|
+
"full_name": "Gray Hammer",
|
126
|
+
"initials": "GH",
|
127
|
+
"title": null,
|
128
|
+
"company": null,
|
129
|
+
"email": "grayhammer@email.com",
|
130
|
+
"avatar": "",
|
131
|
+
"avatar_url": "",
|
132
|
+
"last_contacted": null,
|
133
|
+
"visible": true,
|
134
|
+
"twitter": null,
|
135
|
+
"facebook_url": null,
|
136
|
+
"linkedin_url": null,
|
137
|
+
"first_contacted": null,
|
138
|
+
"created_at": "2013-08-26T19:17:54Z",
|
139
|
+
"updated_at": "2013-08-26T19:17:54Z",
|
140
|
+
"hits": 0,
|
141
|
+
"team_parent_id": null,
|
142
|
+
"snoozed_at": null,
|
143
|
+
"snooze_days": null,
|
144
|
+
"groupings": [],
|
145
|
+
"email_addresses": [
|
146
|
+
"grayhammer@email.com"
|
147
|
+
],
|
148
|
+
"tags": [],
|
149
|
+
"contact_status": null,
|
150
|
+
"team_last_contacted": null,
|
151
|
+
"team_last_contacted_by": null,
|
152
|
+
"phone_numbers": [
|
153
|
+
{
|
154
|
+
"_id": "521ba9e2b70ec689fe00000a",
|
155
|
+
"created_at": "2013-08-26T19:17:54Z",
|
156
|
+
"deleted_at": null,
|
157
|
+
"extra_data": null,
|
158
|
+
"label": "Main",
|
159
|
+
"primary": null,
|
160
|
+
"remote_id": null,
|
161
|
+
"updated_at": "2013-08-26T19:17:54Z",
|
162
|
+
"username": null,
|
163
|
+
"value": "587-658-7687"
|
164
|
+
}
|
165
|
+
],
|
166
|
+
"addresses": [],
|
167
|
+
"social_profiles": [],
|
168
|
+
"websites": [],
|
169
|
+
"custom_fields": []
|
170
|
+
}
|
171
|
+
]
|
172
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"meta": {
|
3
|
+
"total": 2,
|
4
|
+
"next_page": null,
|
5
|
+
"previous_page": null
|
6
|
+
},
|
7
|
+
"data": [
|
8
|
+
{
|
9
|
+
"id": 39,
|
10
|
+
"url": null,
|
11
|
+
"title": "Lolokopter",
|
12
|
+
"description": null,
|
13
|
+
"user_id": 62,
|
14
|
+
"created_at": "2014-09-05T15:28:40Z",
|
15
|
+
"article": null,
|
16
|
+
"groupings": []
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"id": 18,
|
20
|
+
"url": null,
|
21
|
+
"title": "Lolokopter",
|
22
|
+
"description": null,
|
23
|
+
"user_id": 62,
|
24
|
+
"created_at": "2014-09-05T15:26:47Z",
|
25
|
+
"article": null,
|
26
|
+
"groupings": []
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
@@ -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,28 @@
|
|
1
|
+
{
|
2
|
+
"meta": {
|
3
|
+
"total": 1,
|
4
|
+
"next_page": null,
|
5
|
+
"previous_page": null
|
6
|
+
},
|
7
|
+
"data": [
|
8
|
+
{
|
9
|
+
"id": 1234123,
|
10
|
+
"type": "Grouping::Bucket",
|
11
|
+
"name": "Acquaintance",
|
12
|
+
"stub": "acquaintance",
|
13
|
+
"user_id": 421232,
|
14
|
+
"domain_id": null,
|
15
|
+
"editable": null,
|
16
|
+
"conversable": null,
|
17
|
+
"locked": false,
|
18
|
+
"derived_from_id": null,
|
19
|
+
"created_at": "2014-08-19T11:29:55Z",
|
20
|
+
"updated_at": "2014-09-03T22:14:05Z",
|
21
|
+
"has_followups": true,
|
22
|
+
"num_days_to_followup": 90,
|
23
|
+
"program_id": null,
|
24
|
+
"objective": false,
|
25
|
+
"sort_order": 0
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"meta": {
|
3
|
+
"total": 3,
|
4
|
+
"next_page": null,
|
5
|
+
"previous_page": null
|
6
|
+
},
|
7
|
+
"data": [
|
8
|
+
{
|
9
|
+
"id": 1234,
|
10
|
+
"body": "This is a note",
|
11
|
+
"contact_id": 123123,
|
12
|
+
"timestamp": "2014-09-03T09:14:52Z",
|
13
|
+
"user_id": 123
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"id": 1235,
|
17
|
+
"body": "this is another note",
|
18
|
+
"contact_id": 123123,
|
19
|
+
"timestamp": "2014-09-03T09:14:52Z",
|
20
|
+
"user_id": 123
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"id": 1236,
|
24
|
+
"body": "lulz",
|
25
|
+
"contact_id": 123123123,
|
26
|
+
"timestamp": "2014-09-03T09:14:26Z",
|
27
|
+
"user_id": 123
|
28
|
+
}
|
29
|
+
]
|
30
|
+
}
|