pipedrive-connect 1.3.0 → 2.0.0
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -0
- data/README.md +66 -0
- data/bin/console +1 -0
- data/lib/pipedrive/api_operations/request.rb +15 -2
- data/lib/pipedrive/merge.rb +7 -4
- data/lib/pipedrive/resource.rb +12 -12
- data/lib/pipedrive/resources/activity.rb +4 -0
- data/lib/pipedrive/resources/deal.rb +4 -0
- data/lib/pipedrive/resources/participant.rb +1 -2
- data/lib/pipedrive/resources/person.rb +1 -1
- data/lib/pipedrive/resources/product.rb +4 -0
- data/lib/pipedrive/version.rb +1 -1
- data/lib/pipedrive.rb +20 -2
- data/pipedrive-connect.gemspec +12 -12
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f18dde5f2e0550c63819b8720d7a0cd8f6e5ce569a395caf1fa6b81d65a4e99d
|
4
|
+
data.tar.gz: 4d7c2ffb0aaa8b0a34abe54edcfd544e93082e228cd0ae667295a965a12c502c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbfc929ac2babe044204650a120181ad1a5b88fd7284c9373b9b6b36fa48d8007640ae39aa10a685eda15783528d2da7c77e0022f823394ab0017ebdc2b01b12
|
7
|
+
data.tar.gz: 0ee028a57c6651e12109a858f542f1cf7a633266074508c9351a9c8604afbfceac330df2d29b314690dff7cb28fa9a8f994eee75d543b14ba6b7a3776ba68c76
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,17 @@
|
|
2
2
|
|
3
3
|
This file contains all notable changes to this project.
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
|
+
|
5
6
|
This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
|
6
7
|
|
8
|
+
## [2.0.0] - 2025-04-11
|
9
|
+
- **BREAKING change**: Minimum ruby version updated to 2.7.
|
10
|
+
- Added options for using new V2 API endpoints. Resource `Pipedrive::Activity` switched to new V2 endpoint.
|
11
|
+
- Documentation updates with information on V1/V2 API endpoint switching.
|
12
|
+
## [1.3.1] - 2023-06-01
|
13
|
+
|
14
|
+
- **BREAKING change**: Generated `delete_*` method has been refactored to receive the `id` of the record to be dettached or deleted - instead of the resource per se -, for instance: `deal.delete_product(attached_product_id)`. This is because the API behaves different depending on the endpoint, like in case of `#DELETE /deals/{id}/products/{product_attachment_id}` that receives an id corresponding to the attachment id (not a product, but a different record).
|
15
|
+
|
7
16
|
## [1.3.0] - 2023-04-17
|
8
17
|
|
9
18
|
- Modify `has_many` to generate methods to `add` and `delete` resources. ie. `add_participant`, `add_product`, `delete_product`
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -53,6 +53,49 @@ require 'pipedrive'
|
|
53
53
|
Pipedrive.api_key = ENV["PIPEDRIVE_API_KEY"]
|
54
54
|
```
|
55
55
|
|
56
|
+
### Pipedrive API versions
|
57
|
+
|
58
|
+
Pipedrive has started adding new V2 endpoints to their API. You can change which API endpoint is accessed by setting up
|
59
|
+
the enpoint access on the configuration settings
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
# by default set up to use V2 api endpoints (as of version 2.0.0)
|
63
|
+
irb(main):001:0> Pipedrive.api_version
|
64
|
+
=> :v2
|
65
|
+
|
66
|
+
# use only V1 api endpoints
|
67
|
+
irb(main):005:0> Pipedrive.use_v1_api!
|
68
|
+
=> :v1
|
69
|
+
irb(main):006:0> Pipedrive.api_version
|
70
|
+
=> :v1
|
71
|
+
|
72
|
+
# change back to using V2 api endpoints
|
73
|
+
irb(main):009:0> Pipedrive.use_v2_api!
|
74
|
+
=> :v2
|
75
|
+
irb(main):010:0> Pipedrive.api_version
|
76
|
+
=> :v2
|
77
|
+
```
|
78
|
+
*Please note:* not all resources have V2 api endpoint. For these resources the V2 setting will be ignored and the
|
79
|
+
V1 endpoints will always be used.
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
irb(main):030:0> Pipedrive.use_v2_api!
|
83
|
+
=> :v2
|
84
|
+
irb(main):031:0> Pipedrive.api_version
|
85
|
+
=> :v2
|
86
|
+
irb(main):032:0> Pipedrive::Lead.api_version
|
87
|
+
=> :v1
|
88
|
+
```
|
89
|
+
|
90
|
+
### Backwards Compatibility
|
91
|
+
|
92
|
+
To maintain backwards compatibility, you can explicitly set the API version to V1 in your application's configuration:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
# Set to use V1 API endpoints for all resources
|
96
|
+
Pipedrive.use_v1_api!
|
97
|
+
```
|
98
|
+
|
56
99
|
### Models
|
57
100
|
|
58
101
|
Access your data in pipedrive via the models (for the complete list check out the directory `lib/pipedrive/resources`). You'll find that most of these classes are documented in the [API Reference](https://developers.pipedrive.com/docs/api/v1/).
|
@@ -97,6 +140,29 @@ new_acme.update(name: "Acme the new Inc")
|
|
97
140
|
new_acme.delete
|
98
141
|
```
|
99
142
|
|
143
|
+
### Has many methods
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
deal = Pipedrive::Deal.retrieve 1
|
147
|
+
person = Pipedrive::Person.retrieve 1
|
148
|
+
product = Pipedrive::Product.retrieve 1
|
149
|
+
|
150
|
+
# add a participant
|
151
|
+
deal.add_participant(person_id: person.id)
|
152
|
+
|
153
|
+
# attach a product to a deal returning the attachment data
|
154
|
+
product_attachment =
|
155
|
+
deal.add_product(product_id: product.id,
|
156
|
+
item_price: 99,
|
157
|
+
quantity: 2,
|
158
|
+
discount_percentage: 5)
|
159
|
+
|
160
|
+
# detach a product from a deal
|
161
|
+
# Note: product attachment is not the product per se
|
162
|
+
# but the record that represents the attachment
|
163
|
+
deal.delete_product(product_attachment.id)
|
164
|
+
```
|
165
|
+
|
100
166
|
### 204 No Content responses
|
101
167
|
|
102
168
|
Some endpoints of the API return the HTTP status code **204** which is still a success code returning no data (empty body). This could be confusing but probably has a rationale behind.
|
data/bin/console
CHANGED
@@ -8,12 +8,22 @@ module Pipedrive
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module ClassMethods
|
11
|
+
def supports_v2_api?
|
12
|
+
# default setting, override in resources as required
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def api_version
|
17
|
+
supports_v2_api? ? Pipedrive.api_version : :v1
|
18
|
+
end
|
19
|
+
|
11
20
|
def request(method, url, params = {})
|
12
21
|
check_api_key!
|
13
22
|
raise "Not supported method" \
|
14
23
|
unless %i[get post put patch delete].include?(method)
|
15
24
|
|
16
25
|
Util.debug "#{name} #{method.upcase} #{url}"
|
26
|
+
|
17
27
|
response = api_client.send(method) do |req|
|
18
28
|
req.url url
|
19
29
|
req.params = { api_token: Pipedrive.api_key }
|
@@ -23,18 +33,21 @@ module Pipedrive
|
|
23
33
|
req.params.merge!(params)
|
24
34
|
end
|
25
35
|
end
|
36
|
+
|
26
37
|
Util.serialize_response(response)
|
27
38
|
end
|
28
39
|
|
29
40
|
def api_client
|
30
41
|
@api_client = Faraday.new(
|
31
|
-
url: BASE_URL,
|
42
|
+
url: "#{BASE_URL}/#{api_version}",
|
32
43
|
headers: { "Content-Type": "application/json" }
|
33
44
|
) do |faraday|
|
34
45
|
if Pipedrive.debug_http
|
35
46
|
faraday.response :logger, Pipedrive.logger,
|
36
|
-
bodies:
|
47
|
+
bodies: Pipedrive.debug_http_body
|
37
48
|
end
|
49
|
+
|
50
|
+
faraday.adapter Pipedrive.faraday_adapter
|
38
51
|
end
|
39
52
|
end
|
40
53
|
|
data/lib/pipedrive/merge.rb
CHANGED
@@ -5,10 +5,13 @@ module Pipedrive
|
|
5
5
|
def merge(with_id:)
|
6
6
|
raise "with_id must be an integer" unless with_id&.is_a?(Integer)
|
7
7
|
|
8
|
-
response = request(
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
response = request(
|
9
|
+
:put,
|
10
|
+
"#{resource_url}/merge",
|
11
|
+
merge_with_id: with_id
|
12
|
+
)
|
13
|
+
|
14
|
+
self.class.new(response[:data])
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
data/lib/pipedrive/resource.rb
CHANGED
@@ -73,7 +73,7 @@ module Pipedrive
|
|
73
73
|
"For example has_many :deals, class_name: 'Deal'"
|
74
74
|
end
|
75
75
|
class_name_lower_case = class_name.downcase
|
76
|
-
singular = args[:singular] || class_name_lower_case
|
76
|
+
singular = args[:singular] || class_name_lower_case
|
77
77
|
# always include all the data of the resource
|
78
78
|
options = { "include_#{class_name_lower_case}_data": 1 }
|
79
79
|
# add namespace to class_name
|
@@ -82,14 +82,16 @@ module Pipedrive
|
|
82
82
|
response = request(:get,
|
83
83
|
"#{resource_url}/#{resource_name}",
|
84
84
|
params.merge(options))
|
85
|
-
response
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
data = data
|
85
|
+
response
|
86
|
+
.dig(:data)
|
87
|
+
&.map do |data|
|
88
|
+
class_name_as_sym = class_name_lower_case.to_sym
|
89
|
+
data[:metadata] = data
|
90
|
+
if data.key?(class_name_as_sym)
|
91
|
+
data = data.merge(data.delete(class_name_as_sym))
|
92
|
+
end
|
93
|
+
Object.const_get(class_name).new(data)
|
90
94
|
end
|
91
|
-
Object.const_get(class_name).new(data)
|
92
|
-
end
|
93
95
|
end
|
94
96
|
|
95
97
|
define_method("add_#{singular}") do |params|
|
@@ -101,10 +103,8 @@ module Pipedrive
|
|
101
103
|
Object.const_get(class_name).new(response.dig(:data))
|
102
104
|
end
|
103
105
|
|
104
|
-
define_method("delete_#{singular}") do |
|
105
|
-
|
106
|
-
unless resource.is_a?(Pipedrive::Resource)
|
107
|
-
response = request(:delete, "#{resource_url}/#{resource_name}/#{resource.id}")
|
106
|
+
define_method("delete_#{singular}") do |resource_id|
|
107
|
+
response = request(:delete, "#{resource_url}/#{resource_name}/#{resource_id}")
|
108
108
|
response[:success]
|
109
109
|
end
|
110
110
|
end
|
data/lib/pipedrive/version.rb
CHANGED
data/lib/pipedrive.rb
CHANGED
@@ -24,7 +24,7 @@ require "pipedrive/merge"
|
|
24
24
|
require "pipedrive/resources"
|
25
25
|
|
26
26
|
module Pipedrive
|
27
|
-
BASE_URL = "https://api.pipedrive.com/
|
27
|
+
BASE_URL = "https://api.pipedrive.com/api"
|
28
28
|
|
29
29
|
class << self
|
30
30
|
attr_accessor :api_key,
|
@@ -33,7 +33,25 @@ module Pipedrive
|
|
33
33
|
:debug_http,
|
34
34
|
:debug_http_body,
|
35
35
|
:treat_no_content_as_not_found
|
36
|
+
|
37
|
+
attr_writer :faraday_adapter
|
38
|
+
|
39
|
+
def use_v2_api!
|
40
|
+
@api_version = :v2
|
41
|
+
end
|
42
|
+
|
43
|
+
def use_v1_api!
|
44
|
+
@api_version = :v1
|
45
|
+
end
|
46
|
+
|
47
|
+
def api_version
|
48
|
+
@api_version || :v2
|
49
|
+
end
|
50
|
+
|
51
|
+
def faraday_adapter
|
52
|
+
@faraday_adapter || :net_http
|
53
|
+
end
|
36
54
|
end
|
37
55
|
|
38
|
-
@logger = Logger.new(
|
56
|
+
@logger = Logger.new($stdout)
|
39
57
|
end
|
data/pipedrive-connect.gemspec
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift(
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
|
4
4
|
|
5
5
|
require "pipedrive/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
8
|
+
spec.name = "pipedrive-connect"
|
9
|
+
spec.version = Pipedrive::VERSION
|
10
|
+
spec.authors = "Get on Board"
|
11
|
+
spec.email = "team@getonbrd.com"
|
12
|
+
spec.summary = "Ruby binding for the pipedrive API."
|
13
|
+
spec.homepage = "https://github.com/getonbrd/pipedrive-connect"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
12
16
|
|
13
|
-
spec.
|
14
|
-
spec.homepage = "https://github.com/getonbrd/pipedrive-connect"
|
15
|
-
spec.license = "MIT"
|
16
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
17
|
-
|
18
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
18
|
spec.metadata["source_code_uri"] = "https://github.com/getonbrd/pipedrive-connect"
|
20
|
-
spec.metadata["changelog_uri"]
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/getonbrd/pipedrive-connect/CHANGELOG.md"
|
21
20
|
|
22
21
|
# Specify which files should be added to the gem when it is released.
|
23
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -30,4 +29,5 @@ Gem::Specification.new do |spec|
|
|
30
29
|
|
31
30
|
# dependencies
|
32
31
|
spec.add_dependency("faraday", "< 3")
|
32
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipedrive-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Get on Board
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -86,6 +86,7 @@ metadata:
|
|
86
86
|
homepage_uri: https://github.com/getonbrd/pipedrive-connect
|
87
87
|
source_code_uri: https://github.com/getonbrd/pipedrive-connect
|
88
88
|
changelog_uri: https://github.com/getonbrd/pipedrive-connect/CHANGELOG.md
|
89
|
+
rubygems_mfa_required: 'true'
|
89
90
|
post_install_message:
|
90
91
|
rdoc_options: []
|
91
92
|
require_paths:
|
@@ -94,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
95
|
requirements:
|
95
96
|
- - ">="
|
96
97
|
- !ruby/object:Gem::Version
|
97
|
-
version: 2.
|
98
|
+
version: 2.7.0
|
98
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
100
|
requirements:
|
100
101
|
- - ">="
|