pipedrive-connect 1.2.9 → 1.2.10
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/CHANGELOG.md +6 -0
- data/README.md +23 -0
- data/lib/pipedrive/resource.rb +6 -1
- data/lib/pipedrive/util.rb +12 -3
- data/lib/pipedrive/version.rb +1 -1
- data/lib/pipedrive.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2281f9b37f07b817f422ff7d3d8b254901850051e49a14b8f9e8e5d8e6882046
|
4
|
+
data.tar.gz: 52a88a1f8d811197c860821ce67937ebb381aef36b78f9a683f849f84e818e11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d754a927d1aff43105a9c74a2ac650a7750ddc1c092c5dfc8c45a58cecc9fa857e55aaabc3a0bed7afbd42afed9b8500514e62fa25d6491f5433531b06a10d2
|
7
|
+
data.tar.gz: e84716ef498f0bd319e036c7e2fdc6df88ac9b9c0d43ab978f41ff0003721747c2a27e0db4192fee8de6c9ee862b220bf28e0d5197dd3c6353dcbb22f4fa7fa2
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,13 @@ This file contains all notable changes to this project.
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
5
|
This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
|
6
6
|
|
7
|
+
## [1.2.10] - 2022-10-19
|
8
|
+
|
9
|
+
- Implement `empty?` (or `no_content?`) method on all the models when the response is No content (204 HTTP code)
|
10
|
+
- Add option to treat 204 HTTP code (No Content) as 404 HTTP code (Not found)
|
11
|
+
|
7
12
|
## [1.2.9] - 2022-10-13
|
13
|
+
|
8
14
|
- Add `find_by_deal` method to `Subscription`to allow finding of subscriptions by `deal_id`.
|
9
15
|
|
10
16
|
## [1.2.8] - 2022-10-11
|
data/README.md
CHANGED
@@ -97,6 +97,29 @@ new_acme.update(name: "Acme the new Inc")
|
|
97
97
|
new_acme.delete
|
98
98
|
```
|
99
99
|
|
100
|
+
### 204 No Content responses
|
101
|
+
|
102
|
+
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.
|
103
|
+
|
104
|
+
For these cases a method `empty?` within the model responds `true`.
|
105
|
+
|
106
|
+
For instance:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
# Asuming the subscription is not found but still return with empty body
|
110
|
+
subscription = Pipedrive::Subscription.find_by_deal(123)
|
111
|
+
subscription.empty? # true
|
112
|
+
subscription.no_content? # true - is an alias of empty?
|
113
|
+
```
|
114
|
+
|
115
|
+
In case you want to override that behavior treating **no content** as **not found**, there is an option for that:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
Pipedrive.treat_no_content_as_not_found = true
|
119
|
+
# Will raise a instance of Pipedrive::NotFoundError if subscription
|
120
|
+
subscription = Pipedrive::Subscription.find_by_deal(123)
|
121
|
+
```
|
122
|
+
|
100
123
|
### Custom Fields
|
101
124
|
|
102
125
|
Pipedrive gives you the chance to add additional data by creating custom fields that are not included by default. Deals, Persons, Organizations and Products can all contain custom fields.
|
data/lib/pipedrive/resource.rb
CHANGED
@@ -116,7 +116,7 @@ module Pipedrive
|
|
116
116
|
# init data
|
117
117
|
@data = data
|
118
118
|
# generate the methods
|
119
|
-
data
|
119
|
+
data&.each_key do |k|
|
120
120
|
# it could be a custom field diccionary
|
121
121
|
m, is_custom_field = klass.fields_dicc&.dig(k) &&
|
122
122
|
[klass.fields_dicc&.dig(k), true] ||
|
@@ -152,5 +152,10 @@ module Pipedrive
|
|
152
152
|
protected def fetch_value(key, is_custom_field)
|
153
153
|
@data[is_custom_field ? self.class.inverted_fields_dicc.dig(key) : key]
|
154
154
|
end
|
155
|
+
|
156
|
+
def no_content?
|
157
|
+
@data.nil? || @data.empty?
|
158
|
+
end
|
159
|
+
alias empty? no_content?
|
155
160
|
end
|
156
161
|
end
|
data/lib/pipedrive/util.rb
CHANGED
@@ -3,10 +3,19 @@
|
|
3
3
|
module Pipedrive
|
4
4
|
module Util
|
5
5
|
def self.serialize_response(response, symbolize_names: true)
|
6
|
-
|
7
|
-
|
6
|
+
if response.status == 204
|
7
|
+
return {} unless Pipedrive.treat_no_content_as_not_found
|
8
8
|
|
9
|
-
|
9
|
+
Pipedrive.raise_error(404, error: "HTTP 204 status code received. No content")
|
10
|
+
end
|
11
|
+
|
12
|
+
json_body = JSON.parse(response.body, symbolize_names: symbolize_names)
|
13
|
+
|
14
|
+
if response.success?
|
15
|
+
json_body
|
16
|
+
else
|
17
|
+
Pipedrive.raise_error(response.status, json_body)
|
18
|
+
end
|
10
19
|
end
|
11
20
|
|
12
21
|
def self.debug(message)
|
data/lib/pipedrive/version.rb
CHANGED
data/lib/pipedrive.rb
CHANGED
@@ -27,7 +27,12 @@ module Pipedrive
|
|
27
27
|
BASE_URL = "https://api.pipedrive.com/v1"
|
28
28
|
|
29
29
|
class << self
|
30
|
-
attr_accessor :api_key,
|
30
|
+
attr_accessor :api_key,
|
31
|
+
:logger,
|
32
|
+
:debug,
|
33
|
+
:debug_http,
|
34
|
+
:debug_http_body,
|
35
|
+
:treat_no_content_as_not_found
|
31
36
|
end
|
32
37
|
|
33
38
|
@logger = Logger.new(STDOUT)
|
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.2.
|
4
|
+
version: 1.2.10
|
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: 2022-10-
|
11
|
+
date: 2022-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|