wordnik 0.4.7 → 4.06.00
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile.lock +4 -4
- data/Rakefile +90 -66
- data/api_docs/account.json +1 -1
- data/api_docs/corpus.json +1 -1
- data/api_docs/document.json +1 -1
- data/api_docs/partners.json +1 -1
- data/api_docs/system.json +1 -1
- data/api_docs/tag.json +1 -1
- data/api_docs/user.json +1 -1
- data/api_docs/users.json +1 -1
- data/api_docs/word.json +1 -1
- data/api_docs/wordList.json +1 -1
- data/api_docs/wordLists.json +1 -1
- data/api_docs/words.json +1 -1
- data/lib/wordnik.rb +24 -31
- data/lib/wordnik/configuration.rb +14 -1
- data/lib/wordnik/operation.rb +3 -3
- data/lib/wordnik/operation_parameter.rb +1 -1
- data/lib/wordnik/resource_modules/account.rb +313 -57
- data/lib/wordnik/resource_modules/system.rb +159 -6
- data/lib/wordnik/resource_modules/user.rb +1012 -88
- data/lib/wordnik/resource_modules/word.rb +1087 -134
- data/lib/wordnik/resource_modules/word_list.rb +423 -60
- data/lib/wordnik/resource_modules/word_lists.rb +89 -18
- data/lib/wordnik/resource_modules/words.rb +313 -150
- data/lib/wordnik/response.rb +11 -3
- data/lib/wordnik/version.rb +2 -1
- data/spec/operation_parameter_spec.rb +16 -12
- data/spec/operation_spec.rb +10 -0
- data/spec/resource_spec.rb +1 -56
- data/spec/response_spec.rb +22 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/wordnik_spec.rb +2 -2
- data/wordnik.gemspec +5 -1
- metadata +28 -23
- data/USAGE.md +0 -298
- data/api_docs/wordoftheday.json +0 -1
@@ -3,12 +3,66 @@
|
|
3
3
|
|
4
4
|
module WordListMethods
|
5
5
|
|
6
|
+
# Updates an existing WordList
|
7
|
+
#
|
8
|
+
def update_word_list(wordListId, body, *args)
|
9
|
+
http_method = :put
|
10
|
+
path = '/wordList/{wordListId}'
|
11
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
12
|
+
|
13
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
14
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
15
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
16
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
17
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
18
|
+
last_arg ||= {}
|
19
|
+
|
20
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
21
|
+
# that we want the request itself back, not the response body
|
22
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
23
|
+
request_only = true
|
24
|
+
last_arg.delete(:request_only)
|
25
|
+
end
|
26
|
+
|
27
|
+
params = last_arg
|
28
|
+
body ||= {}
|
29
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
30
|
+
request_only ? request : request.response.body
|
31
|
+
end
|
32
|
+
|
33
|
+
# Deletes an existing WordList
|
34
|
+
#
|
35
|
+
def delete_word_list(wordListId, *args)
|
36
|
+
http_method = :delete
|
37
|
+
path = '/wordList/{wordListId}'
|
38
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
39
|
+
|
40
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
41
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
42
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
43
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
44
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
45
|
+
last_arg ||= {}
|
46
|
+
|
47
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
48
|
+
# that we want the request itself back, not the response body
|
49
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
50
|
+
request_only = true
|
51
|
+
last_arg.delete(:request_only)
|
52
|
+
end
|
53
|
+
|
54
|
+
params = last_arg
|
55
|
+
body ||= {}
|
56
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
57
|
+
request_only ? request : request.response.body
|
58
|
+
end
|
59
|
+
|
6
60
|
# Fetches a WordList by ID
|
7
61
|
#
|
8
62
|
def get_word_list_by_id(wordListId, *args)
|
9
63
|
http_method = :get
|
10
64
|
path = '/wordList/{wordListId}'
|
11
|
-
path.sub!('{wordListId}', wordListId)
|
65
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
12
66
|
|
13
67
|
# Ruby turns all key-value arguments at the end into a single hash
|
14
68
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -24,14 +78,35 @@ module WordListMethods
|
|
24
78
|
last_arg.delete(:request_only)
|
25
79
|
end
|
26
80
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
81
|
+
params = last_arg
|
82
|
+
body ||= {}
|
83
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
84
|
+
request_only ? request : request.response.body
|
85
|
+
end
|
86
|
+
|
87
|
+
# Adds words to a WordList
|
88
|
+
#
|
89
|
+
def add_words_to_word_list(wordListId, body, *args)
|
90
|
+
http_method = :post
|
91
|
+
path = '/wordList/{wordListId}/words'
|
92
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
93
|
+
|
94
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
95
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
96
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
97
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
98
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
99
|
+
last_arg ||= {}
|
100
|
+
|
101
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
102
|
+
# that we want the request itself back, not the response body
|
103
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
104
|
+
request_only = true
|
105
|
+
last_arg.delete(:request_only)
|
33
106
|
end
|
34
107
|
|
108
|
+
params = last_arg
|
109
|
+
body ||= {}
|
35
110
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
36
111
|
request_only ? request : request.response.body
|
37
112
|
end
|
@@ -41,7 +116,7 @@ module WordListMethods
|
|
41
116
|
def get_word_list_words(wordListId, *args)
|
42
117
|
http_method = :get
|
43
118
|
path = '/wordList/{wordListId}/words'
|
44
|
-
path.sub!('{wordListId}', wordListId)
|
119
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
45
120
|
|
46
121
|
# Ruby turns all key-value arguments at the end into a single hash
|
47
122
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -57,31 +132,71 @@ module WordListMethods
|
|
57
132
|
last_arg.delete(:request_only)
|
58
133
|
end
|
59
134
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
135
|
+
params = last_arg
|
136
|
+
body ||= {}
|
137
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
138
|
+
request_only ? request : request.response.body
|
139
|
+
end
|
140
|
+
|
141
|
+
# Returns information about API parameters
|
142
|
+
#
|
143
|
+
def get_help(*args)
|
144
|
+
http_method = :get
|
145
|
+
path = '/wordList'
|
146
|
+
|
147
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
148
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
149
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
150
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
151
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
152
|
+
last_arg ||= {}
|
153
|
+
|
154
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
155
|
+
# that we want the request itself back, not the response body
|
156
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
157
|
+
request_only = true
|
158
|
+
last_arg.delete(:request_only)
|
66
159
|
end
|
67
160
|
|
161
|
+
params = last_arg
|
162
|
+
body ||= {}
|
68
163
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
69
|
-
|
70
|
-
|
71
|
-
operation = self.operations.find_by_nickname('get_word_list_words')
|
72
|
-
response_value_type = operation.response.value_type
|
73
|
-
|
74
|
-
Massage(response.body)
|
75
|
-
|
76
|
-
|
164
|
+
request_only ? request : request.response.body
|
77
165
|
end
|
78
166
|
|
79
|
-
#
|
167
|
+
# Checks to see if a WordList has been favorited for a user
|
168
|
+
#
|
169
|
+
def is_favorite_word_list(wordListId, *args)
|
170
|
+
http_method = :get
|
171
|
+
path = '/wordList/{wordListId}/isFavorite'
|
172
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
173
|
+
|
174
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
175
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
176
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
177
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
178
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
179
|
+
last_arg ||= {}
|
180
|
+
|
181
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
182
|
+
# that we want the request itself back, not the response body
|
183
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
184
|
+
request_only = true
|
185
|
+
last_arg.delete(:request_only)
|
186
|
+
end
|
187
|
+
|
188
|
+
params = last_arg
|
189
|
+
body ||= {}
|
190
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
191
|
+
request_only ? request : request.response.body
|
192
|
+
end
|
193
|
+
|
194
|
+
# Favorites a WordList for a User
|
80
195
|
#
|
81
|
-
def
|
196
|
+
def favorite_word_list(wordListId, *args)
|
82
197
|
http_method = :post
|
83
|
-
path = '/wordList/{wordListId}/
|
84
|
-
path.sub!('{wordListId}', wordListId)
|
198
|
+
path = '/wordList/{wordListId}/favorite'
|
199
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
85
200
|
|
86
201
|
# Ruby turns all key-value arguments at the end into a single hash
|
87
202
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -97,24 +212,207 @@ module WordListMethods
|
|
97
212
|
last_arg.delete(:request_only)
|
98
213
|
end
|
99
214
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
215
|
+
params = last_arg
|
216
|
+
body ||= {}
|
217
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
218
|
+
request_only ? request : request.response.body
|
219
|
+
end
|
220
|
+
|
221
|
+
# Unfavorites a WordList for a User
|
222
|
+
#
|
223
|
+
def un_favorite_word_list(wordListId, *args)
|
224
|
+
http_method = :delete
|
225
|
+
path = '/wordList/{wordListId}/favorite'
|
226
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
227
|
+
|
228
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
229
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
230
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
231
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
232
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
233
|
+
last_arg ||= {}
|
234
|
+
|
235
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
236
|
+
# that we want the request itself back, not the response body
|
237
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
238
|
+
request_only = true
|
239
|
+
last_arg.delete(:request_only)
|
106
240
|
end
|
107
241
|
|
242
|
+
params = last_arg
|
243
|
+
body ||= {}
|
108
244
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
109
245
|
request_only ? request : request.response.body
|
110
246
|
end
|
111
247
|
|
112
|
-
#
|
248
|
+
# Fetches Tags on a WordList
|
249
|
+
#
|
250
|
+
def get_word_list_tags(wordListId, *args)
|
251
|
+
http_method = :get
|
252
|
+
path = '/wordList/{wordListId}/tags'
|
253
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
254
|
+
|
255
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
256
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
257
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
258
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
259
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
260
|
+
last_arg ||= {}
|
261
|
+
|
262
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
263
|
+
# that we want the request itself back, not the response body
|
264
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
265
|
+
request_only = true
|
266
|
+
last_arg.delete(:request_only)
|
267
|
+
end
|
268
|
+
|
269
|
+
params = last_arg
|
270
|
+
body ||= {}
|
271
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
272
|
+
request_only ? request : request.response.body
|
273
|
+
end
|
274
|
+
|
275
|
+
# Fetches Tag count on a WordList
|
276
|
+
#
|
277
|
+
def get_word_list_tag_count(wordListId, *args)
|
278
|
+
http_method = :get
|
279
|
+
path = '/wordList/{wordListId}/tagCount'
|
280
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
281
|
+
|
282
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
283
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
284
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
285
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
286
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
287
|
+
last_arg ||= {}
|
288
|
+
|
289
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
290
|
+
# that we want the request itself back, not the response body
|
291
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
292
|
+
request_only = true
|
293
|
+
last_arg.delete(:request_only)
|
294
|
+
end
|
295
|
+
|
296
|
+
params = last_arg
|
297
|
+
body ||= {}
|
298
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
299
|
+
request_only ? request : request.response.body
|
300
|
+
end
|
301
|
+
|
302
|
+
# Adds a Tag on a WordList
|
303
|
+
#
|
304
|
+
def add_word_list_tag(wordListId, *args)
|
305
|
+
http_method = :post
|
306
|
+
path = '/wordList/{wordListId}/tag'
|
307
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
308
|
+
|
309
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
310
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
311
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
312
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
313
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
314
|
+
last_arg ||= {}
|
315
|
+
|
316
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
317
|
+
# that we want the request itself back, not the response body
|
318
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
319
|
+
request_only = true
|
320
|
+
last_arg.delete(:request_only)
|
321
|
+
end
|
322
|
+
|
323
|
+
params = last_arg
|
324
|
+
body ||= {}
|
325
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
326
|
+
request_only ? request : request.response.body
|
327
|
+
end
|
328
|
+
|
329
|
+
# Adds a Tag on a WordList
|
330
|
+
#
|
331
|
+
def delete_word_list_tag(wordListId, *args)
|
332
|
+
http_method = :delete
|
333
|
+
path = '/wordList/{wordListId}/tag'
|
334
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
335
|
+
|
336
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
337
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
338
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
339
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
340
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
341
|
+
last_arg ||= {}
|
342
|
+
|
343
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
344
|
+
# that we want the request itself back, not the response body
|
345
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
346
|
+
request_only = true
|
347
|
+
last_arg.delete(:request_only)
|
348
|
+
end
|
349
|
+
|
350
|
+
params = last_arg
|
351
|
+
body ||= {}
|
352
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
353
|
+
request_only ? request : request.response.body
|
354
|
+
end
|
355
|
+
|
356
|
+
# Fetches comments on a WordList
|
357
|
+
#
|
358
|
+
def get_word_list_comments(wordListId, *args)
|
359
|
+
http_method = :get
|
360
|
+
path = '/wordList/{wordListId}/comments'
|
361
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
362
|
+
|
363
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
364
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
365
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
366
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
367
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
368
|
+
last_arg ||= {}
|
369
|
+
|
370
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
371
|
+
# that we want the request itself back, not the response body
|
372
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
373
|
+
request_only = true
|
374
|
+
last_arg.delete(:request_only)
|
375
|
+
end
|
376
|
+
|
377
|
+
params = last_arg
|
378
|
+
body ||= {}
|
379
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
380
|
+
request_only ? request : request.response.body
|
381
|
+
end
|
382
|
+
|
383
|
+
# Adds a Comment on a WordList
|
113
384
|
#
|
114
|
-
def
|
385
|
+
def add_comment_to_word_list(wordListId, body, *args)
|
386
|
+
http_method = :post
|
387
|
+
path = '/wordList/{wordListId}/comment'
|
388
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
389
|
+
|
390
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
391
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
392
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
393
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
394
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
395
|
+
last_arg ||= {}
|
396
|
+
|
397
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
398
|
+
# that we want the request itself back, not the response body
|
399
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
400
|
+
request_only = true
|
401
|
+
last_arg.delete(:request_only)
|
402
|
+
end
|
403
|
+
|
404
|
+
params = last_arg
|
405
|
+
body ||= {}
|
406
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
407
|
+
request_only ? request : request.response.body
|
408
|
+
end
|
409
|
+
|
410
|
+
# Updates a Comment on a WordList
|
411
|
+
#
|
412
|
+
def update_comment_on_word_list(wordListId, body, *args)
|
115
413
|
http_method = :put
|
116
|
-
path = '/wordList/{wordListId}'
|
117
|
-
path.sub!('{wordListId}', wordListId)
|
414
|
+
path = '/wordList/{wordListId}/comment'
|
415
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
118
416
|
|
119
417
|
# Ruby turns all key-value arguments at the end into a single hash
|
120
418
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -130,24 +428,47 @@ module WordListMethods
|
|
130
428
|
last_arg.delete(:request_only)
|
131
429
|
end
|
132
430
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
431
|
+
params = last_arg
|
432
|
+
body ||= {}
|
433
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
434
|
+
request_only ? request : request.response.body
|
435
|
+
end
|
436
|
+
|
437
|
+
# Fetches a WordList comment by ID
|
438
|
+
#
|
439
|
+
def get_word_list_comment_by_id(wordListId, commentId, *args)
|
440
|
+
http_method = :get
|
441
|
+
path = '/wordList/{wordListId}/comment/{commentId}'
|
442
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
443
|
+
path.sub!('{commentId}', commentId.to_s)
|
444
|
+
|
445
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
446
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
447
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
448
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
449
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
450
|
+
last_arg ||= {}
|
451
|
+
|
452
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
453
|
+
# that we want the request itself back, not the response body
|
454
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
455
|
+
request_only = true
|
456
|
+
last_arg.delete(:request_only)
|
139
457
|
end
|
140
458
|
|
459
|
+
params = last_arg
|
460
|
+
body ||= {}
|
141
461
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
142
462
|
request_only ? request : request.response.body
|
143
463
|
end
|
144
464
|
|
145
|
-
# Deletes
|
465
|
+
# Deletes a WordList comment by ID
|
146
466
|
#
|
147
|
-
def
|
467
|
+
def delete_word_list_comment_by_id(wordListId, commentId, *args)
|
148
468
|
http_method = :delete
|
149
|
-
path = '/wordList/{wordListId}'
|
150
|
-
path.sub!('{wordListId}', wordListId)
|
469
|
+
path = '/wordList/{wordListId}/comment/{commentId}'
|
470
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
471
|
+
path.sub!('{commentId}', commentId.to_s)
|
151
472
|
|
152
473
|
# Ruby turns all key-value arguments at the end into a single hash
|
153
474
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -163,24 +484,45 @@ module WordListMethods
|
|
163
484
|
last_arg.delete(:request_only)
|
164
485
|
end
|
165
486
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
487
|
+
params = last_arg
|
488
|
+
body ||= {}
|
489
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
490
|
+
request_only ? request : request.response.body
|
491
|
+
end
|
492
|
+
|
493
|
+
# Fetches WordList Comment count
|
494
|
+
#
|
495
|
+
def get_word_list_comment_count(wordListId, *args)
|
496
|
+
http_method = :get
|
497
|
+
path = '/wordList/{wordListId}/commentCount'
|
498
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
499
|
+
|
500
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
501
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
502
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
503
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
504
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
505
|
+
last_arg ||= {}
|
506
|
+
|
507
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
508
|
+
# that we want the request itself back, not the response body
|
509
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
510
|
+
request_only = true
|
511
|
+
last_arg.delete(:request_only)
|
172
512
|
end
|
173
513
|
|
514
|
+
params = last_arg
|
515
|
+
body ||= {}
|
174
516
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
175
517
|
request_only ? request : request.response.body
|
176
518
|
end
|
177
519
|
|
178
520
|
# Removes words from a WordList
|
179
521
|
#
|
180
|
-
def delete_words_from_word_list(wordListId, *args)
|
522
|
+
def delete_words_from_word_list(wordListId, body, *args)
|
181
523
|
http_method = :post
|
182
524
|
path = '/wordList/{wordListId}/deleteWords'
|
183
|
-
path.sub!('{wordListId}', wordListId)
|
525
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
184
526
|
|
185
527
|
# Ruby turns all key-value arguments at the end into a single hash
|
186
528
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -196,14 +538,35 @@ module WordListMethods
|
|
196
538
|
last_arg.delete(:request_only)
|
197
539
|
end
|
198
540
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
541
|
+
params = last_arg
|
542
|
+
body ||= {}
|
543
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
544
|
+
request_only ? request : request.response.body
|
545
|
+
end
|
546
|
+
|
547
|
+
# Gets a count of Words in a WordList
|
548
|
+
#
|
549
|
+
def get_word_list_words_count(wordListId, *args)
|
550
|
+
http_method = :get
|
551
|
+
path = '/wordList/{wordListId}/wordsCount'
|
552
|
+
path.sub!('{wordListId}', wordListId.to_s)
|
553
|
+
|
554
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
555
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
556
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
557
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
558
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
559
|
+
last_arg ||= {}
|
560
|
+
|
561
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
562
|
+
# that we want the request itself back, not the response body
|
563
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
564
|
+
request_only = true
|
565
|
+
last_arg.delete(:request_only)
|
205
566
|
end
|
206
567
|
|
568
|
+
params = last_arg
|
569
|
+
body ||= {}
|
207
570
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
208
571
|
request_only ? request : request.response.body
|
209
572
|
end
|