pipedrive-connect 1.2.9 → 1.2.11
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 +10 -0
- data/README.md +26 -3
- data/lib/pipedrive/resource.rb +6 -1
- data/lib/pipedrive/resources/user.rb +18 -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: 9893998dfcae74b8d260672486acecd728c90e0106ac31ecfa0a9346ecff7d16
|
4
|
+
data.tar.gz: 56cd3850aec29c134a9b4ebe909fed4521e082bdf7336da21fcee487bbfba162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68014fe619c968921a3875415317fe72f4fccc9c2b9cc1860d5ce0d45d551b40d820b4a9e0caba90371066f661c584a5d782cd7cda9efeb1e11d09df6237f488
|
7
|
+
data.tar.gz: 0e890a6305abdd0fe15d7700bef130fe0d4bcb8b0de5f4dcc42b904ae83d89dedf8c1fe11afa38cdb05f40de6708e3854f14726ebbb5d87bfcbb6bfc0e00489c
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,17 @@ 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.11] - 2022-11-21
|
8
|
+
|
9
|
+
- Added `find` method for user to work for the `find` endpoint of the Pipedrive API
|
10
|
+
|
11
|
+
## [1.2.10] - 2022-10-19
|
12
|
+
|
13
|
+
- Implement `empty?` (or `no_content?`) method on all the models when the response is No content (204 HTTP code)
|
14
|
+
- Add option to treat 204 HTTP code (No Content) as 404 HTTP code (Not found)
|
15
|
+
|
7
16
|
## [1.2.9] - 2022-10-13
|
17
|
+
|
8
18
|
- Add `find_by_deal` method to `Subscription`to allow finding of subscriptions by `deal_id`.
|
9
19
|
|
10
20
|
## [1.2.8] - 2022-10-11
|
data/README.md
CHANGED
@@ -64,11 +64,11 @@ For example to search, retrieve, access, create, update or delete an organizatio
|
|
64
64
|
# return an array of Pipedrive::Organization instances
|
65
65
|
orgs = Pipedrive::Organization.search("Acme Inc")
|
66
66
|
|
67
|
-
# specify it is an exact match and reduce the scope to name and address
|
67
|
+
# specify it is an exact match and reduce the scope to the fields name and address (CSV string)
|
68
68
|
orgs = Pipedrive::Organization.search(
|
69
69
|
"Acme Inc",
|
70
|
-
|
71
|
-
fields: [:name, :address]
|
70
|
+
exact_match: true,
|
71
|
+
fields: [:name, :address].join(",")
|
72
72
|
)
|
73
73
|
|
74
74
|
# Want to paginate across all the organizations sorting them by name?
|
@@ -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 no content is returned
|
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
|
@@ -1,5 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Pipedrive
|
4
|
-
class User < Resource
|
4
|
+
class User < Resource
|
5
|
+
# GET /v1/users/find/
|
6
|
+
# Find users by their name or email
|
7
|
+
def self.find(term, search_by_email)
|
8
|
+
params = { term: term }
|
9
|
+
params = params.merge({ search_by_email: 1 }) if search_by_email
|
10
|
+
response = request(
|
11
|
+
:get,
|
12
|
+
"#{resource_url}/find",
|
13
|
+
params
|
14
|
+
)
|
15
|
+
items = response[:data]
|
16
|
+
|
17
|
+
return [] if items.nil?
|
18
|
+
|
19
|
+
items.map { |d| new(d) }
|
20
|
+
end
|
21
|
+
end
|
5
22
|
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.11
|
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-
|
11
|
+
date: 2022-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|