pipedrive_jetrockets 0.0.41 → 0.0.42
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/config/routes.rb +5 -5
- data/lib/pipedrive_jetrockets/service.rb +32 -7
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb622caf9719c7b978a90f978db72a4fff47abbca6316bc0aad742787b66dd96
|
4
|
+
data.tar.gz: 34384c6335b0d3e7437790884111f55a412aa4d899670be4f7d3f9c8c632a948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e23a0176f7d0bf59dd7a36e0b4ba8dd9c08c18013e70eeed9108957c3f12314672057a85477a445dee2153c0238d19a203043ad17e5b645fc92955b5af31592
|
7
|
+
data.tar.gz: d99a866fc987149838a89dbcd81bd80648f9b8fd49756f98e8d555bcde54278a52a9446cd44757a8b62fbe066eff733e8837f5302dce3726cdbc5badbfefa785
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
scope '/pipedrive' do
|
3
|
+
post '/deal_updated' => 'pipedrive_jetrockets/events#deal_updated'
|
4
|
+
end
|
5
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'http'
|
1
2
|
require 'pipedrive_jetrockets/deal'
|
2
3
|
require 'pipedrive_jetrockets/note'
|
3
4
|
require 'pipedrive_jetrockets/organisation'
|
@@ -18,21 +19,25 @@ module PipedriveJetrockets
|
|
18
19
|
"PipedriveJetrockets::#{@resource_name.titleize}".constantize.new(raw)
|
19
20
|
end
|
20
21
|
|
21
|
-
def build_uri(
|
22
|
-
|
22
|
+
def build_uri(params = {}, specificator = nil)
|
23
|
+
params.merge!(api_token: ENV['pipedrive_api_token'])
|
24
|
+
query_string = params.map{|k,v|"#{k}=#{v}"}.join('&')
|
25
|
+
plural_resource_name = @resource_name == 'person' ? 'persons' : @resource_name.pluralize
|
26
|
+
uri = URI("#{HOST}/#{plural_resource_name}/#{specificator}?#{query_string}")
|
23
27
|
end
|
24
28
|
|
25
29
|
def all
|
26
30
|
uri = build_uri
|
27
|
-
|
31
|
+
response = HTTP.get(uri)
|
32
|
+
json_array = ::JSON.parse(response)['data']
|
28
33
|
json_array.map{|raw|build_entity(raw)}
|
29
34
|
end
|
30
35
|
|
31
36
|
def create(params)
|
32
37
|
uri = build_uri
|
33
|
-
response =
|
38
|
+
response = HTTP.post(uri, form: params)
|
34
39
|
|
35
|
-
if response.
|
40
|
+
if response.code == 201
|
36
41
|
JSON.parse(response.body)['data']['id']
|
37
42
|
else
|
38
43
|
nil
|
@@ -40,14 +45,34 @@ module PipedriveJetrockets
|
|
40
45
|
end
|
41
46
|
|
42
47
|
def find(id)
|
43
|
-
uri = build_uri(id)
|
44
|
-
|
48
|
+
uri = build_uri({}, id)
|
49
|
+
response = HTTP.get(uri)
|
50
|
+
raw = ::JSON.parse(response)['data']
|
45
51
|
build_entity(raw)
|
46
52
|
end
|
47
53
|
|
54
|
+
def find_by_email(email)
|
55
|
+
raise NoMethodError if @resource_name != 'person'
|
56
|
+
uri = build_uri({term: email, search_by_email: true }, 'find')
|
57
|
+
response = HTTP.get(uri)
|
58
|
+
json_array = ::JSON.parse(response)['data']
|
59
|
+
return nil unless json_array
|
60
|
+
json_array.map{|raw|build_entity(raw)}
|
61
|
+
end
|
62
|
+
|
48
63
|
def first
|
49
64
|
self.all.first
|
50
65
|
end
|
51
66
|
|
67
|
+
def update(id, params)
|
68
|
+
uri = build_uri({}, id)
|
69
|
+
response = HTTP.put(uri, form: params)
|
70
|
+
|
71
|
+
if response.code == 200
|
72
|
+
JSON.parse(response.body)['data']['id']
|
73
|
+
else
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
end
|
52
77
|
end
|
53
78
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipedrive_jetrockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agafonov Maksim
|
@@ -9,7 +9,21 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-12-15 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Pipedrive API wrapper
|
14
28
|
email: agafonov.maksim@jetrockets.ru
|
15
29
|
executables: []
|