pipedrive-adhit 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 (46) 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 +45 -0
  6. data/Rakefile +45 -0
  7. data/VERSION +1 -0
  8. data/lib/pipedrive/activity-type.rb +4 -0
  9. data/lib/pipedrive/activity.rb +4 -0
  10. data/lib/pipedrive/authorization.rb +4 -0
  11. data/lib/pipedrive/base.rb +134 -0
  12. data/lib/pipedrive/currency.rb +4 -0
  13. data/lib/pipedrive/deal-field.rb +4 -0
  14. data/lib/pipedrive/deal.rb +31 -0
  15. data/lib/pipedrive/file.rb +4 -0
  16. data/lib/pipedrive/filter.rb +4 -0
  17. data/lib/pipedrive/goal.rb +4 -0
  18. data/lib/pipedrive/note.rb +8 -0
  19. data/lib/pipedrive/organization-field.rb +4 -0
  20. data/lib/pipedrive/organization.rb +20 -0
  21. data/lib/pipedrive/permission-set.rb +4 -0
  22. data/lib/pipedrive/person-field.rb +4 -0
  23. data/lib/pipedrive/person.rb +16 -0
  24. data/lib/pipedrive/pipeline.rb +17 -0
  25. data/lib/pipedrive/product-field.rb +4 -0
  26. data/lib/pipedrive/product.rb +4 -0
  27. data/lib/pipedrive/push-notification.rb +4 -0
  28. data/lib/pipedrive/role.rb +4 -0
  29. data/lib/pipedrive/search-result.rb +28 -0
  30. data/lib/pipedrive/stage.rb +7 -0
  31. data/lib/pipedrive/user-connection.rb +4 -0
  32. data/lib/pipedrive/user-setting.rb +4 -0
  33. data/lib/pipedrive/user.rb +4 -0
  34. data/lib/pipedrive-ruby.rb +34 -0
  35. data/pipedrive-ruby.gemspec +109 -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/helper.rb +24 -0
  41. data/test/test_pipedrive_authentication.rb +21 -0
  42. data/test/test_pipedrive_deal.rb +48 -0
  43. data/test/test_pipedrive_note.rb +45 -0
  44. data/test/test_pipedrive_organization.rb +42 -0
  45. data/test/test_pipedrive_person.rb +47 -0
  46. metadata +230 -0
@@ -0,0 +1,109 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "pipedrive-adhit"
8
+ s.version = "0.3.4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jan Schwenzien", "Waldemar Kusnezow", "Joel Courtney"]
12
+ s.date = "2014-04-23"
13
+ s.description = "Ruby wrapper for the Pipedrive API"
14
+ s.email = "jan@general-scripting.com"
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/pipedrive-ruby.rb",
26
+ "lib/pipedrive/activity-type.rb",
27
+ "lib/pipedrive/activity.rb",
28
+ "lib/pipedrive/authorization.rb",
29
+ "lib/pipedrive/base.rb",
30
+ "lib/pipedrive/currency.rb",
31
+ "lib/pipedrive/deal-field.rb",
32
+ "lib/pipedrive/deal.rb",
33
+ "lib/pipedrive/file.rb",
34
+ "lib/pipedrive/filter.rb",
35
+ "lib/pipedrive/goal.rb",
36
+ "lib/pipedrive/note.rb",
37
+ "lib/pipedrive/organization-field.rb",
38
+ "lib/pipedrive/organization.rb",
39
+ "lib/pipedrive/permission-set.rb",
40
+ "lib/pipedrive/person-field.rb",
41
+ "lib/pipedrive/person.rb",
42
+ "lib/pipedrive/pipeline.rb",
43
+ "lib/pipedrive/product-field.rb",
44
+ "lib/pipedrive/product.rb",
45
+ "lib/pipedrive/push-notification.rb",
46
+ "lib/pipedrive/role.rb",
47
+ "lib/pipedrive/search-result.rb",
48
+ "lib/pipedrive/stage.rb",
49
+ "lib/pipedrive/user-connection.rb",
50
+ "lib/pipedrive/user-setting.rb",
51
+ "lib/pipedrive/user.rb",
52
+ "pipedrive-ruby.gemspec",
53
+ "test/data/create_deal_body.json",
54
+ "test/data/create_note_body.json",
55
+ "test/data/create_organization_body.json",
56
+ "test/data/create_person_body.json",
57
+ "test/helper.rb",
58
+ "test/test_pipedrive_authentication.rb",
59
+ "test/test_pipedrive_deal.rb",
60
+ "test/test_pipedrive_note.rb",
61
+ "test/test_pipedrive_organization.rb",
62
+ "test/test_pipedrive_person.rb"
63
+ ]
64
+ s.homepage = "https://github.com/GeneralScripting/pipedrive-ruby.git"
65
+ s.licenses = ["MIT"]
66
+ s.require_paths = ["lib"]
67
+ s.rubygems_version = "1.8.25"
68
+ s.summary = "Ruby wrapper for the Pipedrive API"
69
+
70
+ if s.respond_to? :specification_version then
71
+ s.specification_version = 3
72
+
73
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
74
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
75
+ s.add_runtime_dependency(%q<json>, [">= 1.7.7"])
76
+ s.add_runtime_dependency(%q<multi_xml>, [">= 0.5.2"])
77
+ s.add_runtime_dependency(%q<webmock>, [">= 0"])
78
+ s.add_runtime_dependency(%q<coveralls>, [">= 0"])
79
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
80
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
81
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
82
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
83
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
84
+ else
85
+ s.add_dependency(%q<httparty>, [">= 0"])
86
+ s.add_dependency(%q<json>, [">= 1.7.7"])
87
+ s.add_dependency(%q<multi_xml>, [">= 0.5.2"])
88
+ s.add_dependency(%q<webmock>, [">= 0"])
89
+ s.add_dependency(%q<coveralls>, [">= 0"])
90
+ s.add_dependency(%q<shoulda>, [">= 0"])
91
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
92
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
93
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
94
+ s.add_dependency(%q<simplecov>, [">= 0"])
95
+ end
96
+ else
97
+ s.add_dependency(%q<httparty>, [">= 0"])
98
+ s.add_dependency(%q<json>, [">= 1.7.7"])
99
+ s.add_dependency(%q<multi_xml>, [">= 0.5.2"])
100
+ s.add_dependency(%q<webmock>, [">= 0"])
101
+ s.add_dependency(%q<coveralls>, [">= 0"])
102
+ s.add_dependency(%q<shoulda>, [">= 0"])
103
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
104
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
105
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
106
+ s.add_dependency(%q<simplecov>, [">= 0"])
107
+ end
108
+ end
109
+
@@ -0,0 +1,40 @@
1
+ {
2
+ "success": true,
3
+ "data": {
4
+ "id": 337,
5
+ "user_id": 96701,
6
+ "person_id": null,
7
+ "org_id": 72312,
8
+ "stage_id": 30,
9
+ "title": "Dope Deal",
10
+ "value": 37,
11
+ "currency": "EUR",
12
+ "add_time": "2013-03-01 14:01:03",
13
+ "update_time": "2013-03-01 14:01:03",
14
+ "stage_change_time": "2013-03-01 14:01:03",
15
+ "active": true,
16
+ "deleted": false,
17
+ "status": "open",
18
+ "next_activity_date": null,
19
+ "next_activity_time": null,
20
+ "next_activity_id": null,
21
+ "last_activity_id": null,
22
+ "last_activity_date": null,
23
+ "lost_reason": null,
24
+ "visible_to": "0",
25
+ "close_time": null,
26
+ "pipeline_id": 1,
27
+ "won_time": null,
28
+ "lost_time": null,
29
+ "products_count": null,
30
+ "files_count": null,
31
+ "activities_count": null,
32
+ "undone_activities_count": null,
33
+ "person_name": null,
34
+ "org_name": null,
35
+ "stage_order_nr": 21,
36
+ "weighted_value": 37,
37
+ "formatted_weighted_value": "37 €",
38
+ "formatted_value": "37 €"
39
+ }
40
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "success": true,
3
+ "data": {
4
+ "id": 11,
5
+ "user_id": 131904,
6
+ "deal_id": null,
7
+ "person_id": 1,
8
+ "org_id": null,
9
+ "content": "abc",
10
+ "add_time": "2013-08-19 01:23:03",
11
+ "update_time": "",
12
+ "active_flag": true,
13
+ "organization": null,
14
+ "person": {
15
+ "name": "testando"
16
+ },
17
+ "deal": null,
18
+ "user": {
19
+ "email": "brunogh@gmail.com",
20
+ "name": "Bruno",
21
+ "icon_url": "https://pipedrive-us-usericons.s3.amazonaws.com/profile_120x120_131904.jpg",
22
+ "is_you": true
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "success": true,
3
+ "data": {
4
+ "id": 7553,
5
+ "company_id": 72312,
6
+ "owner_id": 96701,
7
+ "name": "Dope.org",
8
+ "open_deals_count": 0,
9
+ "closed_deals_count": null,
10
+ "people_count": 0,
11
+ "activities_count": null,
12
+ "undone_activities_count": null,
13
+ "files_count": null,
14
+ "active_flag": true,
15
+ "category_id": null,
16
+ "country_code": null,
17
+ "temp_old_id": null,
18
+ "first_char": "d",
19
+ "permission_group_id": null,
20
+ "update_time": null,
21
+ "add_time": "2013-03-01 13:46:06",
22
+ "visible_to": "1",
23
+ "next_activity_date": null,
24
+ "next_activity_time": null,
25
+ "next_activity_id": null,
26
+ "last_activity_id": null,
27
+ "last_activity_date": null,
28
+ "edit_name": true
29
+ }
30
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "success": true,
3
+ "data": {
4
+ "id": 3826,
5
+ "company_id": 72312,
6
+ "owner_id": null,
7
+ "org_id": 404,
8
+ "name": "John Dope",
9
+ "first_name": null,
10
+ "last_name": null,
11
+ "open_deals_count": 0,
12
+ "closed_deals_count": null,
13
+ "activities_count": null,
14
+ "undone_activities_count": null,
15
+ "files_count": null,
16
+ "active_flag": true,
17
+ "phone": [
18
+ {
19
+ "label": "",
20
+ "value": "0123456789",
21
+ "primary": true
22
+ }
23
+ ],
24
+ "email": [
25
+ {
26
+ "label": "",
27
+ "value": "john@dope.org",
28
+ "primary": true
29
+ }
30
+ ],
31
+ "first_char": "j",
32
+ "update_time": null,
33
+ "add_time": "2013-03-01 13:34:23",
34
+ "visible_to": "1",
35
+ "next_activity_date": null,
36
+ "next_activity_time": null,
37
+ "next_activity_id": null,
38
+ "last_activity_id": null,
39
+ "last_activity_date": null,
40
+ "org_name": null,
41
+ "owner_name": "Unnamed",
42
+ "im": [
43
+ {
44
+ "value": "",
45
+ "primary": true
46
+ }
47
+ ]
48
+ }
49
+ }
data/test/helper.rb ADDED
@@ -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-ruby'
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