PipedrivePUT 1.1.25 → 1.1.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3482ec90f7ff3d7171a670ad1e6b0e18da8ab08f
4
- data.tar.gz: 5f98bae242775118e9d3fee6359ff67e617903a1
3
+ metadata.gz: d4a99a18e055a0dfa4257e023517b81734d60c18
4
+ data.tar.gz: 96400b33b801f94cceb130e736b6ae1b610dd532
5
5
  SHA512:
6
- metadata.gz: bdf810789c99e3b18b48c9c457cfe55241b6addf7306271e93f6aa08d60b9aaea283cd6d5c0f22e33a332e30dea228076b803c994bf56f1694d4fd20d89e6d3f
7
- data.tar.gz: 7f338214e692aba775980ec83ac3f3353ecdce8c3627a218e519532ac5d6fb8bf206cfa2c9ec288f5ed503a42a9f1fc2bb0faac5caffdefd38db96bb536824a1
6
+ metadata.gz: faf318427f34e264b30916be0fb4ff6b558f7da40212635ab0711a33d3ed390dce38a7b92840baaea3b48d9d8370eff1ee877c181acdc1c2cb431db3bdf0899b
7
+ data.tar.gz: 0ad080c29057474750237d9d6d6e1f3f6ddf1bf912a06afe190f9f11f73c9cbf58339a0215ce9f71e433d1a76d060c239a6fa6a2fb58e171dc1cf243c6f50096
data/README.md CHANGED
@@ -207,11 +207,23 @@ Get all fields that are able to be used in an organization
207
207
  PipedrivePUT::OrganizationFields.getAllOrganizationFields
208
208
  ```
209
209
 
210
-
211
210
  NOTE: This searches for everything in Pipedrive (deal, organization, user, state, product, etc.)
212
211
 
213
212
  I hope to add additional support to break this down at a later time.
214
213
 
214
+ Add Organization Field
215
+ ```ruby
216
+ PipedrivePUT::OrganizationFields.addOrganizationField(< Field Name>, <Field Type>, { <options> } )
217
+ ```
218
+
219
+ Field types: " ", varchar, varchar_auto, text, double, monetary, date, set, enum, user, org, people, phone, time, timerange, daterange
220
+
221
+ NOTE: The field type for Pipedrive is required. However, it can also be left as empty.
222
+
223
+ Example:
224
+ ```ruby
225
+ PipedrivePUT::OrganizationFields.addOrganizationField("Total Ordered in September", "monetary", {:important_flag => 'true'})
226
+ ```
215
227
 
216
228
  Data is returned in JSON format.
217
229
 
@@ -12,35 +12,34 @@ require 'rest-client'
12
12
 
13
13
  #Get All Organizations from Pipedrive
14
14
  def self.getAllOrgs()
15
-
16
- @start = 0
17
-
18
- table = Array.new
19
- @more_items = true
20
- tablesize = 0
21
- while @more_items == true do
22
- count = 0
23
- #puts @more_items
24
- @base = URI.parse('https://api.pipedrive.com/v1/organizations?start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s)
25
- #puts @base
26
- @content = Net::HTTP.get(@base)
27
- @parsed = JSON.parse(@content)
28
-
29
- while count < @parsed["data"].size
30
- #table.push(@parsed["data"][count])
31
- table[tablesize] = @parsed["data"][count]
32
- count = count +1
33
- tablesize = tablesize + 1
34
- end
15
+ @start = 0
16
+
17
+ table = Array.new
18
+ @more_items = true
19
+ tablesize = 0
20
+ while @more_items == true do
21
+ count = 0
22
+ #puts @more_items
23
+ @base = URI.parse('https://api.pipedrive.com/v1/organizations?start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s)
24
+ #puts @base
25
+ @content = Net::HTTP.get(@base)
26
+ @parsed = JSON.parse(@content)
35
27
 
36
- @pagination = @parsed['additional_data']['pagination']
37
- @more_items = @pagination['more_items_in_collection']
38
- #puts @more_items
39
- @start = @pagination['next_start']
40
- #puts @start
41
- end
28
+ while count < @parsed["data"].size
29
+ #table.push(@parsed["data"][count])
30
+ table[tablesize] = @parsed["data"][count]
31
+ count = count +1
32
+ tablesize = tablesize + 1
33
+ end
42
34
 
43
- return table
35
+ @pagination = @parsed['additional_data']['pagination']
36
+ @more_items = @pagination['more_items_in_collection']
37
+ #puts @more_items
38
+ @start = @pagination['next_start']
39
+ #puts @start
40
+ end
41
+
42
+ return table
44
43
  end
45
44
 
46
45
 
@@ -62,85 +61,108 @@ require 'rest-client'
62
61
 
63
62
  #Return data of a specific Organization
64
63
  def self.getOrganization(id)
65
- @base = 'https://api.pipedrive.com/v1/organizations/' + id.to_s + '?api_token=' + @@key.to_s
66
- @content = open(@base.to_s).read
67
- @parsed = JSON.parse(@content)
68
- return @parsed
64
+ begin
65
+ @base = 'https://api.pipedrive.com/v1/organizations/' + id.to_s + '?api_token=' + @@key.to_s
66
+ @content = open(@base.to_s).read
67
+ @parsed = JSON.parse(@content)
68
+ if @parsed["data"].nil?
69
+ return "Organization does not exist in pipedrive"
70
+ else
71
+ return @parsed
72
+ end
73
+ rescue OpenURI::HTTPError => error
74
+ response = error.io
75
+ return response.status
76
+ end
69
77
  end
70
78
 
71
79
  #Find Organization by name
72
80
  def self.findOrganizationByName(name)
73
- @start = 0
74
-
75
- table = Array.new
76
- @more_items = true
77
- tablesize = 0
81
+ begin
82
+ @start = 0
83
+
84
+ table = Array.new
85
+ @more_items = true
86
+ tablesize = 0
78
87
 
79
- while @more_items == true do
80
- count = 0
88
+ while @more_items == true do
89
+ count = 0
81
90
 
82
- @base = URI.parse('https://api.pipedrive.com/v1/organizations/find?term=' + name+ '&start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s)
83
-
84
- #puts @base
91
+ @base = URI.parse('https://api.pipedrive.com/v1/organizations/find?term=' + name+ '&start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s)
92
+
93
+ #puts @base
85
94
 
86
- @content = open(@base.to_s).read
95
+ @content = open(@base.to_s).read
87
96
 
88
- #puts @content
97
+ #puts @content
89
98
 
90
- @parsed = JSON.parse(@content)
91
-
92
- while count < @parsed["data"].size
93
- #table.push(@parsed["data"][count])
94
- table[tablesize] = @parsed["data"][count]
95
- count = count +1
96
- tablesize = tablesize + 1
97
-
98
- end
99
- @pagination = @parsed['additional_data']['pagination']
100
- @more_items = @pagination['more_items_in_collection']
101
- #puts @more_items
102
- @start = @pagination['next_start']
103
- #puts @start
104
- end
105
- return table
99
+ @parsed = JSON.parse(@content)
100
+
101
+ while count < @parsed["data"].size
102
+ #table.push(@parsed["data"][count])
103
+ table[tablesize] = @parsed["data"][count]
104
+ count = count +1
105
+ tablesize = tablesize + 1
106
+
107
+ end
108
+ @pagination = @parsed['additional_data']['pagination']
109
+ @more_items = @pagination['more_items_in_collection']
110
+ #puts @more_items
111
+ @start = @pagination['next_start']
112
+ #puts @start
113
+ end
114
+ return table
115
+
116
+ rescue OpenURI::HTTPError => error
117
+ response = error.io
118
+ return response.status
119
+ end
106
120
  end
107
121
 
108
122
 
109
123
  #Get Persons of an Organization
110
124
  def self.getPersonsOfOrganization(id)
111
- @start = 0
112
-
113
- table = Array.new
114
- @more_items = true
115
- tablesize = 0
125
+ begin
126
+ @start = 0
127
+
128
+ table = Array.new
129
+ @more_items = true
130
+ tablesize = 0
116
131
 
117
- while @more_items == true do
118
- count = 0
132
+ while @more_items == true do
133
+ count = 0
119
134
 
120
- @base = 'https://api.pipedrive.com/v1/organizations/' + id.to_s + '/persons?&start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s
121
-
122
- @content = open(@base.to_s).read
123
- @parsed = JSON.parse(@content)
135
+ @base = 'https://api.pipedrive.com/v1/organizations/' + id.to_s + '/persons?&start=' + @start.to_s + '&limit=500&api_token=' + @@key.to_s
136
+
137
+ @content = open(@base.to_s).read
124
138
 
125
- if @parsed["data"].nil?
126
- return "Organization does not have any Person associated with it"
127
- else
128
-
129
- while count < @parsed["data"].size
130
- #table.push(@parsed["data"][count])
131
- table[tablesize] = @parsed["data"][count]
132
- count = count +1
133
- tablesize = tablesize + 1
139
+ puts @content
140
+
141
+ @parsed = JSON.parse(@content)
142
+
143
+ if @parsed["data"].nil?
144
+ return "Organization does not have any Person associated with that id"
145
+ else
134
146
 
135
- end
136
- @pagination = @parsed['additional_data']['pagination']
137
- @more_items = @pagination['more_items_in_collection']
138
- #puts @more_items
139
- @start = @pagination['next_start']
140
- #puts @start
141
- end
142
- end
143
- return table
147
+ while count < @parsed["data"].size
148
+ #table.push(@parsed["data"][count])
149
+ table[tablesize] = @parsed["data"][count]
150
+ count = count +1
151
+ tablesize = tablesize + 1
152
+
153
+ end
154
+ @pagination = @parsed['additional_data']['pagination']
155
+ @more_items = @pagination['more_items_in_collection']
156
+ #puts @more_items
157
+ @start = @pagination['next_start']
158
+ #puts @start
159
+ end
160
+ end
161
+ return table
162
+ rescue OpenURI::HTTPError => error
163
+ response = error.io
164
+ return response.status
165
+ end
144
166
  end
145
167
 
146
168
  #Update an Organization
@@ -165,4 +187,4 @@ require 'rest-client'
165
187
  end
166
188
 
167
189
  end
168
- end
190
+ end
@@ -33,8 +33,24 @@ include PipedrivePUT
33
33
  end
34
34
 
35
35
  return table
36
- end
36
+ end
37
+
38
+ #Add an organization Field
39
+ def self.addOrganizationField(fieldName, fieldType, options = {})
40
+ #args.each_with_index{ |arg, i| puts "#{i+1}. #{arg}" }
41
+
42
+ @url = 'https://api.pipedrive.com/v1/organizationFields?api_token=' + @@key.to_s
43
+
44
+ if (!options.nil?)
37
45
 
46
+ options.merge!(:name => fieldName.to_s)
47
+ options.merge!(:field_type => fieldType.to_s)
48
+
49
+ #puts options
50
+
51
+ response = HTTParty.post(@url.to_s, :body => options.to_json, :headers => {'Content-type' => 'application/json'})
52
+ end
53
+ end
38
54
 
39
55
  end
40
56
  end
@@ -1,3 +1,3 @@
1
1
  module PipedrivePUT
2
- VERSION = "1.1.25"
2
+ VERSION = "1.1.27"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: PipedrivePUT
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.25
4
+ version: 1.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - JakePens71
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-20 00:00:00.000000000 Z
11
+ date: 2015-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler