pipedrive-connect 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +23 -0
- data/lib/pipedrive/resource.rb +12 -12
- data/lib/pipedrive/resources/participant.rb +1 -2
- data/lib/pipedrive/resources/person.rb +1 -1
- data/lib/pipedrive/version.rb +1 -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: 802a599c26c15ec1dd3dca1ec4601dae2e1687138f4208a979e1da0bb4a3a80b
|
4
|
+
data.tar.gz: a330bd75c0dc1713873e82fad5014c2091b1b50933ebaf7f4021b14d3c8bd846
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 862a75c93af2ab058fac2bc491ed0125bbc9cc8beff21c32a7b53c2874010d3bf5759978f92917cdd786fe83510f4e0bc67bf4b07eee825f065aa02821375be0
|
7
|
+
data.tar.gz: 81656beb8265d16d4f6105b3046ede92cbf3a08555b696f9960e979ed343abf17abb0437055330d3c37080d053e145e4a30173b640aac3f42b3031784878fbe6
|
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,13 @@
|
|
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
|
+
## [1.3.1] - 2023-06-01
|
9
|
+
|
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).
|
11
|
+
|
7
12
|
## [1.3.0] - 2023-04-17
|
8
13
|
|
9
14
|
- Modify `has_many` to generate methods to `add` and `delete` resources. ie. `add_participant`, `add_product`, `delete_product`
|
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
|
+
### Has many methods
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
deal = Pipedrive::Deal.retrieve 1
|
104
|
+
person = Pipedrive::Person.retrieve 1
|
105
|
+
product = Pipedrive::Product.retrieve 1
|
106
|
+
|
107
|
+
# add a participant
|
108
|
+
deal.add_participant(person_id: person.id)
|
109
|
+
|
110
|
+
# attach a product to a deal returning the attachment data
|
111
|
+
product_attachment =
|
112
|
+
deal.add_product(product_id: product.id,
|
113
|
+
item_price: 99,
|
114
|
+
quantity: 2,
|
115
|
+
discount_percentage: 5)
|
116
|
+
|
117
|
+
# detach a product from a deal
|
118
|
+
# Note: product attachment is not the product per se
|
119
|
+
# but the record that represent the attachment
|
120
|
+
deal.delete_product(product_attachment.id)
|
121
|
+
```
|
122
|
+
|
100
123
|
### 204 No Content responses
|
101
124
|
|
102
125
|
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/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
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.
|
4
|
+
version: 1.3.1
|
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-
|
11
|
+
date: 2023-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|