pipedrive-ruby 0.2.5 → 0.2.6

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.
data/Gemfile CHANGED
@@ -4,6 +4,9 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
6
  gem 'httparty'
7
+ gem 'json', '>= 1.7.7'
8
+ gem 'multi_xml', '>= 0.5.2'
9
+ gem 'webmock'
7
10
 
8
11
  # Add dependencies to develop your gem here.
9
12
  # Include everything needed to run rake, tests, features, etc.
@@ -1,35 +1,48 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (3.2.8)
4
+ activesupport (3.2.12)
5
5
  i18n (~> 0.6)
6
6
  multi_json (~> 1.0)
7
+ addressable (2.3.4)
8
+ bourne (1.1.2)
9
+ mocha (= 0.10.5)
10
+ crack (0.4.0)
11
+ safe_yaml (~> 0.9.0)
7
12
  git (1.2.5)
8
- httparty (0.9.0)
13
+ httparty (0.10.2)
9
14
  multi_json (~> 1.0)
10
- multi_xml
11
- i18n (0.6.1)
15
+ multi_xml (>= 0.5.2)
16
+ i18n (0.6.4)
12
17
  jeweler (1.8.4)
13
18
  bundler (~> 1.0)
14
19
  git (>= 1.2.5)
15
20
  rake
16
21
  rdoc
17
- json (1.7.5)
18
- multi_json (1.3.6)
19
- multi_xml (0.5.1)
20
- rake (0.9.2.2)
21
- rdoc (3.12)
22
+ json (1.7.7)
23
+ metaclass (0.0.1)
24
+ mocha (0.10.5)
25
+ metaclass (~> 0.0.1)
26
+ multi_json (1.6.1)
27
+ multi_xml (0.5.3)
28
+ rake (10.0.3)
29
+ rdoc (3.12.2)
22
30
  json (~> 1.4)
31
+ safe_yaml (0.9.3)
23
32
  shoulda (3.3.2)
24
33
  shoulda-context (~> 1.0.1)
25
34
  shoulda-matchers (~> 1.4.1)
26
- shoulda-context (1.0.1)
27
- shoulda-matchers (1.4.1)
35
+ shoulda-context (1.0.2)
36
+ shoulda-matchers (1.4.2)
28
37
  activesupport (>= 3.0.0)
38
+ bourne (~> 1.1.2)
29
39
  simplecov (0.7.1)
30
40
  multi_json (~> 1.0)
31
41
  simplecov-html (~> 0.7.1)
32
42
  simplecov-html (0.7.1)
43
+ webmock (1.11.0)
44
+ addressable (>= 2.2.7)
45
+ crack (>= 0.3.2)
33
46
 
34
47
  PLATFORMS
35
48
  ruby
@@ -38,6 +51,9 @@ DEPENDENCIES
38
51
  bundler (>= 1.0.0)
39
52
  httparty
40
53
  jeweler (>= 1.8.4)
54
+ json (>= 1.7.7)
55
+ multi_xml (>= 0.5.2)
41
56
  rdoc (~> 3.12)
42
57
  shoulda
43
58
  simplecov
59
+ webmock
@@ -17,8 +17,8 @@
17
17
  Pipedrive::Organization.create( params )
18
18
  Pipedrive::Organization.find( <ID> )
19
19
 
20
- Pipdrive::Person.create( params )
21
- Pipdrive::Person.find( <ID >)
20
+ Pipedrive::Person.create( params )
21
+ Pipedrive::Person.find( <ID >)
22
22
 
23
23
 
24
24
  == Contributing to pipedrive-ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -3,6 +3,8 @@ require 'pipedrive/deal'
3
3
  require 'pipedrive/organization'
4
4
  require 'pipedrive/person'
5
5
  require 'pipedrive/product'
6
+ require 'pipedrive/pipeline'
7
+ require 'pipedrive/stage'
6
8
 
7
9
  module Pipedrive
8
10
 
@@ -20,7 +20,7 @@ module Pipedrive
20
20
  format :json
21
21
 
22
22
  extend Forwardable
23
- def_delegators 'self.class', :get, :post, :put, :resource_path, :bad_response
23
+ def_delegators 'self.class', :delete, :get, :post, :put, :resource_path, :bad_response
24
24
 
25
25
  attr_reader :data
26
26
 
@@ -6,5 +6,13 @@ module Pipedrive
6
6
  res.success? ? res['data']['product_attachment_id'] : bad_response(res)
7
7
  end
8
8
 
9
+ def products
10
+ Product.all(get "#{resource_path}/#{id}/products")
11
+ end
12
+
13
+ def remove_product product_attachment_id
14
+ res = delete "#{resource_path}/#{id}/products", { body: { product_attachment_id: product_attachment_id } }
15
+ res.success? ? nil : bad_response(res)
16
+ end
9
17
  end
10
18
  end
@@ -0,0 +1,7 @@
1
+ module Pipedrive
2
+ class Pipeline < Base
3
+ def stages
4
+ Stage.all(get "/stages", { pipeline_id: self.id })
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Pipedrive
2
+ class Stage < Base
3
+ end
4
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "pipedrive-ruby"
8
- s.version = "0.2.5"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jan Schwenzien", "Waldemar Kusnezow"]
12
- s.date = "2013-02-09"
12
+ s.date = "2013-06-17"
13
13
  s.description = "Ruby wrapper for the Pipedrive API"
14
14
  s.email = "jan@general-scripting.com"
15
15
  s.extra_rdoc_files = [
@@ -27,15 +27,23 @@ Gem::Specification.new do |s|
27
27
  "lib/pipedrive/deal.rb",
28
28
  "lib/pipedrive/organization.rb",
29
29
  "lib/pipedrive/person.rb",
30
+ "lib/pipedrive/pipeline.rb",
30
31
  "lib/pipedrive/product.rb",
32
+ "lib/pipedrive/stage.rb",
31
33
  "pipedrive-ruby.gemspec",
34
+ "test/data/create_deal_body.json",
35
+ "test/data/create_organization_body.json",
36
+ "test/data/create_person_body.json",
32
37
  "test/helper.rb",
33
- "test/test_pipedrive-rails.rb"
38
+ "test/test_pipedrive_authentication.rb",
39
+ "test/test_pipedrive_deal.rb",
40
+ "test/test_pipedrive_organization.rb",
41
+ "test/test_pipedrive_person.rb"
34
42
  ]
35
43
  s.homepage = "https://github.com/GeneralScripting/pipedrive-ruby.git"
36
44
  s.licenses = ["MIT"]
37
45
  s.require_paths = ["lib"]
38
- s.rubygems_version = "1.8.23"
46
+ s.rubygems_version = "1.8.25"
39
47
  s.summary = "Ruby wrapper for the Pipedrive API"
40
48
 
41
49
  if s.respond_to? :specification_version then
@@ -43,6 +51,9 @@ Gem::Specification.new do |s|
43
51
 
44
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
53
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
54
+ s.add_runtime_dependency(%q<json>, [">= 1.7.7"])
55
+ s.add_runtime_dependency(%q<multi_xml>, [">= 0.5.2"])
56
+ s.add_runtime_dependency(%q<webmock>, [">= 0"])
46
57
  s.add_development_dependency(%q<shoulda>, [">= 0"])
47
58
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
48
59
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
@@ -50,6 +61,9 @@ Gem::Specification.new do |s|
50
61
  s.add_development_dependency(%q<simplecov>, [">= 0"])
51
62
  else
52
63
  s.add_dependency(%q<httparty>, [">= 0"])
64
+ s.add_dependency(%q<json>, [">= 1.7.7"])
65
+ s.add_dependency(%q<multi_xml>, [">= 0.5.2"])
66
+ s.add_dependency(%q<webmock>, [">= 0"])
53
67
  s.add_dependency(%q<shoulda>, [">= 0"])
54
68
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
69
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
@@ -58,6 +72,9 @@ Gem::Specification.new do |s|
58
72
  end
59
73
  else
60
74
  s.add_dependency(%q<httparty>, [">= 0"])
75
+ s.add_dependency(%q<json>, [">= 1.7.7"])
76
+ s.add_dependency(%q<multi_xml>, [">= 0.5.2"])
77
+ s.add_dependency(%q<webmock>, [">= 0"])
61
78
  s.add_dependency(%q<shoulda>, [">= 0"])
62
79
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
63
80
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
@@ -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,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
+ }
@@ -9,10 +9,12 @@ rescue Bundler::BundlerError => e
9
9
  end
10
10
  require 'test/unit'
11
11
  require 'shoulda'
12
+ # require 'mocha/setup'
13
+ require 'webmock/test_unit'
12
14
 
13
15
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
16
  $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'pipedrive-rails'
17
+ require 'pipedrive-ruby'
16
18
 
17
19
  class Test::Unit::TestCase
18
20
  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,47 @@
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
+ flunk "to be tested"
46
+ end
47
+ end
@@ -0,0 +1,41 @@
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
+ flunk "to be tested"
40
+ end
41
+ end
@@ -0,0 +1,46 @@
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
+ flunk "to be tested"
45
+ end
46
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipedrive-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-09 00:00:00.000000000 Z
13
+ date: 2013-06-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -28,6 +28,54 @@ dependencies:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
30
  version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: json
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: 1.7.7
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 1.7.7
47
+ - !ruby/object:Gem::Dependency
48
+ name: multi_xml
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.2
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 0.5.2
63
+ - !ruby/object:Gem::Dependency
64
+ name: webmock
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
31
79
  - !ruby/object:Gem::Dependency
32
80
  name: shoulda
33
81
  requirement: !ruby/object:Gem::Requirement
@@ -126,10 +174,18 @@ files:
126
174
  - lib/pipedrive/deal.rb
127
175
  - lib/pipedrive/organization.rb
128
176
  - lib/pipedrive/person.rb
177
+ - lib/pipedrive/pipeline.rb
129
178
  - lib/pipedrive/product.rb
179
+ - lib/pipedrive/stage.rb
130
180
  - pipedrive-ruby.gemspec
181
+ - test/data/create_deal_body.json
182
+ - test/data/create_organization_body.json
183
+ - test/data/create_person_body.json
131
184
  - test/helper.rb
132
- - test/test_pipedrive-rails.rb
185
+ - test/test_pipedrive_authentication.rb
186
+ - test/test_pipedrive_deal.rb
187
+ - test/test_pipedrive_organization.rb
188
+ - test/test_pipedrive_person.rb
133
189
  homepage: https://github.com/GeneralScripting/pipedrive-ruby.git
134
190
  licenses:
135
191
  - MIT
@@ -145,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
201
  version: '0'
146
202
  segments:
147
203
  - 0
148
- hash: -526297699486921758
204
+ hash: -1935958620386015648
149
205
  required_rubygems_version: !ruby/object:Gem::Requirement
150
206
  none: false
151
207
  requirements:
@@ -154,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
210
  version: '0'
155
211
  requirements: []
156
212
  rubyforge_project:
157
- rubygems_version: 1.8.23
213
+ rubygems_version: 1.8.25
158
214
  signing_key:
159
215
  specification_version: 3
160
216
  summary: Ruby wrapper for the Pipedrive API
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestPipedriveRails < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end