pipedrive-api-client 0.3.4

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 (48) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/Gemfile +20 -0
  4. data/Gemfile.lock +71 -0
  5. data/README.md +44 -0
  6. data/Rakefile +45 -0
  7. data/VERSION +1 -0
  8. data/lib/pipedrive-api-client.rb +34 -0
  9. data/lib/pipedrive/activity-type.rb +4 -0
  10. data/lib/pipedrive/activity.rb +4 -0
  11. data/lib/pipedrive/authorization.rb +4 -0
  12. data/lib/pipedrive/base.rb +134 -0
  13. data/lib/pipedrive/currency.rb +4 -0
  14. data/lib/pipedrive/deal-field.rb +4 -0
  15. data/lib/pipedrive/deal.rb +31 -0
  16. data/lib/pipedrive/file.rb +4 -0
  17. data/lib/pipedrive/filter.rb +4 -0
  18. data/lib/pipedrive/goal.rb +4 -0
  19. data/lib/pipedrive/note.rb +8 -0
  20. data/lib/pipedrive/organization-field.rb +4 -0
  21. data/lib/pipedrive/organization.rb +20 -0
  22. data/lib/pipedrive/permission-set.rb +4 -0
  23. data/lib/pipedrive/person-field.rb +4 -0
  24. data/lib/pipedrive/person.rb +16 -0
  25. data/lib/pipedrive/pipeline.rb +17 -0
  26. data/lib/pipedrive/product-field.rb +4 -0
  27. data/lib/pipedrive/product.rb +4 -0
  28. data/lib/pipedrive/push-notification.rb +4 -0
  29. data/lib/pipedrive/role.rb +4 -0
  30. data/lib/pipedrive/search-result.rb +28 -0
  31. data/lib/pipedrive/stage.rb +7 -0
  32. data/lib/pipedrive/user-connection.rb +4 -0
  33. data/lib/pipedrive/user-setting.rb +4 -0
  34. data/lib/pipedrive/user.rb +4 -0
  35. data/pipedrive-api-client.gemspec +111 -0
  36. data/test/data/create_deal_body.json +40 -0
  37. data/test/data/create_note_body.json +25 -0
  38. data/test/data/create_organization_body.json +30 -0
  39. data/test/data/create_person_body.json +49 -0
  40. data/test/data/create_stages_body.json +70 -0
  41. data/test/helper.rb +24 -0
  42. data/test/test_pipedrive_authentication.rb +21 -0
  43. data/test/test_pipedrive_deal.rb +48 -0
  44. data/test/test_pipedrive_note.rb +45 -0
  45. data/test/test_pipedrive_organization.rb +42 -0
  46. data/test/test_pipedrive_person.rb +47 -0
  47. data/test/test_pipedrive_stage.rb +40 -0
  48. metadata +233 -0
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ begin
8
+ Bundler.setup(:default, :development)
9
+ rescue Bundler::BundlerError => e
10
+ $stderr.puts e.message
11
+ $stderr.puts "Run `bundle install` to install missing gems"
12
+ exit e.status_code
13
+ end
14
+ require 'test/unit'
15
+ require 'shoulda'
16
+ # require 'mocha/setup'
17
+ require 'webmock/test_unit'
18
+
19
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
20
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
21
+ require 'pipedrive-api-client'
22
+
23
+ class Test::Unit::TestCase
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'helper'
2
+
3
+ class TestPipedriveAuthentication < Test::Unit::TestCase
4
+ should "set authentication credentials on Pipedrive::Base" do
5
+ Pipedrive.authenticate("some-token")
6
+ assert_equal "some-token", Pipedrive::Base.default_options[:default_params][:api_token]
7
+ end
8
+
9
+ should "send authentication token with each request" do
10
+ Pipedrive.authenticate("some-token")
11
+
12
+ stub_request(:get, "http://api.pipedrive.com/v1/?api_token=some-token").
13
+ with(:headers => {
14
+ 'Accept'=>'application/json',
15
+ 'Content-Type'=>'application/x-www-form-urlencoded',
16
+ 'User-Agent'=>'Ruby.Pipedrive.Api'
17
+ }).
18
+ to_return(:status => 200, :body => "", :headers => {})
19
+ Pipedrive::Base.get("/")
20
+ end
21
+ end
@@ -0,0 +1,48 @@
1
+ require 'helper'
2
+
3
+ class TestPipedriveDeal < Test::Unit::TestCase
4
+ def setup
5
+ Pipedrive.authenticate("some-token")
6
+ end
7
+
8
+ should "execute a valid person request" do
9
+ body = {
10
+ "currency" => "EUR",
11
+ "org_id" => "72312",
12
+ "title" => "Dope Deal",
13
+ "value" => "37k"
14
+ }
15
+
16
+ stub_request(:post, "http://api.pipedrive.com/v1/deals?api_token=some-token").
17
+ with(:body => body,
18
+ :headers => {
19
+ 'Accept'=>'application/json',
20
+ 'Content-Type'=>'application/x-www-form-urlencoded',
21
+ 'User-Agent'=>'Ruby.Pipedrive.Api'
22
+ }).
23
+ to_return(
24
+ :status => 200,
25
+ :body => File.read(File.join(File.dirname(__FILE__), "data", "create_deal_body.json")),
26
+ :headers => {
27
+ "server" => "nginx/1.2.4",
28
+ "date" => "Fri, 01 Mar 2013 14:01:03 GMT",
29
+ "content-type" => "application/json",
30
+ "content-length" => "1260",
31
+ "connection" => "keep-alive",
32
+ "access-control-allow-origin" => "*"
33
+ }
34
+ )
35
+
36
+ deal = ::Pipedrive::Deal.create(body)
37
+
38
+ assert_equal "Dope Deal", deal.title
39
+ assert_equal 37, deal.value
40
+ assert_equal "EUR", deal.currency
41
+ assert_equal 72312, deal.org_id
42
+ end
43
+
44
+ should "return bad_response on errors" do
45
+ #TODO
46
+ # flunk "to be tested"
47
+ end
48
+ end
@@ -0,0 +1,45 @@
1
+ require 'helper'
2
+
3
+ class TestPipedriveNote < Test::Unit::TestCase
4
+ def setup
5
+ Pipedrive.authenticate("some-token")
6
+ end
7
+
8
+ should "execute a valid person request" do
9
+ body = {
10
+ "content"=>"whatever html body",
11
+ "person_id"=>"1"
12
+ # org_id
13
+ # deal_id
14
+ }
15
+
16
+ stub_request(:post, "http://api.pipedrive.com/v1/notes?api_token=some-token").
17
+ with(:body => body, :headers => {
18
+ 'Accept'=>'application/json',
19
+ 'Content-Type'=>'application/x-www-form-urlencoded',
20
+ 'User-Agent'=>'Ruby.Pipedrive.Api'
21
+ }).
22
+ to_return(
23
+ :status => 200,
24
+ :body => File.read(File.join(File.dirname(__FILE__), "data", "create_note_body.json")),
25
+ :headers => {
26
+ "server" => "nginx/1.2.4",
27
+ "date" => "Fri, 01 Mar 2013 13:34:23 GMT",
28
+ "content-type" => "application/json",
29
+ "content-length" => "1164",
30
+ "connection" => "keep-alive",
31
+ "access-control-allow-origin" => "*"
32
+ }
33
+ )
34
+
35
+ note = ::Pipedrive::Note.create(body)
36
+
37
+ assert_equal "abc", note.content
38
+ assert_equal 1, note.person_id
39
+ end
40
+
41
+ should "return bad_response on errors" do
42
+ #TODO
43
+ # flunk "to be tested"
44
+ end
45
+ end
@@ -0,0 +1,42 @@
1
+ require 'helper'
2
+
3
+ class TestPipedriveOrganization < Test::Unit::TestCase
4
+ def setup
5
+ Pipedrive.authenticate("some-token")
6
+ end
7
+
8
+ should "execute a valid person request" do
9
+ stub_request(:post, "http://api.pipedrive.com/v1/organizations?api_token=some-token").
10
+ with(:body => {
11
+ "name" => "Dope.org"
12
+ },
13
+ :headers => {
14
+ 'Accept'=>'application/json',
15
+ 'Content-Type'=>'application/x-www-form-urlencoded',
16
+ 'User-Agent'=>'Ruby.Pipedrive.Api'
17
+ }).
18
+ to_return(
19
+ :status => 200,
20
+ :body => File.read(File.join(File.dirname(__FILE__), "data", "create_organization_body.json")),
21
+ :headers => {
22
+ "server" => "nginx/1.2.4",
23
+ "date" => "Fri, 01 Mar 2013 13:46:06 GMT",
24
+ "content-type" => "application/json",
25
+ "content-length" => "3337",
26
+ "connection" => "keep-alive",
27
+ "access-control-allow-origin" => "*"
28
+ }
29
+ )
30
+
31
+ organization = ::Pipedrive::Organization.create({
32
+ name: "Dope.org"
33
+ })
34
+
35
+ assert_equal "Dope.org", organization.name
36
+ end
37
+
38
+ should "return bad_response on errors" do
39
+ # TODO
40
+ # flunk "to be tested"
41
+ end
42
+ end
@@ -0,0 +1,47 @@
1
+ require 'helper'
2
+
3
+ class TestPipedrivePerson < Test::Unit::TestCase
4
+ def setup
5
+ Pipedrive.authenticate("some-token")
6
+ end
7
+
8
+ should "execute a valid person request" do
9
+ body = {
10
+ "email"=>["john@dope.org"],
11
+ "name"=>"John Dope",
12
+ "org_id"=>"404",
13
+ "phone"=>["0123456789"]
14
+ }
15
+
16
+ stub_request(:post, "http://api.pipedrive.com/v1/persons?api_token=some-token").
17
+ with(:body => body, :headers => {
18
+ 'Accept'=>'application/json',
19
+ 'Content-Type'=>'application/x-www-form-urlencoded',
20
+ 'User-Agent'=>'Ruby.Pipedrive.Api'
21
+ }).
22
+ to_return(
23
+ :status => 200,
24
+ :body => File.read(File.join(File.dirname(__FILE__), "data", "create_person_body.json")),
25
+ :headers => {
26
+ "server" => "nginx/1.2.4",
27
+ "date" => "Fri, 01 Mar 2013 13:34:23 GMT",
28
+ "content-type" => "application/json",
29
+ "content-length" => "1164",
30
+ "connection" => "keep-alive",
31
+ "access-control-allow-origin" => "*"
32
+ }
33
+ )
34
+
35
+ person = ::Pipedrive::Person.create(body)
36
+
37
+ assert_equal "John Dope", person.name
38
+ assert_equal 404, person.org_id
39
+ assert_equal "john@dope.org", person.email.first.fetch("value")
40
+ assert_equal "0123456789", person.phone.first.fetch("value")
41
+ end
42
+
43
+ should "return bad_response on errors" do
44
+ #TODO
45
+ # flunk "to be tested"
46
+ end
47
+ end
@@ -0,0 +1,40 @@
1
+ require 'helper'
2
+
3
+ class TestPipedriveStage < Test::Unit::TestCase
4
+ def setup
5
+ Pipedrive.authenticate("some-token")
6
+ end
7
+
8
+ should "execute a valid stage request" do
9
+ body = {}
10
+ stub_request(:get, "http://api.pipedrive.com/v1/stages?api_token=some-token").
11
+ with(:body => body,
12
+ :headers => {
13
+ 'Accept'=>'application/json',
14
+ 'Content-Type'=>'application/x-www-form-urlencoded',
15
+ 'User-Agent'=>'Ruby.Pipedrive.Api'
16
+ }).
17
+ to_return(
18
+ :status => 200,
19
+ :body => File.read(File.join(File.dirname(__FILE__), "data", "create_stages_body.json")),
20
+ :headers => {
21
+ "server" => "nginx/1.2.4",
22
+ "date" => "Fri, 01 Mar 2013 14:01:03 GMT",
23
+ "content-type" => "application/json",
24
+ "content-length" => "1260",
25
+ "connection" => "keep-alive",
26
+ "access-control-allow-origin" => "*"
27
+ }
28
+ )
29
+
30
+ stages = ::Pipedrive::Stage.all
31
+ first_stage = stages.first;
32
+
33
+ assert_equal 5, stages.count
34
+
35
+ assert_equal "Idea", first_stage.name
36
+ assert_equal 1, first_stage.order_nr
37
+ assert_equal 1, first_stage.pipeline_id
38
+ assert_equal "Pipeline", first_stage.pipeline_name
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,233 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pipedrive-api-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.4
5
+ platform: ruby
6
+ authors:
7
+ - Björn Lennartsson
8
+ - Jan Schwenzien
9
+ - Waldemar Kusnezow
10
+ - Joel Courtney
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2015-10-06 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: httparty
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: 1.7.7
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.7.7
44
+ - !ruby/object:Gem::Dependency
45
+ name: multi_xml
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: 0.5.2
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: 0.5.2
58
+ - !ruby/object:Gem::Dependency
59
+ name: shoulda
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ - !ruby/object:Gem::Dependency
73
+ name: rdoc
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: '3.12'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '3.12'
86
+ - !ruby/object:Gem::Dependency
87
+ name: bundler
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: 1.0.0
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: 1.0.0
100
+ - !ruby/object:Gem::Dependency
101
+ name: jeweler
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: 1.8.4
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '>='
112
+ - !ruby/object:Gem::Version
113
+ version: 1.8.4
114
+ - !ruby/object:Gem::Dependency
115
+ name: simplecov
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ - !ruby/object:Gem::Dependency
129
+ name: webmock
130
+ requirement: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: coveralls
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ type: :development
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ description: Ruby wrapper for the Pipedrive API
157
+ email: bjorn@ratherunique.se
158
+ executables: []
159
+ extensions: []
160
+ extra_rdoc_files:
161
+ - README.md
162
+ files:
163
+ - .document
164
+ - Gemfile
165
+ - Gemfile.lock
166
+ - README.md
167
+ - Rakefile
168
+ - VERSION
169
+ - lib/pipedrive-api-client.rb
170
+ - lib/pipedrive/activity-type.rb
171
+ - lib/pipedrive/activity.rb
172
+ - lib/pipedrive/authorization.rb
173
+ - lib/pipedrive/base.rb
174
+ - lib/pipedrive/currency.rb
175
+ - lib/pipedrive/deal-field.rb
176
+ - lib/pipedrive/deal.rb
177
+ - lib/pipedrive/file.rb
178
+ - lib/pipedrive/filter.rb
179
+ - lib/pipedrive/goal.rb
180
+ - lib/pipedrive/note.rb
181
+ - lib/pipedrive/organization-field.rb
182
+ - lib/pipedrive/organization.rb
183
+ - lib/pipedrive/permission-set.rb
184
+ - lib/pipedrive/person-field.rb
185
+ - lib/pipedrive/person.rb
186
+ - lib/pipedrive/pipeline.rb
187
+ - lib/pipedrive/product-field.rb
188
+ - lib/pipedrive/product.rb
189
+ - lib/pipedrive/push-notification.rb
190
+ - lib/pipedrive/role.rb
191
+ - lib/pipedrive/search-result.rb
192
+ - lib/pipedrive/stage.rb
193
+ - lib/pipedrive/user-connection.rb
194
+ - lib/pipedrive/user-setting.rb
195
+ - lib/pipedrive/user.rb
196
+ - pipedrive-api-client.gemspec
197
+ - test/data/create_deal_body.json
198
+ - test/data/create_note_body.json
199
+ - test/data/create_organization_body.json
200
+ - test/data/create_person_body.json
201
+ - test/data/create_stages_body.json
202
+ - test/helper.rb
203
+ - test/test_pipedrive_authentication.rb
204
+ - test/test_pipedrive_deal.rb
205
+ - test/test_pipedrive_note.rb
206
+ - test/test_pipedrive_organization.rb
207
+ - test/test_pipedrive_person.rb
208
+ - test/test_pipedrive_stage.rb
209
+ homepage: https://github.com/boena/pipedrive-api-client.git
210
+ licenses:
211
+ - MIT
212
+ metadata: {}
213
+ post_install_message:
214
+ rdoc_options: []
215
+ require_paths:
216
+ - lib
217
+ required_ruby_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ required_rubygems_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - '>='
225
+ - !ruby/object:Gem::Version
226
+ version: '0'
227
+ requirements: []
228
+ rubyforge_project:
229
+ rubygems_version: 2.0.0
230
+ signing_key:
231
+ specification_version: 4
232
+ summary: Ruby wrapper for the Pipedrive API
233
+ test_files: []