nutshell-crm-api 0.1.0 → 0.1.1

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: b5e4313404f12a0dd297d7c8160a98189d204f4e
4
- data.tar.gz: d5a1e365173d1a0b3c6868969bf260ee2958704c
3
+ metadata.gz: 5e0228038f33b20fe1a110609be72a766b9d4587
4
+ data.tar.gz: 953c237a9988f95a130fdeaa3d515500678f4198
5
5
  SHA512:
6
- metadata.gz: 070a8da9f109823ad981b20af96426b5992ca2d70ad89e6101fdc32f032a03742009f26210dc021b1a7ffb2e701e00395ea65e2ea3206fc11feb2c94fc5bc4f2
7
- data.tar.gz: 2621cb2fae04b5ea4a1331663fa9dc725ca10304de0ab1ad9c2aea93475c7ca7ee18641674e623673fe01c3c4395580a9b172de1ba96e4d3b694dbb6a1538d00
6
+ metadata.gz: 41271a0a34b3952a05ae3a3c200ed71530804488a9dc028b794ab0195b7edfab876227c8101f14edba8923266d7ebc76ce8960ee7f6526b8dcfefe9017ec5623
7
+ data.tar.gz: 578fd1243e94c84a98a1d24b8d8424a1ac6864b99104adc273bd099f70d3680410e0c84b5c793733f69e7f89aedac2748c6938336c782aa55134efa9f083443f
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ spec/task.rb
5
6
 
6
7
  *.rbc
7
8
  .config
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Christian Juth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,16 +1,22 @@
1
- # Nutshell CRM [![Build Status](https://secure.travis-ci.org/mshafrir/nutshell-crm.png)](http://travis-ci.org/mshafrir/nutshell-crm)
1
+ # Attribute
2
2
 
3
- Author: [mshafrir@gmail.com](mailto:mshafrir@gmail.com)
3
+ This gem is a fork of `nutshell-crm` created by [mshafrir@gmail.com](mailto:mshafrir@gmail.com).
4
4
 
5
5
  ## Description ##
6
6
 
7
7
  Nutshell Crm is a Ruby wrapper for the Nutshell Crm API.
8
8
 
9
- [Nutshell API Reference](http://www.nutshell.com/api/)
9
+ [Nutshell API Reference](https://www.nutshell.com/api/detail/class_core.html)
10
10
 
11
11
  ## Reference ##
12
12
 
13
- - {NutshellCrm::Client}
13
+ - {NutshellCrmAPI::Client}
14
+
15
+
16
+ ## Install ##
17
+
18
+ gem install nutshell-crm-api
19
+
14
20
 
15
21
 
16
22
  ## Install ##
@@ -26,382 +26,577 @@ module NutshellCrmAPI
26
26
  @api_key = api_key
27
27
  @stub_responses = nil
28
28
 
29
- result = exec_request(build_payload({:username => @username}), 'http://api.nutshell.com/v1/json')
29
+ params ={username: @username}
30
+ payload = build_payload(params)
31
+ result = exec_request(payload, 'http://api.nutshell.com/v1/json')
30
32
  api_host = result['api']
31
33
  @api_url = "https://#{api_host}/api/v1/json"
32
34
  end
33
35
 
34
- # Saves the given e-mail message.
35
- #
36
- # @param [String] e-mail in RFC 822 format
37
- def add_email(email_string)
38
- exec_request build_payload({:emailString => email_string})
36
+ # For testing.
37
+ def add(num1, num2)
38
+ params = {num1: num1, num2: num2}
39
+ payload = build_payload(params)
40
+ exec_request(payload)
39
41
  end
40
42
 
41
- # Gets all of the custom fields available for Leads, Accounts and Contacts, including appropriate meta-information.
42
- #
43
- # @return [Object] the custom fields available for Leads, Accounts and Contacts, including appropriate meta-information
44
- def describe_custom_fields
45
- exec_request build_payload
43
+ # Delete an account.
44
+ def delete_account(account_id, rev)
45
+ params = {accountId: account_id, rev: rev}
46
+ payload = build_payload params
47
+ exec_request(payload)
48
+ end
49
+
50
+ # Delete an activity.
51
+ def delete_activity(activity_id, rev)
52
+ params = {activityId: activity_id, rev: rev}
53
+ payload = build_payload params
54
+ exec_request(payload)
55
+ end
56
+
57
+ # Delete a contact.
58
+ def delete_contact(contact_id, rev)
59
+ params = {contactId: contact_id, rev: rev}
60
+ payload = build_payload params
61
+ exec_request(payload)
62
+ end
63
+
64
+ # Delete a lead.
65
+ def delete_lead(lead_id, rev)
66
+ params = {leadId: activity_id, rev: rev}
67
+ payload = build_payload params
68
+ exec_request(payload)
69
+ end
70
+
71
+ # Deletes the given note.
72
+ def delete_note(note_id, rev)
73
+ params = {noteId: activity_id, rev: rev}
74
+ payload = build_payload params
75
+ exec_request(payload)
76
+ end
77
+
78
+ # Delete a product.
79
+ def delete_product(product_id, rev)
80
+ params = {productId: product_id, rev: rev}
81
+ payload = build_payload params
82
+ exec_request(payload)
83
+ end
84
+
85
+ # Delete a task.
86
+ def delete_task(task_id, rev)
87
+ params = {taskId: task_id, rev: rev}
88
+ payload = build_payload params
89
+ exec_request(payload)
90
+ end
91
+
92
+ # Delete a team.
93
+ def delete_team(team_id, rev)
94
+ params = {teamId: team_id, rev: rev}
95
+ payload = build_payload params
96
+ exec_request(payload)
97
+ end
98
+
99
+ # Delete a user.
100
+ def delete_user(user_id, rev)
101
+ params = {userId: user_id, rev: rev}
102
+ payload = build_payload params
103
+ exec_request(payload)
46
104
  end
47
105
 
48
106
  # Edit an account.
49
- #
50
- # @param [Integer] account_id
51
- # account ID to edit
52
- # @param [String] rev
53
- # the revision
54
- # @param [Hash] account
55
- # updated account information
56
107
  def edit_account(account_id, rev, account)
57
- exec_request build_payload({:accountId => account_id, :rev => rev, :account => account})
108
+ params = {accountId: account_id, rev: rev, account: account}
109
+ payload = build_payload params
110
+ exec_request(payload)
58
111
  end
59
112
 
60
113
  # Edit an activity.
61
114
  def edit_activity(activity_id, rev, activity)
62
- exec_request build_payload({:activityId => activity_id, :rev => rev, :activity => activity})
115
+ params = {activityId: activity_id, rev: rev, activity: activity}
116
+ payload = build_payload(params)
117
+ exec_request(payload)
63
118
  end
64
119
 
65
120
  # Edit a contact.
66
121
  def edit_contact(contact_id, rev, contact)
67
- exec_request build_payload({:contactId => contact_id, :rev => rev, :contact => contact})
122
+ params = {contactId: contact_id, rev: rev, contact: contact}
123
+ payload = build_payload(params)
124
+ exec_request(payload)
68
125
  end
69
126
 
70
127
  # Edit a lead.
71
128
  def edit_lead(lead_id, rev, lead)
72
- exec_request build_payload({:leadId => lead_id, :rev => rev, :lead => lead})
129
+ params = {leadId: lead_id, rev: rev, lead: lead}
130
+ payload = build_payload(params)
131
+ exec_request(payload)
132
+ end
133
+
134
+ # Edits the given note (note that notes can
135
+ # only be edited for 24 hours by the note author)
136
+ def edit_note(note_id, rev, note)
137
+ params = {noteId: note_id, rev: rev, note: note}
138
+ payload = build_payload(params)
139
+ exec_request(payload)
140
+ end
141
+
142
+ # Edit a product.
143
+ def edit_product(product_id, rev, product)
144
+ params = {productId: product_id, rev: rev, product: product}
145
+ payload = build_payload(params)
146
+ exec_request(payload)
73
147
  end
74
148
 
75
149
  # Update a process step.
76
150
  def edit_step(step_id, rev, step)
77
- exec_request build_payload({:stepId => step_id, :rev => rev, :step => step})
151
+ params = {stepId: step_id, rev: rev, step: step}
152
+ payload = build_payload(params)
153
+ exec_request(payload)
78
154
  end
79
155
 
80
156
  # Edit a task.
81
157
  def edit_task(task_id, rev, task)
82
- exec_request build_payload({:taskId => task_id, :rev => rev, :task => task})
158
+ params = {taskId: task_id, rev: rev, task: task}
159
+ payload = build_payload(params)
160
+ exec_request(payload)
161
+ end
162
+
163
+ # Edit a team.
164
+ def edit_team(team_id, rev, team)
165
+ params = {teamId: team_id, rev: rev, team: team}
166
+ payload = build_payload(params)
167
+ exec_request(payload)
83
168
  end
84
169
 
170
+ # Edit a user.
171
+ def edit_user(user_id, rev, user)
172
+ params = {userId: user_id, rev: rev, user: user}
173
+ payload = build_payload(params)
174
+ exec_request(payload)
175
+ end
176
+
177
+
85
178
  # Find accounts matching a specified query.
86
179
  def find_accounts(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil)
87
- params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses}
88
- payload = build_payload params
180
+ params = {query: query, orderBy: order_by, orderDirection: order_direction, limit: limit, page: page, stubResponses: stub_responses}
181
+ payload = build_payload(params)
89
182
  exec_request(payload)
90
183
  end
91
184
 
92
185
  # Get all active account types (to be applied to an account).
93
186
  def find_account_types(order_by = nil, order_direction = nil, limit = nil, page = nil)
94
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
95
- payload = build_payload params
187
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
188
+ payload = build_payload(params)
96
189
  exec_request(payload)
97
190
  end
98
191
 
99
192
  # Find activities matching a specified query.
100
193
  def find_activities(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil)
101
- params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses}
102
- payload = build_payload params
194
+ params = {query: query, orderBy: order_by, orderDirection: order_direction, limit: limit, page: page, stubResponses: stub_responses}
195
+ payload = build_payload(params)
103
196
  exec_request(payload)
104
197
  end
105
198
 
106
199
  # Get all active activity types.
107
200
  def find_activity_types(order_by = nil, order_direction = nil, limit = nil, page = nil)
108
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
109
- payload = build_payload params
201
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
202
+ payload = build_payload(params)
110
203
  exec_request(payload)
111
204
  end
112
205
 
113
- # Get all active Competitors.
206
+ # List available and running backups.
207
+ def find_backups
208
+ exec_request build_payload
209
+ end
210
+
211
+ # Returns stubs for all active Competitors.
114
212
  def find_competitors(order_by = nil, order_direction = nil, limit = nil, page = nil)
115
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
116
- payload = build_payload params
213
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
214
+ payload = build_payload(params)
117
215
  exec_request(payload)
118
216
  end
119
217
 
120
218
  # Find contacts associated with a specified account or lead.
121
219
  def find_contacts(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil)
122
- params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses}
123
- payload = build_payload params
220
+ params = {query: query, orderBy: order_by, orderDirection: order_direction, limit: limit, page: page, stubResponses: stub_responses}
221
+ payload = build_payload(params)
124
222
  exec_request(payload)
125
223
  end
126
224
 
127
- # Get all active Delays (seen in Step responses in availableDelayIds).
225
+ # Gets all of the custom fields available for Leads, Accounts
226
+ # and Contacts, including appropriate meta-information.
227
+ def find_custom_fields
228
+ exec_request(build_payload)
229
+ end
230
+
231
+ # Returns stubs for all active Delays (seen in Step
232
+ # responses in availableDelayIds)
128
233
  def find_delays(order_by = nil, order_direction = nil, limit = nil, page = nil)
129
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
130
- payload = build_payload params
234
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
235
+ payload = build_payload(params)
131
236
  exec_request(payload)
132
237
  end
133
238
 
134
- # Get all active Industries (to be applied to an account)
239
+ # Returns stubs for all active Industries (to be applied to an account)
135
240
  def find_industries(order_by = nil, order_direction = nil, limit = nil, page = nil)
136
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
137
- payload = build_payload params
241
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
242
+ payload = build_payload(params)
138
243
  exec_request(payload)
139
244
  end
140
245
 
141
246
  # Get all possible outcomes for a closed lead.
142
247
  def find_lead_outcomes(order_by = nil, order_direction = nil, limit = nil, page = nil)
143
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
144
- payload = build_payload params, 'findLead_Outcomes'
248
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
249
+ payload = build_payload(params, 'findLead_Outcomes')
145
250
  exec_request(payload)
146
251
  end
147
252
 
148
253
  # Find leads matching a specified query.
149
254
  def find_leads(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil)
150
- params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses}
151
- payload = build_payload params
255
+ params = {query: query, orderBy: order_by, orderDirection: order_direction, limit: limit, page: page, stubResponses: stub_responses}
256
+ payload = build_payload(params)
152
257
  exec_request(payload)
153
258
  end
154
259
 
155
- # Get all active markets.
260
+ # Returns stubs for all active Markets.
156
261
  def find_markets(order_by = nil, order_direction = nil, limit = nil, page = nil)
157
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
158
- payload = build_payload params
262
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
263
+ payload = build_payload(params)
159
264
  exec_request(payload)
160
265
  end
161
266
 
162
267
  # Get all active milestones.
163
268
  def find_milestones(order_by = nil, order_direction = nil, limit = nil, page = nil)
164
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
165
- payload = build_payload params
269
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
270
+ payload = build_payload(params)
166
271
  exec_request(payload)
167
272
  end
168
273
 
169
- # Get all active Origins.
274
+ # Returns stubs for all active Origins.
170
275
  def find_origins(order_by = nil, order_direction = nil, limit = nil, page = nil)
171
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
172
- payload = build_payload params
276
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
277
+ payload = build_payload(params)
278
+ exec_request(payload)
279
+ end
280
+
281
+ # Finds all processes associated with an entity.
282
+ def find_processes(query)
283
+ params = {query: query}
284
+ payload = build_payload(params)
173
285
  exec_request(payload)
174
286
  end
175
287
 
176
288
  # Get all active products.
177
289
  def find_products(order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil)
178
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses}
179
- payload = build_payload params
290
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page, stubResponses: stub_responses}
291
+ payload = build_payload(params)
180
292
  exec_request(payload)
181
293
  end
182
294
 
183
295
  # Return all publicly-visible settings.
184
296
  def find_settings(order_by = nil, order_direction = nil, limit = nil, page = nil)
185
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
186
- payload = build_payload params
297
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
298
+ payload = build_payload(params)
187
299
  exec_request(payload)
188
300
  end
189
301
 
190
- # Get all active Sources.
302
+ # Returns stubs for all active Sources.
191
303
  def find_sources(order_by = nil, order_direction = nil, limit = nil, page = nil)
192
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
193
- payload = build_payload params
304
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
305
+ payload = build_payload(params)
194
306
  exec_request(payload)
195
307
  end
196
308
 
197
309
  # Get all active tags.
198
310
  def find_tags
199
- exec_request build_payload
311
+ exec_request(build_payload)
200
312
  end
201
313
 
202
314
  # Returns an array containing tasks for the given query.
203
315
  def find_tasks(query)
204
- params = {:query => query}
205
- payload = build_payload params
316
+ params = {query: query}
317
+ payload = build_payload(params)
206
318
  exec_request(payload)
207
319
  end
208
320
 
209
321
  # Get all active Teams.
210
322
  def find_teams(order_by = nil, order_direction = nil, limit = nil, page = nil)
211
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
212
- payload = build_payload params
323
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
324
+ payload = build_payload(params)
213
325
  exec_request(payload)
214
326
  end
215
327
 
216
328
  # Get all territories.
217
329
  def find_territories(order_by = nil, order_direction = nil, limit = nil, page = nil)
218
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
219
- payload = build_payload params
330
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
331
+ payload = build_payload(params)
220
332
  exec_request(payload)
221
333
  end
222
334
 
223
335
  # Find timeline events (Activities, Emails and Notes) for an Entity.
224
336
  def find_timeline(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil)
225
- params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses}
226
- payload = build_payload params
337
+ params = {query: query, orderBy: order_by, orderDirection: order_direction, limit: limit, page: page, stubResponses: stub_responses}
338
+ payload = build_payload(params)
227
339
  exec_request(payload)
228
340
  end
229
341
 
230
- # Get all active Users.
342
+ # Find users matching a specified query.
231
343
  def find_users(order_by = nil, order_direction = nil, limit = nil, page = nil)
232
- params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page}
233
- payload = build_payload params
344
+ params = {orderBy: order_by, orderDirection: order_direction, limit: limit, page: page}
345
+ payload = build_payload(params)
234
346
  exec_request(payload)
235
347
  end
236
348
 
237
349
  # Get the specified Account.
238
350
  def get_account(account_id, rev = nil)
239
- params = {:accountId => account_id, :rev => rev}
351
+ params = {accountId: account_id, rev: rev}
240
352
  exec_request build_payload(params)
241
353
  end
242
354
 
243
355
  # Get the specified Activity.
244
356
  def get_activity(activity_id, rev = nil)
245
- params = {:activityId => activity_id, :rev => rev}
357
+ params = {activityId: activity_id, rev: rev}
246
358
  exec_request build_payload(params)
247
359
  end
248
360
 
249
361
  # Returns graph data and overview information for various sales analytics reports.
250
362
  def getAnalyticsReport(report_type, period, filter_entity = nil, options = nil)
251
- params = {:reportType => report_type, :period => period, :filter => filter_entity, :options => options}
363
+ params = {reportType: report_type, period: period, filter: filter_entity, options: options}
252
364
  exec_request build_payload(params)
253
365
  end
254
366
 
255
367
  # Get the specified Contact.
256
368
  def get_contact(contact_id, rev = nil)
257
- params = {:contactId => contact_id, :rev => rev}
369
+ params = {contactId: contact_id, rev: rev}
258
370
  exec_request build_payload(params)
259
371
  end
260
372
 
261
373
  # Get the specified Email.
262
374
  def get_email(email_id, rev = nil)
263
- params = {:emailId => email_id, :rev => rev}
375
+ params = {emailId: email_id, rev: rev}
264
376
  exec_request build_payload(params)
265
377
  end
266
378
 
267
- # Get the specified lead.
379
+ # Get the specified Lead.
268
380
  def get_lead(lead_id, rev = nil)
269
- params = {:leadId => lead_id, :rev => rev}
381
+ params = {leadId: lead_id, rev: rev}
270
382
  exec_request build_payload(params)
271
383
  end
272
384
 
273
- # Return all mobile-related settings in a simple key-value array.
274
- def get_mobile_settings
275
- exec_request build_payload
276
- end
277
-
278
385
  # Get the specified Note.
279
386
  def get_note(note_id, rev = nil)
280
- params = {:noteId => note_id, :rev => rev}
387
+ params = {noteId: note_id, rev: rev}
281
388
  exec_request build_payload(params)
282
389
  end
283
390
 
284
391
  # Get all information for a product (including full price list).
285
392
  def get_product(product_id, rev = nil)
286
- params = {:productId => product_id, :rev => rev}
393
+ params = {productId: product_id, rev: rev}
287
394
  exec_request build_payload(params)
288
395
  end
289
396
 
397
+ # Get the specified Task.
290
398
  def get_task(task_id, rev = nil)
291
- params = {:taskId => task_id, :rev => rev}
399
+ params = {taskId: task_id, rev: rev}
400
+ exec_request build_payload(params)
401
+ end
402
+
403
+ # Get the specified Team.
404
+ def get_task(team_id, rev = nil)
405
+ params = {teamId: team_id, rev: rev}
292
406
  exec_request build_payload(params)
293
407
  end
294
408
 
295
409
  # Gets the last-updated times of each of the provisioning bins.
296
410
  def get_update_times
297
- exec_request build_payload
411
+ exec_request(build_payload)
298
412
  end
299
413
 
300
414
  # Get all info about a user.
301
415
  def get_user(user_id = nil, rev = nil)
302
- params = {:userId => user_id, :rev => rev}
416
+ params = {userId: user_id, rev: rev}
303
417
  exec_request build_payload(params)
304
418
  end
305
419
 
420
+ # Return data related to authenticated Nutshell instance.
421
+ def instance_data
422
+ exec_request(build_payload)
423
+ end
424
+
306
425
  # Create a new account.
307
426
  def new_account(account)
308
- exec_request build_payload({:account => account})
427
+ params = {account: account}
428
+ payload = build_payload(params)
429
+ exec_request(payload)
309
430
  end
310
431
 
311
432
  # Create a new activity.
312
433
  def new_activity(activity)
313
- exec_request build_payload({:activity => activity})
434
+ params = {activity: activity}
435
+ payload = build_payload(params)
436
+ exec_request(payload)
437
+ end
438
+
439
+ # Initiate downloadable backup.
440
+ def new_backup
441
+ exec_request(build_payload)
314
442
  end
315
443
 
316
- # Create a new contact.
444
+ # Create a new Contact.
317
445
  def new_contact(contact)
318
- exec_request build_payload({:contact => contact})
446
+ params = {contact: contact}
447
+ payload = build_payload(params)
448
+ exec_request(payload)
449
+ end
450
+
451
+ # Saves the given e-mail message.
452
+ def new_email(emailString)
453
+ params = {emailString: emailString}
454
+ payload = build_payload(params)
455
+ exec_request(payload)
319
456
  end
320
457
 
321
458
  # Create a new Lead.
322
459
  def new_lead(lead)
323
- exec_request build_payload({:lead => lead})
460
+ params = {lead: lead}
461
+ payload = build_payload(params)
462
+ exec_request(payload)
324
463
  end
325
464
 
326
- # Create a new Lead.
465
+ # Adds the note to the given entity.
327
466
  def new_note(entity, note)
328
- exec_request build_payload({:entity => entity, :note => note})
467
+ params = {entity: entity, note: note}
468
+ payload = build_payload(params)
469
+ exec_request(payload)
470
+ end
471
+
472
+ # Create a new product.
473
+ def new_product(product)
474
+ params = {product: product}
475
+ payload = build_payload(params)
476
+ exec_request(payload)
477
+ end
478
+
479
+ # Given a source name, fetches an existing
480
+ # source or creates a new one if it does not exist.
481
+ def new_source(name)
482
+ params = {name: name}
483
+ payload = build_payload(params)
484
+ exec_request(payload)
329
485
  end
330
486
 
331
487
  # Create a new tag.
332
- #
333
- # @param [Hash] tag
334
- # See {Nut_Api_Render_Model_Tag}[http://www.nutshell.com/api/detail/class_nut___api___render___model___tag.html]
335
488
  def new_tag(tag)
336
- exec_request build_payload({:tag => tag})
489
+ params = {tag: tag}
490
+ payload = build_payload(params)
491
+ exec_request(payload)
337
492
  end
338
493
 
339
494
  # Create a new Task.
340
495
  def new_task(task)
341
- exec_request build_payload({:task => task})
496
+ params = {task: task}
497
+ payload = build_payload(params)
498
+ exec_request(payload)
499
+ end
500
+
501
+ # Create a new Team.
502
+ def new_team(team)
503
+ params = {team: team}
504
+ payload = build_payload(params)
505
+ exec_request(payload)
506
+ end
507
+
508
+ # Create a new User.
509
+ def new_user(user)
510
+ params = {user: user}
511
+ payload = build_payload(params)
512
+ exec_request(payload)
342
513
  end
343
514
 
344
515
  # Return a list of Account stubs matching a given search string.
345
516
  def search_accounts(query, limit = nil)
346
- exec_request build_payload({:string => query, :limit => limit})
517
+ params = {string: query, limit: limit}
518
+ payload = build_payload(params)
519
+ exec_request(payload)
520
+ end
521
+
522
+ # Return a list of stubs matching a given search string for
523
+ # all entities that could be participants in an Activity.
524
+ def search_activity_participants(query, limit = nil)
525
+ params = {string: query, limit: limit}
526
+ payload = build_payload(params)
527
+ exec_request(payload)
347
528
  end
348
529
 
349
530
  # Works just like searchUniversal, but only searches by email address.
350
531
  def search_by_email(email_address)
351
- exec_request build_payload({:emailAddressString => email_address})
532
+ params = {emailAddressString: email_address}
533
+ payload = build_payload(params)
534
+ exec_request(payload)
352
535
  end
353
536
 
354
537
  # Return a list of Competitor stubs matching a given search string.
355
538
  def search_competitors(query, limit = nil)
356
- exec_request build_payload({:string => query, :limit => limit})
539
+ params = {string: query, limit: limit}
540
+ payload = build_payload(params)
541
+ exec_request(payload)
357
542
  end
358
543
 
359
544
  # Return a list of Contact stubs matching a given search string.
360
545
  def search_contacts(query, limit = nil)
361
- exec_request build_payload({:string => query, :limit => limit})
546
+ params = {string: query, limit: limit}
547
+ payload = build_payload(params)
548
+ exec_request(payload)
362
549
  end
363
550
 
364
551
  # Return a list of Contact and User stubs matching a given search string.
365
552
  def search_contacts_and_users(query, limit = nil)
366
- exec_request build_payload({:string => query, :limit => limit})
553
+ params = {string: query, limit: limit}
554
+ payload = build_payload(params)
555
+ exec_request(payload)
367
556
  end
368
557
 
369
558
  # Return a list of Lead stubs matching a given search string.
370
559
  def search_leads(query, limit = nil)
371
- exec_request build_payload({:string => query, :limit => limit})
560
+ params = {string: query, limit: limit}
561
+ payload = build_payload(params)
562
+ exec_request(payload)
563
+ end
564
+
565
+ # Returns an array of mentionable entities matching the string,
566
+ # but excluding any that the client already knows about,
567
+ # as indicated by knownLocalResults.
568
+ def search_mentionable_entities(query, entityType, entityId, knownLocalEntities, limit = nil)
569
+ params = {string: query, entityType: entityType, entityId: entityId, knownLocalEntities: knownLocalEntities, limit: limit}
570
+ payload = build_payload(params)
571
+ exec_request(payload)
372
572
  end
373
573
 
374
574
  # Return a list of Product stubs matching a given search string.
375
575
  def search_products(query, limit = nil)
376
- exec_request build_payload({:string => query, :limit => limit})
576
+ params = {string: query, limit: limit}
577
+ payload = build_payload(params)
578
+ exec_request(payload)
377
579
  end
378
580
 
379
581
  # Return a list of Source stubs matching a given search string.
380
582
  def search_sources(query, limit = nil)
381
- exec_request build_payload({:string => query, :limit => limit})
583
+ params = {string: query, limit: limit}
584
+ payload = build_payload(params)
585
+ exec_request(payload)
382
586
  end
383
587
 
384
588
  # Return a list of Contact, Lead, and Account stubs matching a given search string.
385
589
  def search_universal(query)
386
- exec_request build_payload({:string => query})
590
+ params = {string: query}
591
+ payload = build_payload(params)
592
+ exec_request(payload)
387
593
  end
388
594
 
389
595
  # Return a list of User and Team stubs matching a given search string.
390
596
  def search_users_and_teams(query, limit = nil)
391
- exec_request build_payload({:string => query, :limit => limit})
392
- end
393
-
394
- # Delete an Activity
395
- def delete_activity(activity_id, rev)
396
- params = {:activityId => activity_id, :rev => rev}
397
- payload = build_payload params
398
- exec_request(payload)
399
- end
400
-
401
- def delete_task(task_id, rev)
402
- params = {:taskId => task_id, :rev => rev}
403
- payload = build_payload params
404
- exec_request(payload)
597
+ params = {string: query, limit: limit}
598
+ payload = build_payload(params)
599
+ exec_request(payload)
405
600
  end
406
601
 
407
602
 
@@ -427,7 +622,7 @@ module NutshellCrmAPI
427
622
  end
428
623
 
429
624
  # Create the payload
430
- payload = {:method => camelcase(method), :id => generate_request_id}
625
+ payload = {method: camelcase(method), id: generate_request_id}
431
626
 
432
627
  # Filter out keys with nil values.
433
628
  payload[:params] = params.reject {|k,v| v.nil?} unless params.nil?
@@ -447,9 +642,9 @@ module NutshellCrmAPI
447
642
  # Executes an arbitrary request.
448
643
  def exec_request(payload, override_url = nil)
449
644
  response = HTTParty.post(override_url.nil? ? @api_url : override_url,
450
- :basic_auth => {:username => @username, :password => @api_key},
451
- :body => payload,
452
- :query => {:output => :json}
645
+ basic_auth: {username: @username, password: @api_key},
646
+ body: payload,
647
+ query: {output: :json}
453
648
  )
454
649
 
455
650
  unless response['error'].nil?
@@ -462,6 +657,8 @@ module NutshellCrmAPI
462
657
  response['result']
463
658
  end
464
659
 
660
+ # Conbert method_name to camelcase so it can
661
+ # call the correct API function.
465
662
  def camelcase(method_name)
466
663
  parts = []
467
664
  method_name.split('_').each_with_index {|str, idx| parts << (idx == 0 ? str : str.capitalize)}
@@ -1,3 +1,3 @@
1
1
  module NutshellCrm
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutshell-crm-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Juth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -91,8 +91,8 @@ files:
91
91
  - ".rbenv-version"
92
92
  - ".rspec"
93
93
  - ".travis.yml"
94
- - CHANGELOG.md
95
94
  - Gemfile
95
+ - LICENSE.txt
96
96
  - README.md
97
97
  - Rakefile
98
98
  - lib/nutshell-crm-api.rb
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project: nutshell-crm-api
123
- rubygems_version: 2.4.6
123
+ rubygems_version: 2.4.8
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: A Ruby wrapper for Nutshell CRM's API
@@ -1,5 +0,0 @@
1
- ## v0.0.5
2
- ## v0.0.4
3
- ## v0.0.3
4
- ## v0.0.2
5
- ## v0.0.1