pipedrive-connect 1.2.6 → 1.2.9
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 +14 -0
- data/lib/pipedrive/errors.rb +55 -2
- data/lib/pipedrive/resources/organization_field.rb +7 -0
- data/lib/pipedrive/resources/person.rb +1 -0
- data/lib/pipedrive/resources/subscription.rb +46 -0
- data/lib/pipedrive/resources.rb +2 -0
- data/lib/pipedrive/util.rb +1 -10
- data/lib/pipedrive/version.rb +1 -1
- data/pipedrive-connect.gemspec +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8e4b1a077e77ca44298953e658c3b83e37845ed292dcf3c334275c6e15f682e
|
4
|
+
data.tar.gz: b7c5b32c1b7ec0a4335aa0305d863dc2179d0e7c4f667f80f4984712b1bd7903
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ce8e1d269278a87b626eaa2cb9a135ff0276327476668369c01f94156544ed02c8f2f4b366176faa2e87a115a9aadb6e0edbd19f5a67247e347c060384739f3
|
7
|
+
data.tar.gz: 4c3651542de50c276b1f896a8e101e8ec06d6c1da335869fcbceee534859858143663aaf8dc3a91f73ee0d6eacf5abd8c768de4f2b0f799fecb307f58b956f33
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,20 @@ 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.9] - 2022-10-13
|
8
|
+
- Add `find_by_deal` method to `Subscription`to allow finding of subscriptions by `deal_id`.
|
9
|
+
|
10
|
+
## [1.2.8] - 2022-10-11
|
11
|
+
|
12
|
+
- Add the new resource `Pipedrive::OrganizationField`
|
13
|
+
- Add activities (as a `has_many` relationship) to `Pipedrive::Person`
|
14
|
+
- Provide better error information also maping the status code to a class according to https://pipedrive.readme.io/docs/core-api-concepts-http-status-codes (check lib/pipedrive/errors.rb)
|
15
|
+
|
16
|
+
## [1.2.7] - 2022-09-23
|
17
|
+
|
18
|
+
- Add `Subscription` resource with additional `create_recurring`, `update_recurring` and `cancel_recurring` methods.
|
19
|
+
- Changed faraday dependency to allow more flexibility
|
20
|
+
|
7
21
|
## [1.2.6] - 2022-07-11
|
8
22
|
|
9
23
|
- Add `delete_attached_product` method to `Deal`
|
data/lib/pipedrive/errors.rb
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
|
3
3
|
module Pipedrive
|
4
4
|
class PipedriveError < StandardError
|
5
|
-
attr_reader :code
|
5
|
+
attr_reader :code, :data
|
6
6
|
|
7
|
-
def initialize(message = nil, code = nil)
|
7
|
+
def initialize(message = nil, code = nil, data = nil)
|
8
8
|
super(message)
|
9
9
|
@message = message
|
10
10
|
@code = code
|
11
|
+
@data = data
|
11
12
|
end
|
12
13
|
|
13
14
|
def message
|
@@ -15,8 +16,60 @@ module Pipedrive
|
|
15
16
|
"#{code_str}#{@message}"
|
16
17
|
end
|
17
18
|
end
|
19
|
+
|
20
|
+
# As documented at https://pipedrive.readme.io/docs/core-api-concepts-http-status-codes
|
18
21
|
class SettingError < PipedriveError; end
|
19
22
|
class AuthenticationError < PipedriveError; end
|
20
23
|
class NotFoundError < PipedriveError; end
|
24
|
+
class BadRequestError < PipedriveError; end
|
25
|
+
class UnauthorizedError < PipedriveError; end
|
26
|
+
class PaymentRequiredError < PipedriveError; end
|
27
|
+
class ForbiddenError < PipedriveError; end
|
28
|
+
class MethodNotAllowedError < PipedriveError; end
|
29
|
+
class GoneError < PipedriveError; end
|
30
|
+
class UnsupportedMediaTypeError < PipedriveError; end
|
31
|
+
class UnprocessableEntityError < PipedriveError; end
|
32
|
+
class TooManyRequestsError < PipedriveError; end
|
33
|
+
class InternalServerError < PipedriveError; end
|
34
|
+
class NotImplementedError < PipedriveError; end
|
35
|
+
class ServiceUnavailableError < PipedriveError; end
|
21
36
|
class UnkownAPIError < PipedriveError; end
|
37
|
+
|
38
|
+
ERROR_CLASS_MAP = {
|
39
|
+
"400" => BadRequestError,
|
40
|
+
"401" => UnauthorizedError,
|
41
|
+
"402" => PaymentRequiredError,
|
42
|
+
"403" => ForbiddenError,
|
43
|
+
"404" => NotFoundError,
|
44
|
+
"405" => MethodNotAllowedError,
|
45
|
+
"410" => GoneError,
|
46
|
+
"415" => UnsupportedMediaTypeError,
|
47
|
+
"422" => UnprocessableEntityError,
|
48
|
+
"429" => TooManyRequestsError,
|
49
|
+
"500" => InternalServerError,
|
50
|
+
"501" => NotImplementedError,
|
51
|
+
"503" => ServiceUnavailableError,
|
52
|
+
}.freeze
|
53
|
+
|
54
|
+
def raise_error(status, response)
|
55
|
+
return if [200, 201].include?(status)
|
56
|
+
|
57
|
+
message =
|
58
|
+
[response.dig(:error), response.dig(:error_info)]
|
59
|
+
.compact
|
60
|
+
.join(". ")
|
61
|
+
|
62
|
+
error_data =
|
63
|
+
response
|
64
|
+
.fetch(:data, {})
|
65
|
+
.inspect
|
66
|
+
.concat(response.fetch(:additional_data, {}).inspect)
|
67
|
+
|
68
|
+
error_class = ERROR_CLASS_MAP[status.to_s]
|
69
|
+
raise error_class.new(message, status, error_data) if error_class
|
70
|
+
|
71
|
+
raise UnkownAPIError.new(message, status, error_data)
|
72
|
+
end
|
73
|
+
|
74
|
+
module_function :raise_error
|
22
75
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pipedrive
|
4
|
+
class Subscription < Resource
|
5
|
+
# POST /subscriptions/recurring
|
6
|
+
# Adds a recurring subscription
|
7
|
+
def self.create_recurring(params)
|
8
|
+
response = request(
|
9
|
+
:post,
|
10
|
+
"#{resource_url}/recurring",
|
11
|
+
params
|
12
|
+
)
|
13
|
+
Subscription.new(response.dig(:data))
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /subscriptions/find/:id
|
17
|
+
# Returns details of a recurring subscription by the deal ID
|
18
|
+
def self.find_by_deal(id)
|
19
|
+
response = request(:get,"#{resource_url}/find/#{id}")
|
20
|
+
new(response.dig(:data))
|
21
|
+
end
|
22
|
+
|
23
|
+
# PUT /subscriptions/recurring/:id
|
24
|
+
# Updates a recurring subscription
|
25
|
+
def update_recurring(params = {})
|
26
|
+
response = request(
|
27
|
+
:put,
|
28
|
+
"#{self.class.resource_url}/recurring/#{id}",
|
29
|
+
params
|
30
|
+
)
|
31
|
+
Subscription.new(response.dig(:data))
|
32
|
+
end
|
33
|
+
|
34
|
+
# PUT /subscriptions/recurring/:id/cancel
|
35
|
+
# Cancels a recurring subscription
|
36
|
+
def cancel_recurring(params = {})
|
37
|
+
response = request(
|
38
|
+
:put,
|
39
|
+
"#{self.class.resource_url}/recurring/#{id}/cancel",
|
40
|
+
params
|
41
|
+
)
|
42
|
+
Subscription.new(response.dig(:data))
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/lib/pipedrive/resources.rb
CHANGED
@@ -13,6 +13,7 @@ require "pipedrive/resources/lead_label"
|
|
13
13
|
require "pipedrive/resources/lead_source"
|
14
14
|
require "pipedrive/resources/lead"
|
15
15
|
require "pipedrive/resources/organization"
|
16
|
+
require "pipedrive/resources/organization_field"
|
16
17
|
require "pipedrive/resources/pipeline"
|
17
18
|
require "pipedrive/resources/product"
|
18
19
|
require "pipedrive/resources/person"
|
@@ -20,4 +21,5 @@ require "pipedrive/resources/note"
|
|
20
21
|
require "pipedrive/resources/stage"
|
21
22
|
require "pipedrive/resources/team"
|
22
23
|
require "pipedrive/resources/user"
|
24
|
+
require "pipedrive/resources/subscription"
|
23
25
|
require "pipedrive/resources/webhook"
|
data/lib/pipedrive/util.rb
CHANGED
@@ -6,16 +6,7 @@ module Pipedrive
|
|
6
6
|
rjson = JSON.parse(response.body, symbolize_names: symbolize_names)
|
7
7
|
return rjson if response.success?
|
8
8
|
|
9
|
-
raise_error(response.status, rjson)
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.raise_error(status, response)
|
13
|
-
case status
|
14
|
-
when 404
|
15
|
-
raise NotFoundError.new(response.dig(:error), status)
|
16
|
-
else
|
17
|
-
raise UnkownAPIError.new(response.dig(:error), status)
|
18
|
-
end
|
9
|
+
Pipedrive.raise_error(response.status, rjson)
|
19
10
|
end
|
20
11
|
|
21
12
|
def self.debug(message)
|
data/lib/pipedrive/version.rb
CHANGED
data/pipedrive-connect.gemspec
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
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.9
|
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-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3'
|
27
27
|
description:
|
28
28
|
email: team@getonbrd.com
|
29
29
|
executables: []
|
@@ -66,10 +66,12 @@ files:
|
|
66
66
|
- lib/pipedrive/resources/lead_source.rb
|
67
67
|
- lib/pipedrive/resources/note.rb
|
68
68
|
- lib/pipedrive/resources/organization.rb
|
69
|
+
- lib/pipedrive/resources/organization_field.rb
|
69
70
|
- lib/pipedrive/resources/person.rb
|
70
71
|
- lib/pipedrive/resources/pipeline.rb
|
71
72
|
- lib/pipedrive/resources/product.rb
|
72
73
|
- lib/pipedrive/resources/stage.rb
|
74
|
+
- lib/pipedrive/resources/subscription.rb
|
73
75
|
- lib/pipedrive/resources/team.rb
|
74
76
|
- lib/pipedrive/resources/user.rb
|
75
77
|
- lib/pipedrive/resources/webhook.rb
|