PipedrivePUT 1.1.32 → 1.1.33
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/lib/PipedrivePUT/persons.rb +101 -114
- data/lib/PipedrivePUT/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d501ab51b26c25f195c4a150e30566d5e81b9ad
|
4
|
+
data.tar.gz: 62f53bbeed6c931dc8b9eaaa697e2f4f48f19cf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee60bca5753e723afaa54a39bc94b051598c67b4a1948da3a21210721472f8f28e30285e62a1b696fdd071e1a32e08cb5a7dacd3c5bb7d0ab2a629b983b767c2
|
7
|
+
data.tar.gz: 8e82e8d5f238eedad532264b922cfa0736bdd2f1d3f3f318ac0eb02f75a28b2cb02c682cfbd7bc577171994ce859b7764d26c1a2752785038680ebb3f7782571
|
data/lib/PipedrivePUT/persons.rb
CHANGED
@@ -1,132 +1,119 @@
|
|
1
1
|
module PipedrivePUT
|
2
|
+
# Operations from the Persons API
|
3
|
+
class Persons
|
4
|
+
include PipedrivePUT
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#Gets all persons in pipedrive
|
7
|
-
def self.getAllPersons
|
6
|
+
# Gets all persons in pipedrive
|
7
|
+
def self.getAllPersons
|
8
8
|
@start = 0
|
9
|
-
|
10
|
-
table = Array.new
|
11
|
-
@more_items = true
|
12
|
-
tablesize = 0
|
13
|
-
while @more_items == true do
|
14
|
-
count = 0
|
15
|
-
#puts @more_items
|
16
|
-
@base = 'https://api.pipedrive.com/v1/persons?start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s
|
17
|
-
#puts @base
|
18
|
-
@content = open(@base.to_s).read
|
19
|
-
@parsed = JSON.parse(@content)
|
20
|
-
|
21
|
-
while count < @parsed["data"].size
|
22
|
-
#table.push(@parsed["data"][count])
|
23
|
-
table[tablesize] = @parsed["data"][count]
|
24
|
-
count = count +1
|
25
|
-
tablesize = tablesize + 1
|
26
|
-
end
|
27
|
-
|
28
|
-
@pagination = @parsed['additional_data']['pagination']
|
29
|
-
@more_items = @pagination['more_items_in_collection']
|
30
|
-
#puts @more_items
|
31
|
-
@start = @pagination['next_start']
|
32
|
-
#puts @start
|
33
|
-
end
|
34
|
-
|
35
|
-
return table
|
36
|
-
|
37
|
-
end
|
38
9
|
|
10
|
+
table = Array.new
|
11
|
+
@more_items = true
|
12
|
+
tablesize = 0
|
13
|
+
while @more_items == true do
|
14
|
+
count = 0
|
15
|
+
#puts @more_items
|
16
|
+
@base = 'https://api.pipedrive.com/v1/persons?start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s
|
17
|
+
#puts @base
|
18
|
+
@content = open(@base.to_s).read
|
19
|
+
@parsed = JSON.parse(@content)
|
20
|
+
|
21
|
+
while count < @parsed["data"].size
|
22
|
+
#table.push(@parsed["data"][count])
|
23
|
+
table[tablesize] = @parsed["data"][count]
|
24
|
+
count = count +1
|
25
|
+
tablesize = tablesize + 1
|
26
|
+
end
|
39
27
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
@pagination = @parsed['additional_data']['pagination']
|
29
|
+
@more_items = @pagination['more_items_in_collection']
|
30
|
+
#puts @more_items
|
31
|
+
@start = @pagination['next_start']
|
32
|
+
#puts @start
|
33
|
+
end
|
45
34
|
|
35
|
+
return table
|
46
36
|
end
|
47
37
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
if (!options.nil?)
|
55
|
-
|
56
|
-
options.merge!(:name => name)
|
38
|
+
#Gets details of a signle person with id being passed in at params.
|
39
|
+
def self.detailsOfPerson(id)
|
40
|
+
@base = 'https://api.pipedrive.com/v1/persons/' + id.to_s + '?start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s
|
41
|
+
@content = open(@base.to_s).read
|
42
|
+
@parsed = JSON.parse(@content)
|
43
|
+
end
|
57
44
|
|
58
|
-
|
45
|
+
#Add an Person
|
46
|
+
def self.addPerson(name, options = {})
|
47
|
+
@url = 'https://api.pipedrive.com/v1/persons?api_token=' + @@key.to_s
|
59
48
|
|
60
|
-
|
61
|
-
|
49
|
+
if (!options.nil?)
|
50
|
+
options.merge!(:name => name)
|
51
|
+
response = HTTParty.post(@url.to_s, :body => options.to_json, :headers => {'Content-type' => 'application/json'})
|
62
52
|
end
|
53
|
+
end
|
63
54
|
|
64
55
|
#Delete a person from Pipedrive
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
response = HTTParty.delete(@url.to_s)
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
#Update an Organization
|
74
|
-
def self.updatePerson(id, options = {})
|
75
|
-
@url = 'https://api.pipedrive.com/v1/persons/' + id.to_s + '?api_token=' + @@key.to_s
|
76
|
-
|
77
|
-
if (!options.nil?)
|
78
|
-
|
79
|
-
options.merge!(:id => id)
|
80
|
-
#puts options
|
56
|
+
def self.deletePerson(id)
|
57
|
+
@url = 'https://api.pipedrive.com/v1/persons/' + id.to_s + '?api_token=' + @@key.to_s
|
58
|
+
response = HTTParty.delete(@url.to_s)
|
59
|
+
end
|
81
60
|
|
82
|
-
#puts '----------------------'
|
83
|
-
|
84
|
-
response = HTTParty.put(@url.to_s, :body => options.to_json, :headers => {'Content-type' => 'application/json'})
|
85
|
-
#puts '----------------------'
|
86
|
-
#puts response
|
87
|
-
|
88
|
-
end
|
89
61
|
|
90
|
-
|
62
|
+
#Update a Person
|
63
|
+
def self.updatePerson(id, options = {})
|
64
|
+
@url = 'https://api.pipedrive.com/v1/persons/' + id.to_s + '?api_token=' + @@key.to_s
|
91
65
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
@start = 0;
|
96
|
-
table = Array.new
|
97
|
-
@more_items = true
|
98
|
-
|
99
|
-
tablesize = 0
|
100
|
-
|
101
|
-
while @more_items == true do
|
102
|
-
count = 0
|
103
|
-
|
104
|
-
@base = 'https://api.pipedrive.com/v1/persons/find?term=' + term.to_s + '&org_id=' + org_id.to_s + '&start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s
|
105
|
-
|
106
|
-
@content = open(@base.to_s).read
|
107
|
-
@parsed = JSON.parse(@content)
|
108
|
-
|
109
|
-
if @parsed["data"].nil?
|
110
|
-
return "No Persons returned"
|
111
|
-
else
|
112
|
-
|
113
|
-
while count < @parsed["data"].size
|
114
|
-
#table.push(@parsed["data"][count])
|
115
|
-
table[tablesize] = @parsed["data"][count]
|
116
|
-
count = count +1
|
117
|
-
tablesize = tablesize + 1
|
118
|
-
|
119
|
-
end
|
120
|
-
@pagination = @parsed['additional_data']['pagination']
|
121
|
-
@more_items = @pagination['more_items_in_collection']
|
122
|
-
#puts @more_items
|
123
|
-
@start = @pagination['next_start']
|
124
|
-
#puts @start
|
125
|
-
end
|
126
|
-
end
|
127
|
-
return table
|
66
|
+
if (!options.nil?)
|
67
|
+
options.merge!(:id => id)
|
68
|
+
response = HTTParty.put(@url.to_s, :body => options.to_json, :headers => {'Content-type' => 'application/json'})
|
128
69
|
end
|
70
|
+
end
|
129
71
|
|
130
|
-
|
131
|
-
|
132
|
-
|
72
|
+
# Search person by name
|
73
|
+
# term - Search term to look for
|
74
|
+
# optional parameters:
|
75
|
+
# org_id - ID of the organization person is associated with.
|
76
|
+
# start - Pagination start
|
77
|
+
# limit - Items shown per page
|
78
|
+
# search_by_email (boolean) - when enabled, term will only be matched against email addresses
|
79
|
+
# of people. Default: false
|
80
|
+
def self.searchForPerson(term, options = {})
|
81
|
+
table = []
|
82
|
+
more_items = true
|
83
|
+
|
84
|
+
tablesize = 0
|
85
|
+
params = {}
|
86
|
+
|
87
|
+
# optional search parameters
|
88
|
+
params[:start] = options.fetch(:start, 0)
|
89
|
+
params[:org_id] = options.fetch(:org_id, nil) if params[:org_id]
|
90
|
+
params[:limit] = options.fetch(:limit, 500)
|
91
|
+
params[:search_by_email] = options.fetch(:search_by_email, 0)
|
92
|
+
params[:api_token] = @@key.to_s
|
93
|
+
|
94
|
+
url = "https://api.pipedrive.com/v1/persons/find?term=#{term}"
|
95
|
+
|
96
|
+
params.each do |key, value|
|
97
|
+
url << "&#{key}=#{value}"
|
98
|
+
end
|
99
|
+
|
100
|
+
while more_items == true
|
101
|
+
count = 0
|
102
|
+
|
103
|
+
content = open(url).read
|
104
|
+
parsed = JSON.parse(content)
|
105
|
+
return 'No Persons returned' if parsed['data'].nil?
|
106
|
+
|
107
|
+
while count < parsed['data'].size
|
108
|
+
table[tablesize] = parsed['data'][count]
|
109
|
+
count += 1
|
110
|
+
tablesize += 1
|
111
|
+
end
|
112
|
+
pagination = parsed['additional_data']['pagination']
|
113
|
+
more_items = pagination['more_items_in_collection']
|
114
|
+
params['start'] = pagination['next_start']
|
115
|
+
end
|
116
|
+
table
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
data/lib/PipedrivePUT/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: PipedrivePUT
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JakePens71
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -152,4 +152,3 @@ summary: Pipedrive gem to retrieve data from Pipedrive.com
|
|
152
152
|
test_files:
|
153
153
|
- spec/PipedrivePUT_spec.rb
|
154
154
|
- spec/spec_helper.rb
|
155
|
-
has_rdoc:
|