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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4028161bfa2119bd08b3eb17a1c6b40ea199927
4
- data.tar.gz: 203a60f6baca923cf572cd284423297e0de3c887
3
+ metadata.gz: 1d501ab51b26c25f195c4a150e30566d5e81b9ad
4
+ data.tar.gz: 62f53bbeed6c931dc8b9eaaa697e2f4f48f19cf0
5
5
  SHA512:
6
- metadata.gz: ca0cf29998ba1d441c7b8b336789f032ff08e390e0031647c497423704ae1ce2c871fd70ac5423f69d8147fb7068ea3c8b09dd5e04d94d7e769c14c99a7c8af8
7
- data.tar.gz: 8d341c68c420d5c252dae3b4d4884f548f5f3aa8685785aeb37489e3bf93686ed7ca777702fe3b5bfde8fdce1c9d6160d6ada906371911587a7dee9982fec2fd
6
+ metadata.gz: ee60bca5753e723afaa54a39bc94b051598c67b4a1948da3a21210721472f8f28e30285e62a1b696fdd071e1a32e08cb5a7dacd3c5bb7d0ab2a629b983b767c2
7
+ data.tar.gz: 8e82e8d5f238eedad532264b922cfa0736bdd2f1d3f3f318ac0eb02f75a28b2cb02c682cfbd7bc577171994ce859b7764d26c1a2752785038680ebb3f7782571
@@ -1,132 +1,119 @@
1
1
  module PipedrivePUT
2
+ # Operations from the Persons API
3
+ class Persons
4
+ include PipedrivePUT
2
5
 
3
- class Persons
4
- include PipedrivePUT
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
- #Gets details of a signle person with id being passed in at params.
41
- def self.detailsOfPerson(id)
42
- @base = 'https://api.pipedrive.com/v1/persons/' + id.to_s + '?start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s
43
- @content = open(@base.to_s).read
44
- @parsed = JSON.parse(@content)
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
- #Add an Person
49
- def self.addPerson(name, options = {})
50
- #args.each_with_index{ |arg, i| puts "#{i+1}. #{arg}" }
51
-
52
- @url = 'https://api.pipedrive.com/v1/persons?api_token=' + @@key.to_s
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
- #puts options
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
- response = HTTParty.post(@url.to_s, :body => options.to_json, :headers => {'Content-type' => 'application/json'})
61
- end
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
- def self.deletePerson(id)
66
-
67
- @url = 'https://api.pipedrive.com/v1/persons/' + id.to_s + '?api_token=' + @@key.to_s
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
- end
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
- #Search person by name (additional params means organization id)
93
- def self.SearchForPerson(term, org_id)
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
- end
131
-
132
- end
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
@@ -1,3 +1,3 @@
1
1
  module PipedrivePUT
2
- VERSION = "1.1.32"
2
+ VERSION = "1.1.33"
3
3
  end
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.32
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-03-04 00:00:00.000000000 Z
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: