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.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +62 -0
  4. data/Rakefile +7 -0
  5. data/lib/contactually-api.rb +34 -0
  6. data/lib/contactually/accounts.rb +31 -0
  7. data/lib/contactually/api.rb +70 -0
  8. data/lib/contactually/contact_groupings.rb +16 -0
  9. data/lib/contactually/contacts.rb +57 -0
  10. data/lib/contactually/contents.rb +38 -0
  11. data/lib/contactually/errors.rb +18 -0
  12. data/lib/contactually/groupings.rb +49 -0
  13. data/lib/contactually/middleware/error_detector.rb +27 -0
  14. data/lib/contactually/notes.rb +39 -0
  15. data/lib/contactually/representer/account_representer.rb +13 -0
  16. data/lib/contactually/representer/contact_representer.rb +46 -0
  17. data/lib/contactually/representer/content_representer.rb +16 -0
  18. data/lib/contactually/representer/grouping_representer.rb +28 -0
  19. data/lib/contactually/representer/grouping_statistics_representer.rb +12 -0
  20. data/lib/contactually/representer/note_representer.rb +13 -0
  21. data/lib/contactually/representer/task_representer.rb +19 -0
  22. data/lib/contactually/tasks.rb +12 -0
  23. data/lib/contactually/version.rb +3 -0
  24. data/spec/accounts_spec.rb +57 -0
  25. data/spec/api_spec.rb +87 -0
  26. data/spec/contact_groupings_spec.rb +43 -0
  27. data/spec/contacts_spec.rb +117 -0
  28. data/spec/contents_spec.rb +81 -0
  29. data/spec/fixtures/account.json +10 -0
  30. data/spec/fixtures/accounts_index.json +16 -0
  31. data/spec/fixtures/contact.json +38 -0
  32. data/spec/fixtures/contacts_index.json +169 -0
  33. data/spec/fixtures/content.json +10 -0
  34. data/spec/fixtures/contents_index.json +26 -0
  35. data/spec/fixtures/grouping.json +19 -0
  36. data/spec/fixtures/groupings_index.json +24 -0
  37. data/spec/fixtures/groupings_statistics.json +46 -0
  38. data/spec/fixtures/note.json +7 -0
  39. data/spec/fixtures/note_destroy.json +4 -0
  40. data/spec/fixtures/notes_index.json +27 -0
  41. data/spec/fixtures/task.json +27 -0
  42. data/spec/groupings_spec.rb +100 -0
  43. data/spec/notes_spec.rb +89 -0
  44. data/spec/spec_helper.rb +14 -0
  45. data/spec/tasks_spec.rb +36 -0
  46. metadata +194 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "id": 1234,
3
+ "body": "This is a note",
4
+ "contact_id": 123123,
5
+ "timestamp": "2014-09-03T09:14:52Z",
6
+ "user_id": 123
7
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": 1234123,
3
+ "deleted": true
4
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "count": 3,
3
+ "total_count": 3,
4
+ "notes": [
5
+ {
6
+ "id": 1234,
7
+ "body": "This is a note",
8
+ "contact_id": 123123,
9
+ "timestamp": "2014-09-03T09:14:52Z",
10
+ "user_id": 123
11
+ },
12
+ {
13
+ "id": 1235,
14
+ "body": "this is another note",
15
+ "contact_id": 123123,
16
+ "timestamp": "2014-09-03T09:14:52Z",
17
+ "user_id": 123
18
+ },
19
+ {
20
+ "id": 1236,
21
+ "body": "lulz",
22
+ "contact_id": 123123123,
23
+ "timestamp": "2014-09-03T09:14:26Z",
24
+ "user_id": 123
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "id": 123123,
3
+ "title": "Lolokopter",
4
+ "due_date": "2015-10-01T00:00:00Z",
5
+ "interaction_type": null,
6
+ "completed_at": null,
7
+ "deleted_at": null,
8
+ "is_follow_up": false,
9
+ "last_contacted": null,
10
+ "contact_id": 1234,
11
+ "ignored": null,
12
+ "completed_via": null,
13
+ "user_id": 12345,
14
+ "approval_data": {
15
+ "approval_type": false,
16
+ "approval_text": false,
17
+ "approval_url": false,
18
+ "approval_template": false,
19
+ "approval_account_id": false
20
+ },
21
+ "contact_program_step_id": null,
22
+ "unresponded_followup_id": null,
23
+ "user_bucket": {
24
+ "id": 12312,
25
+ "name": "Colleague"
26
+ }
27
+ }
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+
3
+ describe Contactually::Groupings 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
+
12
+ describe '#initialize' do
13
+ specify do
14
+ expect(subject).to be_kind_of Contactually::Groupings
15
+ end
16
+
17
+ specify do
18
+ expect(subject.instance_variable_get(:@master)).to be_kind_of Contactually::API
19
+ end
20
+ end
21
+
22
+ describe '#index' do
23
+ it 'calls the api with correct params' do
24
+ allow(@master).to receive(:call).with('groupings.json', :get, { foo: :bar }).and_return({ 'groupings' => [] })
25
+ subject.index({ foo: :bar })
26
+ expect(@master).to have_received(:call)
27
+ end
28
+
29
+ it 'returns groupings from json response' do
30
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/groupings_index.json"))
31
+ allow(@master).to receive(:call).with('groupings.json', :get, {}).and_return(JSON.load(json))
32
+ expect(subject.index({})).to be_kind_of Array
33
+ expect(subject.index({})[0]).to be_kind_of Contactually::Grouping
34
+ end
35
+ end
36
+
37
+ describe '#create' do
38
+ it 'calls the api with correct params' do
39
+ allow(@master).to receive(:call).with('groupings.json', :post, { grouping: { foo: :bar }}).and_return({ 'id' => 1234 })
40
+ subject.create({ grouping: { foo: :bar }})
41
+ expect(@master).to have_received(:call)
42
+ end
43
+
44
+ it 'returns groupings from json response' do
45
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/grouping.json"))
46
+ allow(@master).to receive(:call).with('groupings.json', :post, { grouping: { foo: :bar }}).and_return(JSON.load(json))
47
+ expect(subject.create({ grouping: { foo: :bar }})).to be_kind_of Contactually::Grouping
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('groupings/1.json', :delete, {})
54
+ subject.destroy(1)
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('groupings/1.json', :get, { foo: :bar }).and_return({ id: 1234 })
62
+ subject.show(1, { foo: :bar })
63
+ expect(@master).to have_received(:call)
64
+ end
65
+
66
+ it 'returns a grouping from json response' do
67
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/grouping.json"))
68
+ allow(@master).to receive(:call).with('groupings/1.json', :get, { foo: :bar }).and_return(JSON.load(json))
69
+ expect(subject.show(1, { foo: :bar })).to be_kind_of Contactually::Grouping
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('groupings/1.json', :put, { grouping: { foo: :bar }}).and_return({ id: 1234 })
76
+ subject.update(1, { grouping: { foo: :bar }})
77
+ expect(@master).to have_received(:call)
78
+ end
79
+
80
+ it 'returns a grouping from json response' do
81
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/grouping.json"))
82
+ allow(@master).to receive(:call).with('groupings/1.json', :put, { grouping: { foo: :bar }}).and_return(JSON.load(json))
83
+ expect(subject.update(1, { grouping: { foo: :bar }})).to be_kind_of Contactually::Grouping
84
+ end
85
+ end
86
+
87
+ describe '#statistics' do
88
+ it 'calls the api with correct params' do
89
+ allow(@master).to receive(:call).with('groupings/1/statistics.json', :get, { foo: :bar }).and_return({ 'messages_sent' => 10 })
90
+ subject.statistics(1, { foo: :bar })
91
+ expect(@master).to have_received(:call)
92
+ end
93
+
94
+ it 'returns statistics object' do
95
+ json = File.read(File.join(File.dirname(__FILE__), "fixtures/groupings_statistics.json"))
96
+ allow(@master).to receive(:call).with('groupings/1/statistics.json', :get, { foo: :bar }).and_return(JSON.load(json))
97
+ expect(subject.statistics(1, { foo: :bar })).to be_kind_of Contactually::GroupingStatistics
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe Contactually::Notes 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
+
12
+ describe '#initialize' do
13
+ specify do
14
+ expect(subject).to be_kind_of Contactually::Notes
15
+ end
16
+
17
+ specify do
18
+ expect(subject.instance_variable_get(:@master)).to be_kind_of Contactually::API
19
+ end
20
+ end
21
+
22
+ describe '#index' do
23
+ it 'calls the api with correct params' do
24
+ allow(@master).to receive(:call).with('notes.json', :get, { foo: :bar }).and_return({ 'notes' => [] })
25
+ subject.index({ foo: :bar })
26
+ expect(@master).to have_received(:call)
27
+ end
28
+
29
+ it 'returns notes from json response' do
30
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/notes_index.json"))
31
+ allow(@master).to receive(:call).with('notes.json', :get, {}).and_return(JSON.load(json))
32
+ expect(subject.index({})).to be_kind_of Array
33
+ expect(subject.index({})[0]).to be_kind_of Contactually::Note
34
+ end
35
+ end
36
+
37
+ describe '#show' do
38
+ it 'calls the api with correct params' do
39
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/note.json"))
40
+ allow(@master).to receive(:call).with('notes/1.json', :get, { foo: :bar }).and_return(JSON.load(json))
41
+ subject.show(1, { foo: :bar })
42
+ expect(@master).to have_received(:call)
43
+ end
44
+
45
+ it 'returns a note' do
46
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/note.json"))
47
+ allow(@master).to receive(:call).with('notes/1.json', :get, { foo: :bar }).and_return(JSON.load(json))
48
+ expect(subject.show(1, { foo: :bar })).to be_kind_of Contactually::Note
49
+ end
50
+ end
51
+
52
+ describe '#create' do
53
+ it 'calls the api with correct params' do
54
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/note.json"))
55
+ allow(@master).to receive(:call).with('notes.json', :post, { note: { foo: :bar }}).and_return(JSON.load(json))
56
+ subject.create({ note: { foo: :bar }})
57
+ expect(@master).to have_received(:call)
58
+ end
59
+
60
+ it 'returns a note' do
61
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/note.json"))
62
+ allow(@master).to receive(:call).with('notes.json', :post, { note: { foo: :bar }}).and_return(JSON.load(json))
63
+ expect(subject.create({ note: { foo: :bar }})).to be_kind_of Contactually::Note
64
+ end
65
+ end
66
+
67
+ describe '#update' do
68
+ it 'calls the api with correct params' do
69
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/note.json"))
70
+ allow(@master).to receive(:call).with('notes/1.json', :put, { note: { foo: :bar }}).and_return(JSON.load(json))
71
+ subject.update(1, { note: { foo: :bar }})
72
+ expect(@master).to have_received(:call)
73
+ end
74
+
75
+ it 'returns a note' do
76
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/note.json"))
77
+ allow(@master).to receive(:call).with('notes/1.json', :put, { note: { foo: :bar }}).and_return(JSON.load(json))
78
+ expect(subject.update(1, { note: { foo: :bar }})).to be_kind_of Contactually::Note
79
+ end
80
+ end
81
+
82
+ describe '#destroy' do
83
+ it 'calls the api with correct params' do
84
+ allow(@master).to receive(:call).with('notes/1.json', :delete, { foo: :bar })
85
+ subject.destroy(1, { foo: :bar })
86
+ expect(@master).to have_received(:call)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'rspec'
5
+ require 'pry-byebug'
6
+ require 'contactually-api'
7
+
8
+ # Requires supporting files with custom matchers and macros, etc,
9
+ # in ./support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+
12
+ RSpec.configure do |config|
13
+ config.color = true
14
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Contactually::Tasks 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::Tasks
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 '#show' do
22
+ it 'calls the api with correct params' do
23
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/task.json"))
24
+ allow(@master).to receive(:call).with('tasks/1.json', :get, { foo: :bar }).and_return(JSON.load(json))
25
+ subject.show(1, { foo: :bar })
26
+ expect(@master).to have_received(:call)
27
+ end
28
+
29
+ it 'returns a task' do
30
+ json = File.read(File.join(File.dirname(__FILE__),"fixtures/task.json"))
31
+ allow(@master).to receive(:call).with('tasks/1.json', :get, { foo: :bar }).and_return(JSON.load(json))
32
+ expect(subject.show(1, { foo: :bar })).to be_kind_of Contactually::Task
33
+ end
34
+ end
35
+
36
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: contactually-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Johannes Heck
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: roar
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.12.9
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.12.9
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: This is a simple wrapper for the contactually api. Try it!
98
+ email:
99
+ - johannes@railslove.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - lib/contactually-api.rb
108
+ - lib/contactually/accounts.rb
109
+ - lib/contactually/api.rb
110
+ - lib/contactually/contact_groupings.rb
111
+ - lib/contactually/contacts.rb
112
+ - lib/contactually/contents.rb
113
+ - lib/contactually/errors.rb
114
+ - lib/contactually/groupings.rb
115
+ - lib/contactually/middleware/error_detector.rb
116
+ - lib/contactually/notes.rb
117
+ - lib/contactually/representer/account_representer.rb
118
+ - lib/contactually/representer/contact_representer.rb
119
+ - lib/contactually/representer/content_representer.rb
120
+ - lib/contactually/representer/grouping_representer.rb
121
+ - lib/contactually/representer/grouping_statistics_representer.rb
122
+ - lib/contactually/representer/note_representer.rb
123
+ - lib/contactually/representer/task_representer.rb
124
+ - lib/contactually/tasks.rb
125
+ - lib/contactually/version.rb
126
+ - spec/accounts_spec.rb
127
+ - spec/api_spec.rb
128
+ - spec/contact_groupings_spec.rb
129
+ - spec/contacts_spec.rb
130
+ - spec/contents_spec.rb
131
+ - spec/fixtures/account.json
132
+ - spec/fixtures/accounts_index.json
133
+ - spec/fixtures/contact.json
134
+ - spec/fixtures/contacts_index.json
135
+ - spec/fixtures/content.json
136
+ - spec/fixtures/contents_index.json
137
+ - spec/fixtures/grouping.json
138
+ - spec/fixtures/groupings_index.json
139
+ - spec/fixtures/groupings_statistics.json
140
+ - spec/fixtures/note.json
141
+ - spec/fixtures/note_destroy.json
142
+ - spec/fixtures/notes_index.json
143
+ - spec/fixtures/task.json
144
+ - spec/groupings_spec.rb
145
+ - spec/notes_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/tasks_spec.rb
148
+ homepage: https://github.com/railslove/contactually-api
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.2.2
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: A wrapper for the contactually.com api
172
+ test_files:
173
+ - spec/accounts_spec.rb
174
+ - spec/api_spec.rb
175
+ - spec/contact_groupings_spec.rb
176
+ - spec/contacts_spec.rb
177
+ - spec/contents_spec.rb
178
+ - spec/fixtures/account.json
179
+ - spec/fixtures/accounts_index.json
180
+ - spec/fixtures/contact.json
181
+ - spec/fixtures/contacts_index.json
182
+ - spec/fixtures/content.json
183
+ - spec/fixtures/contents_index.json
184
+ - spec/fixtures/grouping.json
185
+ - spec/fixtures/groupings_index.json
186
+ - spec/fixtures/groupings_statistics.json
187
+ - spec/fixtures/note.json
188
+ - spec/fixtures/note_destroy.json
189
+ - spec/fixtures/notes_index.json
190
+ - spec/fixtures/task.json
191
+ - spec/groupings_spec.rb
192
+ - spec/notes_spec.rb
193
+ - spec/spec_helper.rb
194
+ - spec/tasks_spec.rb