pipedrive-connect 1.3.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 802a599c26c15ec1dd3dca1ec4601dae2e1687138f4208a979e1da0bb4a3a80b
4
- data.tar.gz: a330bd75c0dc1713873e82fad5014c2091b1b50933ebaf7f4021b14d3c8bd846
3
+ metadata.gz: f18dde5f2e0550c63819b8720d7a0cd8f6e5ce569a395caf1fa6b81d65a4e99d
4
+ data.tar.gz: 4d7c2ffb0aaa8b0a34abe54edcfd544e93082e228cd0ae667295a965a12c502c
5
5
  SHA512:
6
- metadata.gz: 862a75c93af2ab058fac2bc491ed0125bbc9cc8beff21c32a7b53c2874010d3bf5759978f92917cdd786fe83510f4e0bc67bf4b07eee825f065aa02821375be0
7
- data.tar.gz: 81656beb8265d16d4f6105b3046ede92cbf3a08555b696f9960e979ed343abf17abb0437055330d3c37080d053e145e4a30173b640aac3f42b3031784878fbe6
6
+ metadata.gz: fbfc929ac2babe044204650a120181ad1a5b88fd7284c9373b9b6b36fa48d8007640ae39aa10a685eda15783528d2da7c77e0022f823394ab0017ebdc2b01b12
7
+ data.tar.gz: 0ee028a57c6651e12109a858f542f1cf7a633266074508c9351a9c8604afbfceac330df2d29b314690dff7cb28fa9a8f994eee75d543b14ba6b7a3776ba68c76
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  /Gemfile.lock
11
11
  .rvmrc
12
+ .tool-versions
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ AllCops:
2
2
  NewCops: enable
3
3
 
4
4
  DisplayCopNames: true
5
- TargetRubyVersion: 2.6
5
+ TargetRubyVersion: 2.7
6
6
 
7
7
  Metrics/BlockLength:
8
8
  Max: 40
data/CHANGELOG.md CHANGED
@@ -5,9 +5,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
7
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.
8
12
  ## [1.3.1] - 2023-06-01
9
13
 
10
- - **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).
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).
11
15
 
12
16
  ## [1.3.0] - 2023-04-17
13
17
 
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ gemspec
6
6
 
7
7
  group :development do
8
8
  gem "byebug"
9
+ gem "faraday-net_http", require: true
9
10
  gem "mocha"
10
11
  gem "pry"
11
12
  gem "rspec"
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/).
@@ -116,7 +159,7 @@ product_attachment =
116
159
 
117
160
  # detach a product from a deal
118
161
  # Note: product attachment is not the product per se
119
- # but the record that represent the attachment
162
+ # but the record that represents the attachment
120
163
  deal.delete_product(product_attachment.id)
121
164
  ```
122
165
 
data/bin/console CHANGED
@@ -6,6 +6,7 @@ require "bundler/setup"
6
6
  require "pipedrive"
7
7
  require "pry"
8
8
  require "irb"
9
+ require "faraday/net_http"
9
10
 
10
11
  # You can add fixtures and/or initialization code here to make experimenting
11
12
  # with your gem easier. You can also use a different console, if you like.
@@ -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: Pipedrive.debug_http_body
47
+ bodies: Pipedrive.debug_http_body
37
48
  end
49
+
50
+ faraday.adapter Pipedrive.faraday_adapter
38
51
  end
39
52
  end
40
53
 
@@ -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(:put,
9
- "#{resource_url}/merge",
10
- merge_with_id: with_id)
11
- self.class.new(response.dig(:data))
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
@@ -4,5 +4,9 @@ module Pipedrive
4
4
  class Activity < Resource
5
5
  include Fields
6
6
  self.resources_url = "activities"
7
+
8
+ def self.supports_v2_api?
9
+ true
10
+ end
7
11
  end
8
12
  end
@@ -7,5 +7,9 @@ module Pipedrive
7
7
 
8
8
  has_many :products, class_name: "Product"
9
9
  has_many :participants, class_name: "Participant"
10
+
11
+ def self.supports_v2_api?
12
+ false
13
+ end
10
14
  end
11
15
  end
@@ -3,5 +3,9 @@
3
3
  module Pipedrive
4
4
  class Product < Resource
5
5
  include Fields
6
+
7
+ def self.supports_v2_api?
8
+ false
9
+ end
6
10
  end
7
11
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pipedrive
4
- VERSION = "1.3.1"
4
+ VERSION = "2.0.0"
5
5
  end
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/v1"
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(STDOUT)
56
+ @logger = Logger.new($stdout)
39
57
  end
@@ -1,23 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- $LOAD_PATH.unshift(::File.join(::File.dirname(__FILE__), "lib"))
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 = "pipedrive-connect"
9
- spec.version = Pipedrive::VERSION
10
- spec.authors = "Get on Board"
11
- spec.email = "team@getonbrd.com"
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.summary = "Ruby binding for the pipedrive API."
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"] = "https://github.com/getonbrd/pipedrive-connect/CHANGELOG.md"
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: 1.3.1
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: 2023-06-01 00:00:00.000000000 Z
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.3.0
98
+ version: 2.7.0
98
99
  required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - ">="