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,4 @@
1
+ module Pipedrive
2
+ class Goal < Base
3
+ end
4
+ end
@@ -0,0 +1,8 @@
1
+ module Pipedrive
2
+ class Note < Base
3
+
4
+ class << self
5
+
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class OrganizationField < Base
3
+ end
4
+ end
@@ -0,0 +1,20 @@
1
+ module Pipedrive
2
+ class Organization < Base
3
+
4
+ def persons
5
+ Person.all(get "#{resource_path}/#{id}/persons")
6
+ end
7
+
8
+ def deals
9
+ Deal.all(get "#{resource_path}/#{id}/deals")
10
+ end
11
+
12
+ class << self
13
+
14
+ def find_or_create_by_name(name, opts={})
15
+ find_by_name(name).first || create(opts.merge(:name => name))
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class PermissionSet < Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class PersonField < Base
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ module Pipedrive
2
+ class Person < Base
3
+
4
+ class << self
5
+
6
+ def find_or_create_by_name(name, opts={})
7
+ find_by_name(name, :org_id => opts[:org_id]).first || create(opts.merge(:name => name))
8
+ end
9
+
10
+ end
11
+
12
+ def deals()
13
+ Deal.all(get "#{resource_path}/#{id}/deals", :everyone => 1)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module Pipedrive
2
+ class Pipeline < Base
3
+ def stages
4
+ Stage.all(get "/stages", { :pipeline_id => self.id })
5
+ end
6
+
7
+ def statistics(id, start_date, end_date)
8
+ res = get("#{resource_path}/#{id}/movement_statistics",
9
+ :query => {:start_date => start_date, :end_date => end_date})
10
+ res.ok? ? new(res) : bad_response(res,{:id=>id,:start_date=>start_date,:end_date=>end_date})
11
+ end
12
+
13
+ def deals(id, stage_id)
14
+ Pipedrive::Deal.all(get "#{resource_path}/#{id}/deals", :stage_id => stage_id )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class ProductField < Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class Product < Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class PushNotification < Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class Role < Base
3
+ end
4
+ end
@@ -0,0 +1,28 @@
1
+ module Pipedrive
2
+ class SearchResult < Base
3
+
4
+ # Class Methods
5
+ class << self
6
+
7
+ def search(term, start=0, limit=nil)
8
+ res = get(resource_path, :query => { :term => term, :start => start, :limit => limit})
9
+ if res.ok?
10
+ res['data'].nil? ? [] : res['data'].map{|obj| new(obj)}
11
+ else
12
+ bad_response(res,{:term=>term,:start=>start,:limit=>limit})
13
+ end
14
+ end
15
+
16
+ def field(term, field_type, field_key, opts={})
17
+ res = get("#{resource_path}/field", :query => opts.merge(:term => term, :field_type => field_type, :field_key => field_key) )
18
+ if res.ok?
19
+ res['data'].nil? ? [] : res['data'].map{|obj| new(obj)}
20
+ else
21
+ bad_response(res,{:term=>term,:field_type=>field_type,:field_key=>field_key}.merge(opts))
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ module Pipedrive
2
+ class Stage < Base
3
+ def self.deals(id)
4
+ Deal.all(get "#{resource_path}/#{id}/deals", :query => {:everyone => 1})
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class UserConnection < Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class UserSetting < Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class User < Base
3
+ end
4
+ end
@@ -0,0 +1,111 @@
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-api-client"
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 = ["Bj\u{f6}rn Lennartsson", "Jan Schwenzien", "Waldemar Kusnezow", "Joel Courtney"]
12
+ s.date = "2015-10-06"
13
+ s.description = "Ruby wrapper for the Pipedrive API"
14
+ s.email = "bjorn@ratherunique.se"
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-api-client.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-api-client.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/data/create_stages_body.json",
58
+ "test/helper.rb",
59
+ "test/test_pipedrive_authentication.rb",
60
+ "test/test_pipedrive_deal.rb",
61
+ "test/test_pipedrive_note.rb",
62
+ "test/test_pipedrive_organization.rb",
63
+ "test/test_pipedrive_person.rb",
64
+ "test/test_pipedrive_stage.rb"
65
+ ]
66
+ s.homepage = "https://github.com/boena/pipedrive-api-client.git"
67
+ s.licenses = ["MIT"]
68
+ s.require_paths = ["lib"]
69
+ s.rubygems_version = "2.0.0"
70
+ s.summary = "Ruby wrapper for the Pipedrive API"
71
+
72
+ if s.respond_to? :specification_version then
73
+ s.specification_version = 4
74
+
75
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
76
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
77
+ s.add_runtime_dependency(%q<json>, [">= 1.7.7"])
78
+ s.add_runtime_dependency(%q<multi_xml>, [">= 0.5.2"])
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
+ s.add_development_dependency(%q<webmock>, [">= 0"])
85
+ s.add_development_dependency(%q<coveralls>, [">= 0"])
86
+ else
87
+ s.add_dependency(%q<httparty>, [">= 0"])
88
+ s.add_dependency(%q<json>, [">= 1.7.7"])
89
+ s.add_dependency(%q<multi_xml>, [">= 0.5.2"])
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
+ s.add_dependency(%q<webmock>, [">= 0"])
96
+ s.add_dependency(%q<coveralls>, [">= 0"])
97
+ end
98
+ else
99
+ s.add_dependency(%q<httparty>, [">= 0"])
100
+ s.add_dependency(%q<json>, [">= 1.7.7"])
101
+ s.add_dependency(%q<multi_xml>, [">= 0.5.2"])
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
+ s.add_dependency(%q<webmock>, [">= 0"])
108
+ s.add_dependency(%q<coveralls>, [">= 0"])
109
+ end
110
+ end
111
+
@@ -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
+ }
@@ -0,0 +1,70 @@
1
+ {
2
+ "success": true,
3
+ "data": [
4
+ {
5
+ "id": 1,
6
+ "order_nr": 1,
7
+ "name": "Idea",
8
+ "active_flag": true,
9
+ "deal_probability": 100,
10
+ "pipeline_id": 1,
11
+ "rotten_flag": false,
12
+ "rotten_days": null,
13
+ "add_time": "2015-01-06 12:08:01",
14
+ "update_time": null,
15
+ "pipeline_name": "Pipeline"
16
+ },
17
+ {
18
+ "id": 2,
19
+ "order_nr": 2,
20
+ "name": "Contact Made",
21
+ "active_flag": true,
22
+ "deal_probability": 100,
23
+ "pipeline_id": 1,
24
+ "rotten_flag": false,
25
+ "rotten_days": null,
26
+ "add_time": "2015-01-06 12:08:01",
27
+ "update_time": null,
28
+ "pipeline_name": "Pipeline"
29
+ },
30
+ {
31
+ "id": 3,
32
+ "order_nr": 3,
33
+ "name": "Needs Discovered",
34
+ "active_flag": true,
35
+ "deal_probability": 100,
36
+ "pipeline_id": 1,
37
+ "rotten_flag": false,
38
+ "rotten_days": null,
39
+ "add_time": "2015-01-06 12:08:01",
40
+ "update_time": null,
41
+ "pipeline_name": "Pipeline"
42
+ },
43
+ {
44
+ "id": 4,
45
+ "order_nr": 4,
46
+ "name": "Proposal Presented",
47
+ "active_flag": true,
48
+ "deal_probability": 100,
49
+ "pipeline_id": 1,
50
+ "rotten_flag": false,
51
+ "rotten_days": null,
52
+ "add_time": "2015-01-06 12:08:01",
53
+ "update_time": null,
54
+ "pipeline_name": "Pipeline"
55
+ },
56
+ {
57
+ "id": 5,
58
+ "order_nr": 5,
59
+ "name": "In Negotiation",
60
+ "active_flag": true,
61
+ "deal_probability": 100,
62
+ "pipeline_id": 1,
63
+ "rotten_flag": false,
64
+ "rotten_days": null,
65
+ "add_time": "2015-01-06 12:08:01",
66
+ "update_time": null,
67
+ "pipeline_name": "Pipeline"
68
+ }
69
+ ]
70
+ }