pipekit 1.2.0 → 2.0.0
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/README.md +110 -4
- data/lib/pipekit/deal.rb +1 -1
- data/lib/pipekit/person.rb +7 -1
- data/lib/pipekit/repository.rb +5 -0
- data/lib/pipekit/user.rb +13 -0
- data/lib/pipekit/version.rb +1 -1
- data/lib/pipekit.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c29f137ec674dd92e5458ec82f4a637f4571da25
|
4
|
+
data.tar.gz: 0bca608dc9986d0549efd1a79c0dd7deb3cd8d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 341d2b409dda391fdd27a25fb2c215d8956910c99f6f2402f72cc1ef9991c47c67899903bd2cb6f7084a7d16ebe416d3b63f54de11e4e8c7afe0292f5076275d
|
7
|
+
data.tar.gz: 5e792c6a7523980c5a3ef917a7bebfe283f2e3ba80313dddc1f43d4f361c6587b2273cb662f792312936885f8341407ba1d0a2cf8399253533484a5ba0d27028
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Pipekit
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Pipekit is a gem to interact with [Pipedrive](https://www.pipedrive.com) API.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -20,9 +18,117 @@ Or install it yourself as:
|
|
20
18
|
|
21
19
|
$ gem install pipekit
|
22
20
|
|
21
|
+
Pipekit expects a config file containing your api token and key-value mappings for custom pipedrive fields. Look at [example config](./spec/support/config.yml) to see the file structure.
|
22
|
+
|
23
|
+
Configure Pipekit with your config file:
|
24
|
+
|
25
|
+
Pipekit.config_file_path = File.join("config", "pipedrive.yml")
|
26
|
+
|
27
|
+
You need to do once when Pipekit is loaded, the good place for it in the Rails project is `initializers`.
|
28
|
+
|
23
29
|
## Usage
|
24
30
|
|
25
|
-
|
31
|
+
The interface of Pipekit is organised around *repositories*. The available repositories are:
|
32
|
+
|
33
|
+
- Deal
|
34
|
+
- DealField
|
35
|
+
- Note
|
36
|
+
- Organization
|
37
|
+
- Person
|
38
|
+
- PersonField
|
39
|
+
|
40
|
+
### Resource repositories
|
41
|
+
|
42
|
+
Deal, Note, Organization and Person represent corresponding resources on Pipedrive. Repositories provide several methods for querying and changing these resources.
|
43
|
+
|
44
|
+
Methods available for all non-field repositories are:
|
45
|
+
|
46
|
+
- `all`
|
47
|
+
- `where`
|
48
|
+
- `find_by`
|
49
|
+
- `create`
|
50
|
+
- `update`
|
51
|
+
|
52
|
+
#### Examples
|
53
|
+
|
54
|
+
Get all deals
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
deal_repo = Pipekit::Deal.new
|
58
|
+
|
59
|
+
deal_repo.all
|
60
|
+
```
|
61
|
+
|
62
|
+
Get all persons matching an attribute
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
person_repo = Pipekit::Person.new
|
66
|
+
|
67
|
+
person_repo.where(name: "Mike")
|
68
|
+
```
|
69
|
+
|
70
|
+
Get the first deal matching an attribute
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
deal_repo = Pipekit::Deal.new
|
74
|
+
|
75
|
+
deal_repo.find_by(id: 123)
|
76
|
+
```
|
77
|
+
|
78
|
+
Create a person
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
person_repo = Pipekit::Person.new
|
82
|
+
|
83
|
+
person_repo.create({name: "John Doe", deal_id: 123})
|
84
|
+
```
|
85
|
+
|
86
|
+
Update a note
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
note_repo = Pipekit::Note.new
|
90
|
+
|
91
|
+
note_repo.update(123, {content: "Hey"})
|
92
|
+
```
|
93
|
+
|
94
|
+
### Field repositories
|
95
|
+
|
96
|
+
Pipedrive stores custom fields as key-value pairs. E.g. when you add an "Address" field to Persons Pipderive will store it as something like "050280e9bed01e55e25532f0b6e6228c748bf994"
|
97
|
+
|
98
|
+
Methods available for field repositories (PersonField, DealField) are:
|
99
|
+
|
100
|
+
- `get_by_key`
|
101
|
+
- `get_by_name`
|
102
|
+
- `find_label`
|
103
|
+
- `find_values`
|
104
|
+
|
105
|
+
### Response object
|
106
|
+
|
107
|
+
`Pipekit::Response` is a hash-like object that performs an automatic conversion if Pipedrive IDs to meaningful field names.
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
# pipedrive.yml
|
111
|
+
#
|
112
|
+
# fields:
|
113
|
+
# person:
|
114
|
+
# Emergency Contact: 345abd
|
115
|
+
# T-Shirt Size: 567qwe
|
116
|
+
#
|
117
|
+
# field_values:
|
118
|
+
# person:
|
119
|
+
# T-Shirt Size:
|
120
|
+
# "1": Small
|
121
|
+
# "2": Medium
|
122
|
+
# "3": Large
|
123
|
+
|
124
|
+
data = {"id" => 123, "345abd" => "+44123456789", "567qwe" => "1"}
|
125
|
+
|
126
|
+
person = Pipekit::Response.new(data)
|
127
|
+
person["Emergency Contact"]
|
128
|
+
#=> +44123456789
|
129
|
+
person["T-Shirt Size"]
|
130
|
+
#=> "Small"
|
131
|
+
```
|
26
132
|
|
27
133
|
## Development
|
28
134
|
|
data/lib/pipekit/deal.rb
CHANGED
@@ -10,7 +10,7 @@ module Pipekit
|
|
10
10
|
# Finds a person by their email, then finds the first deal related to that
|
11
11
|
# person and updates it with the params provided
|
12
12
|
def update_by_person(email, params, person_repo: Person.new)
|
13
|
-
person = person_repo.
|
13
|
+
person = person_repo.find_exactly_by_email(email)
|
14
14
|
deal = get_by_person_id(person[:id], person_repo: person_repo).first
|
15
15
|
update(deal[:id], params)
|
16
16
|
end
|
data/lib/pipekit/person.rb
CHANGED
@@ -10,8 +10,14 @@ module Pipekit
|
|
10
10
|
request.get("find", term: name)
|
11
11
|
end
|
12
12
|
|
13
|
+
def find_exactly_by_email(email)
|
14
|
+
get_by_email(email).select do |item|
|
15
|
+
item["email"] == email
|
16
|
+
end.first
|
17
|
+
end
|
18
|
+
|
13
19
|
def update_by_email(email, fields)
|
14
|
-
person =
|
20
|
+
person = find_exactly_by_email(email)
|
15
21
|
update(person["id"], fields)
|
16
22
|
end
|
17
23
|
|
data/lib/pipekit/repository.rb
CHANGED
@@ -39,6 +39,7 @@ module Pipekit
|
|
39
39
|
#
|
40
40
|
# Returns a Hash or nil if none found.
|
41
41
|
def find_by(options)
|
42
|
+
warn "Using `Repository#find_by` with an email may return inexact matches" if email_key?(options)
|
42
43
|
where(options, true).first
|
43
44
|
end
|
44
45
|
|
@@ -95,5 +96,9 @@ module Pipekit
|
|
95
96
|
def resource
|
96
97
|
self.class.to_s.split("::").last.tap { |name| name[0] = name[0].downcase }
|
97
98
|
end
|
99
|
+
|
100
|
+
def email_key?(options)
|
101
|
+
options.keys.first && options.keys.first.to_s == "email"
|
102
|
+
end
|
98
103
|
end
|
99
104
|
end
|
data/lib/pipekit/user.rb
ADDED
data/lib/pipekit/version.rb
CHANGED
data/lib/pipekit.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipekit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jafrog
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2017-05-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/pipekit/request.rb
|
145
145
|
- lib/pipekit/response.rb
|
146
146
|
- lib/pipekit/result.rb
|
147
|
+
- lib/pipekit/user.rb
|
147
148
|
- lib/pipekit/version.rb
|
148
149
|
- pipekit.gemspec
|
149
150
|
homepage: https://github.com/makersacademy/pipekit
|
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
version: '0'
|
168
169
|
requirements: []
|
169
170
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
171
|
+
rubygems_version: 2.6.8
|
171
172
|
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: Pipedrive API client for Ruby.
|