wordnik 0.4.7 → 4.06.00

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,11 +3,144 @@
3
3
 
4
4
  module SystemMethods
5
5
 
6
+ # Returns all defined ContentProviders.
7
+ #
8
+ def get_providers(*args)
9
+ http_method = :get
10
+ path = '/system/providers'
11
+
12
+ # Ruby turns all key-value arguments at the end into a single hash
13
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
14
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
15
+ last_arg = args.pop if args.last.is_a?(Hash)
16
+ last_arg = args.pop if args.last.is_a?(Array)
17
+ last_arg ||= {}
18
+
19
+ # Look for a kwarg called :request_only, whose presence indicates
20
+ # that we want the request itself back, not the response body
21
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
22
+ request_only = true
23
+ last_arg.delete(:request_only)
24
+ end
25
+
26
+ params = last_arg
27
+ body ||= {}
28
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
29
+ request_only ? request : request.response.body
30
+ end
31
+
32
+ # Returns information about API parameters
33
+ #
34
+ def get_help(*args)
35
+ http_method = :get
36
+ path = '/system'
37
+
38
+ # Ruby turns all key-value arguments at the end into a single hash
39
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
40
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
41
+ last_arg = args.pop if args.last.is_a?(Hash)
42
+ last_arg = args.pop if args.last.is_a?(Array)
43
+ last_arg ||= {}
44
+
45
+ # Look for a kwarg called :request_only, whose presence indicates
46
+ # that we want the request itself back, not the response body
47
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
48
+ request_only = true
49
+ last_arg.delete(:request_only)
50
+ end
51
+
52
+ params = last_arg
53
+ body ||= {}
54
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
55
+ request_only ? request : request.response.body
56
+ end
57
+
58
+ # Returns weighted terms related to the input word
59
+ #
60
+ def get_related_words(word, *args)
61
+ http_method = :get
62
+ path = '/system/{word}/related'
63
+ path.sub!('{word}', word.to_s)
64
+
65
+ # Ruby turns all key-value arguments at the end into a single hash
66
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
67
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
68
+ last_arg = args.pop if args.last.is_a?(Hash)
69
+ last_arg = args.pop if args.last.is_a?(Array)
70
+ last_arg ||= {}
71
+
72
+ # Look for a kwarg called :request_only, whose presence indicates
73
+ # that we want the request itself back, not the response body
74
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
75
+ request_only = true
76
+ last_arg.delete(:request_only)
77
+ end
78
+
79
+ params = last_arg
80
+ body ||= {}
81
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
82
+ request_only ? request : request.response.body
83
+ end
84
+
85
+ # Returns a word with attributes
86
+ #
87
+ def get_related_words(word, *args)
88
+ http_method = :get
89
+ path = '/system/{word}'
90
+ path.sub!('{word}', word.to_s)
91
+
92
+ # Ruby turns all key-value arguments at the end into a single hash
93
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
94
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
95
+ last_arg = args.pop if args.last.is_a?(Hash)
96
+ last_arg = args.pop if args.last.is_a?(Array)
97
+ last_arg ||= {}
98
+
99
+ # Look for a kwarg called :request_only, whose presence indicates
100
+ # that we want the request itself back, not the response body
101
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
102
+ request_only = true
103
+ last_arg.delete(:request_only)
104
+ end
105
+
106
+ params = last_arg
107
+ body ||= {}
108
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
109
+ request_only ? request : request.response.body
110
+ end
111
+
6
112
  # Returns a graph response for the supplied terms
7
113
  #
8
114
  def get_word_by_id(*args)
9
115
  http_method = :get
10
116
  path = '/system/graph'
117
+
118
+ # Ruby turns all key-value arguments at the end into a single hash
119
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
120
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
121
+ last_arg = args.pop if args.last.is_a?(Hash)
122
+ last_arg = args.pop if args.last.is_a?(Array)
123
+ last_arg ||= {}
124
+
125
+ # Look for a kwarg called :request_only, whose presence indicates
126
+ # that we want the request itself back, not the response body
127
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
128
+ request_only = true
129
+ last_arg.delete(:request_only)
130
+ end
131
+
132
+ params = last_arg
133
+ body ||= {}
134
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
135
+ request_only ? request : request.response.body
136
+ end
137
+
138
+ # Gets an Audio File ID for recording.
139
+ #
140
+ def get_audio_record_id(*args)
141
+ http_method = :get
142
+ path = '/system/audioRecordId'
143
+
11
144
  # Ruby turns all key-value arguments at the end into a single hash
12
145
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
13
146
  # becomes {:limit => 10, :part_of_speech => 'verb'}
@@ -22,14 +155,34 @@ module SystemMethods
22
155
  last_arg.delete(:request_only)
23
156
  end
24
157
 
25
- if [:post, :put].include?(http_method)
26
- params = nil
27
- body = last_arg
28
- else
29
- params = last_arg
30
- body = nil
158
+ params = last_arg
159
+ body ||= {}
160
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
161
+ request_only ? request : request.response.body
162
+ end
163
+
164
+ # Returns system-wide statistics for the platform.
165
+ #
166
+ def get_stats(*args)
167
+ http_method = :get
168
+ path = '/system/stats'
169
+
170
+ # Ruby turns all key-value arguments at the end into a single hash
171
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
172
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
173
+ last_arg = args.pop if args.last.is_a?(Hash)
174
+ last_arg = args.pop if args.last.is_a?(Array)
175
+ last_arg ||= {}
176
+
177
+ # Look for a kwarg called :request_only, whose presence indicates
178
+ # that we want the request itself back, not the response body
179
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
180
+ request_only = true
181
+ last_arg.delete(:request_only)
31
182
  end
32
183
 
184
+ params = last_arg
185
+ body ||= {}
33
186
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
34
187
  request_only ? request : request.response.body
35
188
  end
@@ -3,14 +3,12 @@
3
3
 
4
4
  module UserMethods
5
5
 
6
- # Returns the WordOfTheDay for a given user on a given date
6
+ # Returns a user's WordOfTheDayList
7
7
  #
8
- def get_word_of_the_day_by_date(username, date, *args)
8
+ def get_word_of_the_day_list(username, *args)
9
9
  http_method = :get
10
- path = '/user/{username}/wordOfTheDay/{date}'
11
- path.sub!('{username}', username)
12
-
13
- path.sub!('{date}', date)
10
+ path = '/user/{username}/wordOfTheDayList'
11
+ path.sub!('{username}', username.to_s)
14
12
 
15
13
  # Ruby turns all key-value arguments at the end into a single hash
16
14
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
@@ -26,24 +24,46 @@ module UserMethods
26
24
  last_arg.delete(:request_only)
27
25
  end
28
26
 
29
- if [:post, :put].include?(http_method)
30
- params = nil
31
- body = last_arg
32
- else
33
- params = last_arg
34
- body = nil
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
+ # Creates a WordOfTheDayList
34
+ # A user can have only one WordOfTheDayList.
35
+ #
36
+ def create_word_of_the_day_list(username, body, *args)
37
+ http_method = :post
38
+ path = '/user/{username}/wordOfTheDayList'
39
+ path.sub!('{username}', username.to_s)
40
+
41
+ # Ruby turns all key-value arguments at the end into a single hash
42
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
43
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
44
+ last_arg = args.pop if args.last.is_a?(Hash)
45
+ last_arg = args.pop if args.last.is_a?(Array)
46
+ last_arg ||= {}
47
+
48
+ # Look for a kwarg called :request_only, whose presence indicates
49
+ # that we want the request itself back, not the response body
50
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
51
+ request_only = true
52
+ last_arg.delete(:request_only)
35
53
  end
36
54
 
55
+ params = last_arg
56
+ body ||= {}
37
57
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
38
58
  request_only ? request : request.response.body
39
59
  end
40
60
 
41
- # Returns a user's WordOfTheDayList
61
+ # Updates a user's WordOfTheDayList
42
62
  #
43
- def get_word_of_the_day_list(username, *args)
44
- http_method = :get
63
+ def update_word_of_the_day_list(username, body, *args)
64
+ http_method = :put
45
65
  path = '/user/{username}/wordOfTheDayList'
46
- path.sub!('{username}', username)
66
+ path.sub!('{username}', username.to_s)
47
67
 
48
68
  # Ruby turns all key-value arguments at the end into a single hash
49
69
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
@@ -59,24 +79,47 @@ module UserMethods
59
79
  last_arg.delete(:request_only)
60
80
  end
61
81
 
62
- if [:post, :put].include?(http_method)
63
- params = nil
64
- body = last_arg
65
- else
66
- params = last_arg
67
- body = nil
82
+ params = last_arg
83
+ body ||= {}
84
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
85
+ request_only ? request : request.response.body
86
+ end
87
+
88
+ # Deletes a user's WordOfTheDayList
89
+ #
90
+ def update_word_of_the_day_list(username, permalink, *args)
91
+ http_method = :delete
92
+ path = '/user/{username}/wordOfTheDayList/{permalink}'
93
+ path.sub!('{username}', username.to_s)
94
+ path.sub!('{permalink}', permalink.to_s)
95
+
96
+ # Ruby turns all key-value arguments at the end into a single hash
97
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
98
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
99
+ last_arg = args.pop if args.last.is_a?(Hash)
100
+ last_arg = args.pop if args.last.is_a?(Array)
101
+ last_arg ||= {}
102
+
103
+ # Look for a kwarg called :request_only, whose presence indicates
104
+ # that we want the request itself back, not the response body
105
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
106
+ request_only = true
107
+ last_arg.delete(:request_only)
68
108
  end
69
109
 
110
+ params = last_arg
111
+ body ||= {}
70
112
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
71
113
  request_only ? request : request.response.body
72
114
  end
73
115
 
74
- # Updates a user's WordOfTheDayList
116
+ # Adds a WordOfTheDay to a user's WordOfTheDayList
75
117
  #
76
- def update_word_of_the_day_list(username, *args)
118
+ def update_item_in_word_of_the_day_list(username, permalink, body, *args)
77
119
  http_method = :put
78
- path = '/user/{username}/wordOfTheDayList'
79
- path.sub!('{username}', username)
120
+ path = '/user/{username}/wordOfTheDayList/{permalink}'
121
+ path.sub!('{username}', username.to_s)
122
+ path.sub!('{permalink}', permalink.to_s)
80
123
 
81
124
  # Ruby turns all key-value arguments at the end into a single hash
82
125
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
@@ -92,25 +135,45 @@ module UserMethods
92
135
  last_arg.delete(:request_only)
93
136
  end
94
137
 
95
- if [:post, :put].include?(http_method)
96
- params = nil
97
- body = last_arg
98
- else
99
- params = last_arg
100
- body = nil
138
+ params = last_arg
139
+ body ||= {}
140
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
141
+ request_only ? request : request.response.body
142
+ end
143
+
144
+ # Returns a UserProfile
145
+ #
146
+ def get_user_profile(username, *args)
147
+ http_method = :get
148
+ path = '/user/{username}/profile'
149
+ path.sub!('{username}', username.to_s)
150
+
151
+ # Ruby turns all key-value arguments at the end into a single hash
152
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
153
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
154
+ last_arg = args.pop if args.last.is_a?(Hash)
155
+ last_arg = args.pop if args.last.is_a?(Array)
156
+ last_arg ||= {}
157
+
158
+ # Look for a kwarg called :request_only, whose presence indicates
159
+ # that we want the request itself back, not the response body
160
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
161
+ request_only = true
162
+ last_arg.delete(:request_only)
101
163
  end
102
164
 
165
+ params = last_arg
166
+ body ||= {}
103
167
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
104
168
  request_only ? request : request.response.body
105
169
  end
106
170
 
107
- # Creates a WordOfTheDayList
108
- # A user can have only one WordOfTheDayList.
171
+ # Updates a UserProfile
109
172
  #
110
- def create_word_of_the_day_list(username, *args)
111
- http_method = :post
112
- path = '/user/{username}/wordOfTheDayList'
113
- path.sub!('{username}', username)
173
+ def update_user_profile(username, body, *args)
174
+ http_method = :put
175
+ path = '/user/{username}/profile'
176
+ path.sub!('{username}', username.to_s)
114
177
 
115
178
  # Ruby turns all key-value arguments at the end into a single hash
116
179
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
@@ -126,26 +189,45 @@ module UserMethods
126
189
  last_arg.delete(:request_only)
127
190
  end
128
191
 
129
- if [:post, :put].include?(http_method)
130
- params = nil
131
- body = last_arg
132
- else
133
- params = last_arg
134
- body = nil
192
+ params = last_arg
193
+ body ||= {}
194
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
195
+ request_only ? request : request.response.body
196
+ end
197
+
198
+ # Returns a user's tracking info
199
+ #
200
+ def get_user_tracking_info(username, *args)
201
+ http_method = :get
202
+ path = '/user/{username}/trackingInfo'
203
+ path.sub!('{username}', username.to_s)
204
+
205
+ # Ruby turns all key-value arguments at the end into a single hash
206
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
207
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
208
+ last_arg = args.pop if args.last.is_a?(Hash)
209
+ last_arg = args.pop if args.last.is_a?(Array)
210
+ last_arg ||= {}
211
+
212
+ # Look for a kwarg called :request_only, whose presence indicates
213
+ # that we want the request itself back, not the response body
214
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
215
+ request_only = true
216
+ last_arg.delete(:request_only)
135
217
  end
136
218
 
219
+ params = last_arg
220
+ body ||= {}
137
221
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
138
222
  request_only ? request : request.response.body
139
223
  end
140
224
 
141
- # Adds a WordOfTheDay to a user's WordOfTheDayList
225
+ # Updates a User
142
226
  #
143
- def update_item_in_word_of_the_day_list(username, permalink, *args)
227
+ def update_user(username, body, *args)
144
228
  http_method = :put
145
- path = '/user/{username}/wordOfTheDayList/{permalink}'
146
- path.sub!('{username}', username)
147
-
148
- path.sub!('{permalink}', permalink)
229
+ path = '/user/{username}'
230
+ path.sub!('{username}', username.to_s)
149
231
 
150
232
  # Ruby turns all key-value arguments at the end into a single hash
151
233
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
@@ -161,26 +243,45 @@ module UserMethods
161
243
  last_arg.delete(:request_only)
162
244
  end
163
245
 
164
- if [:post, :put].include?(http_method)
165
- params = nil
166
- body = last_arg
167
- else
168
- params = last_arg
169
- body = nil
246
+ params = last_arg
247
+ body ||= {}
248
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
249
+ request_only ? request : request.response.body
250
+ end
251
+
252
+ # Fetches a User
253
+ #
254
+ def get_user(username, *args)
255
+ http_method = :get
256
+ path = '/user/{username}'
257
+ path.sub!('{username}', username.to_s)
258
+
259
+ # Ruby turns all key-value arguments at the end into a single hash
260
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
261
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
262
+ last_arg = args.pop if args.last.is_a?(Hash)
263
+ last_arg = args.pop if args.last.is_a?(Array)
264
+ last_arg ||= {}
265
+
266
+ # Look for a kwarg called :request_only, whose presence indicates
267
+ # that we want the request itself back, not the response body
268
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
269
+ request_only = true
270
+ last_arg.delete(:request_only)
170
271
  end
171
272
 
273
+ params = last_arg
274
+ body ||= {}
172
275
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
173
276
  request_only ? request : request.response.body
174
277
  end
175
278
 
176
- # Deletes a user's WordOfTheDayList
279
+ # Deletes a User
177
280
  #
178
- def update_word_of_the_day_list(username, permalink, *args)
281
+ def delete_user(username, *args)
179
282
  http_method = :delete
180
- path = '/user/{username}/wordOfTheDayList/{permalink}'
181
- path.sub!('{username}', username)
182
-
183
- path.sub!('{permalink}', permalink)
283
+ path = '/user/{username}'
284
+ path.sub!('{username}', username.to_s)
184
285
 
185
286
  # Ruby turns all key-value arguments at the end into a single hash
186
287
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
@@ -196,14 +297,36 @@ module UserMethods
196
297
  last_arg.delete(:request_only)
197
298
  end
198
299
 
199
- if [:post, :put].include?(http_method)
200
- params = nil
201
- body = last_arg
202
- else
203
- params = last_arg
204
- body = nil
300
+ params = last_arg
301
+ body ||= {}
302
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
303
+ request_only ? request : request.response.body
304
+ end
305
+
306
+ # Adds an item to a user's WordOfTheDayList
307
+ #
308
+ def add_word_to_word_of_the_day_list(username, permalink, body, *args)
309
+ http_method = :put
310
+ path = '/user/{username}/wordOfTheDayList/{permalink}/add'
311
+ path.sub!('{username}', username.to_s)
312
+ path.sub!('{permalink}', permalink.to_s)
313
+
314
+ # Ruby turns all key-value arguments at the end into a single hash
315
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
316
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
317
+ last_arg = args.pop if args.last.is_a?(Hash)
318
+ last_arg = args.pop if args.last.is_a?(Array)
319
+ last_arg ||= {}
320
+
321
+ # Look for a kwarg called :request_only, whose presence indicates
322
+ # that we want the request itself back, not the response body
323
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
324
+ request_only = true
325
+ last_arg.delete(:request_only)
205
326
  end
206
327
 
328
+ params = last_arg
329
+ body ||= {}
207
330
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
208
331
  request_only ? request : request.response.body
209
332
  end
@@ -213,11 +336,37 @@ module UserMethods
213
336
  def delete_word_from_word_of_the_day_list(username, permalink, wordToDelete, *args)
214
337
  http_method = :delete
215
338
  path = '/user/{username}/wordOfTheDayList/{permalink}/{wordToDelete}'
216
- path.sub!('{username}', username)
339
+ path.sub!('{username}', username.to_s)
340
+ path.sub!('{permalink}', permalink.to_s)
341
+ path.sub!('{wordToDelete}', wordToDelete.to_s)
342
+
343
+ # Ruby turns all key-value arguments at the end into a single hash
344
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
345
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
346
+ last_arg = args.pop if args.last.is_a?(Hash)
347
+ last_arg = args.pop if args.last.is_a?(Array)
348
+ last_arg ||= {}
349
+
350
+ # Look for a kwarg called :request_only, whose presence indicates
351
+ # that we want the request itself back, not the response body
352
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
353
+ request_only = true
354
+ last_arg.delete(:request_only)
355
+ end
217
356
 
218
- path.sub!('{permalink}', permalink)
357
+ params = last_arg
358
+ body ||= {}
359
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
360
+ request_only ? request : request.response.body
361
+ end
219
362
 
220
- path.sub!('{wordToDelete}', wordToDelete)
363
+ # Returns the WordOfTheDay for a given user on a given date
364
+ #
365
+ def get_word_of_the_day_by_date(username, date, *args)
366
+ http_method = :get
367
+ path = '/user/{username}/wordOfTheDay/{date}'
368
+ path.sub!('{username}', username.to_s)
369
+ path.sub!('{date}', date.to_s)
221
370
 
222
371
  # Ruby turns all key-value arguments at the end into a single hash
223
372
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
@@ -233,26 +382,127 @@ module UserMethods
233
382
  last_arg.delete(:request_only)
234
383
  end
235
384
 
236
- if [:post, :put].include?(http_method)
237
- params = nil
238
- body = last_arg
239
- else
240
- params = last_arg
241
- body = nil
385
+ params = last_arg
386
+ body ||= {}
387
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
388
+ request_only ? request : request.response.body
389
+ end
390
+
391
+ # Gets WordLists for a User.
392
+ #
393
+ def get_user_word_lists(username, *args)
394
+ http_method = :get
395
+ path = '/user/{username}/wordLists'
396
+ path.sub!('{username}', username.to_s)
397
+
398
+ # Ruby turns all key-value arguments at the end into a single hash
399
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
400
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
401
+ last_arg = args.pop if args.last.is_a?(Hash)
402
+ last_arg = args.pop if args.last.is_a?(Array)
403
+ last_arg ||= {}
404
+
405
+ # Look for a kwarg called :request_only, whose presence indicates
406
+ # that we want the request itself back, not the response body
407
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
408
+ request_only = true
409
+ last_arg.delete(:request_only)
242
410
  end
243
411
 
412
+ params = last_arg
413
+ body ||= {}
244
414
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
245
415
  request_only ? request : request.response.body
246
416
  end
247
417
 
248
- # Adds an item to a user's WordOfTheDayList
418
+ # Gets the count of WordLists for a User.
249
419
  #
250
- def add_word_to_word_of_the_day_list(username, permalink, *args)
420
+ def get_user_word_list_count(username, *args)
421
+ http_method = :get
422
+ path = '/user/{username}/wordListsCount'
423
+ path.sub!('{username}', username.to_s)
424
+
425
+ # Ruby turns all key-value arguments at the end into a single hash
426
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
427
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
428
+ last_arg = args.pop if args.last.is_a?(Hash)
429
+ last_arg = args.pop if args.last.is_a?(Array)
430
+ last_arg ||= {}
431
+
432
+ # Look for a kwarg called :request_only, whose presence indicates
433
+ # that we want the request itself back, not the response body
434
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
435
+ request_only = true
436
+ last_arg.delete(:request_only)
437
+ end
438
+
439
+ params = last_arg
440
+ body ||= {}
441
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
442
+ request_only ? request : request.response.body
443
+ end
444
+
445
+ # Returns a user's settings
446
+ #
447
+ def get_user_settings(username, *args)
448
+ http_method = :get
449
+ path = '/user/{username}/settings'
450
+ path.sub!('{username}', username.to_s)
451
+
452
+ # Ruby turns all key-value arguments at the end into a single hash
453
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
454
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
455
+ last_arg = args.pop if args.last.is_a?(Hash)
456
+ last_arg = args.pop if args.last.is_a?(Array)
457
+ last_arg ||= {}
458
+
459
+ # Look for a kwarg called :request_only, whose presence indicates
460
+ # that we want the request itself back, not the response body
461
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
462
+ request_only = true
463
+ last_arg.delete(:request_only)
464
+ end
465
+
466
+ params = last_arg
467
+ body ||= {}
468
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
469
+ request_only ? request : request.response.body
470
+ end
471
+
472
+ # Updates a user's settings
473
+ #
474
+ def update_user_settings(username, body, *args)
251
475
  http_method = :put
252
- path = '/user/{username}/wordOfTheDayList/{permalink}/add'
253
- path.sub!('{username}', username)
476
+ path = '/user/{username}/settings'
477
+ path.sub!('{username}', username.to_s)
478
+
479
+ # Ruby turns all key-value arguments at the end into a single hash
480
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
481
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
482
+ last_arg = args.pop if args.last.is_a?(Hash)
483
+ last_arg = args.pop if args.last.is_a?(Array)
484
+ last_arg ||= {}
485
+
486
+ # Look for a kwarg called :request_only, whose presence indicates
487
+ # that we want the request itself back, not the response body
488
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
489
+ request_only = true
490
+ last_arg.delete(:request_only)
491
+ end
492
+
493
+ params = last_arg
494
+ body ||= {}
495
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
496
+ request_only ? request : request.response.body
497
+ end
254
498
 
255
- path.sub!('{permalink}', permalink)
499
+ # Returns the API key for the specified user
500
+ # Use the super user API key for getting this information or auth token of the user who is requesting the API key
501
+ #
502
+ def get_api_key_for_user(username, *args)
503
+ http_method = :get
504
+ path = '/user/{username}/apiKey'
505
+ path.sub!('{username}', username.to_s)
256
506
 
257
507
  # Ruby turns all key-value arguments at the end into a single hash
258
508
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
@@ -268,14 +518,688 @@ module UserMethods
268
518
  last_arg.delete(:request_only)
269
519
  end
270
520
 
271
- if [:post, :put].include?(http_method)
272
- params = nil
273
- body = last_arg
274
- else
275
- params = last_arg
276
- body = nil
521
+ params = last_arg
522
+ body ||= {}
523
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
524
+ request_only ? request : request.response.body
525
+ end
526
+
527
+ # Adds a Comment on a User
528
+ #
529
+ def comment_on_user(username, body, *args)
530
+ http_method = :post
531
+ path = '/user/{username}/comment'
532
+ path.sub!('{username}', username.to_s)
533
+
534
+ # Ruby turns all key-value arguments at the end into a single hash
535
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
536
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
537
+ last_arg = args.pop if args.last.is_a?(Hash)
538
+ last_arg = args.pop if args.last.is_a?(Array)
539
+ last_arg ||= {}
540
+
541
+ # Look for a kwarg called :request_only, whose presence indicates
542
+ # that we want the request itself back, not the response body
543
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
544
+ request_only = true
545
+ last_arg.delete(:request_only)
546
+ end
547
+
548
+ params = last_arg
549
+ body ||= {}
550
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
551
+ request_only ? request : request.response.body
552
+ end
553
+
554
+ # Updates a Comment on a User
555
+ #
556
+ def update_comment_on_user(username, body, *args)
557
+ http_method = :put
558
+ path = '/user/{username}/comment'
559
+ path.sub!('{username}', username.to_s)
560
+
561
+ # Ruby turns all key-value arguments at the end into a single hash
562
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
563
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
564
+ last_arg = args.pop if args.last.is_a?(Hash)
565
+ last_arg = args.pop if args.last.is_a?(Array)
566
+ last_arg ||= {}
567
+
568
+ # Look for a kwarg called :request_only, whose presence indicates
569
+ # that we want the request itself back, not the response body
570
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
571
+ request_only = true
572
+ last_arg.delete(:request_only)
573
+ end
574
+
575
+ params = last_arg
576
+ body ||= {}
577
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
578
+ request_only ? request : request.response.body
579
+ end
580
+
581
+ # Deletes a Comment on a User
582
+ #
583
+ def delete_comment_on_user(username, commentId, *args)
584
+ http_method = :delete
585
+ path = '/user/{username}/comment/{commentId}'
586
+ path.sub!('{username}', username.to_s)
587
+ path.sub!('{commentId}', commentId.to_s)
588
+
589
+ # Ruby turns all key-value arguments at the end into a single hash
590
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
591
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
592
+ last_arg = args.pop if args.last.is_a?(Hash)
593
+ last_arg = args.pop if args.last.is_a?(Array)
594
+ last_arg ||= {}
595
+
596
+ # Look for a kwarg called :request_only, whose presence indicates
597
+ # that we want the request itself back, not the response body
598
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
599
+ request_only = true
600
+ last_arg.delete(:request_only)
601
+ end
602
+
603
+ params = last_arg
604
+ body ||= {}
605
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
606
+ request_only ? request : request.response.body
607
+ end
608
+
609
+ # Fetches a comment by ID
610
+ #
611
+ def get_comment_on_user_by_id(username, commentId, *args)
612
+ http_method = :get
613
+ path = '/user/{username}/comment/{commentId}'
614
+ path.sub!('{username}', username.to_s)
615
+ path.sub!('{commentId}', commentId.to_s)
616
+
617
+ # Ruby turns all key-value arguments at the end into a single hash
618
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
619
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
620
+ last_arg = args.pop if args.last.is_a?(Hash)
621
+ last_arg = args.pop if args.last.is_a?(Array)
622
+ last_arg ||= {}
623
+
624
+ # Look for a kwarg called :request_only, whose presence indicates
625
+ # that we want the request itself back, not the response body
626
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
627
+ request_only = true
628
+ last_arg.delete(:request_only)
629
+ end
630
+
631
+ params = last_arg
632
+ body ||= {}
633
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
634
+ request_only ? request : request.response.body
635
+ end
636
+
637
+ # Returns a count of Comments on a user
638
+ #
639
+ def get_comments_on_user_count(username, *args)
640
+ http_method = :get
641
+ path = '/user/{username}/commentsOnCount'
642
+ path.sub!('{username}', username.to_s)
643
+
644
+ # Ruby turns all key-value arguments at the end into a single hash
645
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
646
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
647
+ last_arg = args.pop if args.last.is_a?(Hash)
648
+ last_arg = args.pop if args.last.is_a?(Array)
649
+ last_arg ||= {}
650
+
651
+ # Look for a kwarg called :request_only, whose presence indicates
652
+ # that we want the request itself back, not the response body
653
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
654
+ request_only = true
655
+ last_arg.delete(:request_only)
656
+ end
657
+
658
+ params = last_arg
659
+ body ||= {}
660
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
661
+ request_only ? request : request.response.body
662
+ end
663
+
664
+ # Returns a count of Comments by a user
665
+ #
666
+ def get_comments_by_user_count(username, *args)
667
+ http_method = :get
668
+ path = '/user/{username}/commentsByCount'
669
+ path.sub!('{username}', username.to_s)
670
+
671
+ # Ruby turns all key-value arguments at the end into a single hash
672
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
673
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
674
+ last_arg = args.pop if args.last.is_a?(Hash)
675
+ last_arg = args.pop if args.last.is_a?(Array)
676
+ last_arg ||= {}
677
+
678
+ # Look for a kwarg called :request_only, whose presence indicates
679
+ # that we want the request itself back, not the response body
680
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
681
+ request_only = true
682
+ last_arg.delete(:request_only)
683
+ end
684
+
685
+ params = last_arg
686
+ body ||= {}
687
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
688
+ request_only ? request : request.response.body
689
+ end
690
+
691
+ # Returns Comments by a user
692
+ #
693
+ def get_comments_by_user(username, *args)
694
+ http_method = :get
695
+ path = '/user/{username}/commentsBy'
696
+ path.sub!('{username}', username.to_s)
697
+
698
+ # Ruby turns all key-value arguments at the end into a single hash
699
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
700
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
701
+ last_arg = args.pop if args.last.is_a?(Hash)
702
+ last_arg = args.pop if args.last.is_a?(Array)
703
+ last_arg ||= {}
704
+
705
+ # Look for a kwarg called :request_only, whose presence indicates
706
+ # that we want the request itself back, not the response body
707
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
708
+ request_only = true
709
+ last_arg.delete(:request_only)
710
+ end
711
+
712
+ params = last_arg
713
+ body ||= {}
714
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
715
+ request_only ? request : request.response.body
716
+ end
717
+
718
+ # Returns Comments on a user
719
+ #
720
+ def get_comments_on_user(username, *args)
721
+ http_method = :get
722
+ path = '/user/{username}/commentsOnUser'
723
+ path.sub!('{username}', username.to_s)
724
+
725
+ # Ruby turns all key-value arguments at the end into a single hash
726
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
727
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
728
+ last_arg = args.pop if args.last.is_a?(Hash)
729
+ last_arg = args.pop if args.last.is_a?(Array)
730
+ last_arg ||= {}
731
+
732
+ # Look for a kwarg called :request_only, whose presence indicates
733
+ # that we want the request itself back, not the response body
734
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
735
+ request_only = true
736
+ last_arg.delete(:request_only)
737
+ end
738
+
739
+ params = last_arg
740
+ body ||= {}
741
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
742
+ request_only ? request : request.response.body
743
+ end
744
+
745
+ # Returns UgcSummary info a user
746
+ #
747
+ def get_ugc_summary_for_user(username, *args)
748
+ http_method = :get
749
+ path = '/user/{username}/ugcSummary'
750
+ path.sub!('{username}', username.to_s)
751
+
752
+ # Ruby turns all key-value arguments at the end into a single hash
753
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
754
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
755
+ last_arg = args.pop if args.last.is_a?(Hash)
756
+ last_arg = args.pop if args.last.is_a?(Array)
757
+ last_arg ||= {}
758
+
759
+ # Look for a kwarg called :request_only, whose presence indicates
760
+ # that we want the request itself back, not the response body
761
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
762
+ request_only = true
763
+ last_arg.delete(:request_only)
764
+ end
765
+
766
+ params = last_arg
767
+ body ||= {}
768
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
769
+ request_only ? request : request.response.body
770
+ end
771
+
772
+ # Fetches TagHistory for a User.
773
+ #
774
+ def get_user_tag_history(user, *args)
775
+ http_method = :get
776
+ path = '/user/{user}/tagHistory'
777
+ path.sub!('{user}', user.to_s)
778
+
779
+ # Ruby turns all key-value arguments at the end into a single hash
780
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
781
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
782
+ last_arg = args.pop if args.last.is_a?(Hash)
783
+ last_arg = args.pop if args.last.is_a?(Array)
784
+ last_arg ||= {}
785
+
786
+ # Look for a kwarg called :request_only, whose presence indicates
787
+ # that we want the request itself back, not the response body
788
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
789
+ request_only = true
790
+ last_arg.delete(:request_only)
791
+ end
792
+
793
+ params = last_arg
794
+ body ||= {}
795
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
796
+ request_only ? request : request.response.body
797
+ end
798
+
799
+ # Fetches Tags by a User.
800
+ #
801
+ def get_user_tags(user, *args)
802
+ http_method = :get
803
+ path = '/user/{user}/tags'
804
+ path.sub!('{user}', user.to_s)
805
+
806
+ # Ruby turns all key-value arguments at the end into a single hash
807
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
808
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
809
+ last_arg = args.pop if args.last.is_a?(Hash)
810
+ last_arg = args.pop if args.last.is_a?(Array)
811
+ last_arg ||= {}
812
+
813
+ # Look for a kwarg called :request_only, whose presence indicates
814
+ # that we want the request itself back, not the response body
815
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
816
+ request_only = true
817
+ last_arg.delete(:request_only)
818
+ end
819
+
820
+ params = last_arg
821
+ body ||= {}
822
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
823
+ request_only ? request : request.response.body
824
+ end
825
+
826
+ # Fetches the count of Tags created by a User.
827
+ #
828
+ def get_user_tag_count(user, *args)
829
+ http_method = :get
830
+ path = '/user/{user}/tagCount'
831
+ path.sub!('{user}', user.to_s)
832
+
833
+ # Ruby turns all key-value arguments at the end into a single hash
834
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
835
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
836
+ last_arg = args.pop if args.last.is_a?(Hash)
837
+ last_arg = args.pop if args.last.is_a?(Array)
838
+ last_arg ||= {}
839
+
840
+ # Look for a kwarg called :request_only, whose presence indicates
841
+ # that we want the request itself back, not the response body
842
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
843
+ request_only = true
844
+ last_arg.delete(:request_only)
845
+ end
846
+
847
+ params = last_arg
848
+ body ||= {}
849
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
850
+ request_only ? request : request.response.body
851
+ end
852
+
853
+ # Fetches all subscriptions for a User.
854
+ #
855
+ def get_subscriptions(user, *args)
856
+ http_method = :get
857
+ path = '/user/{user}/subscriptions'
858
+ path.sub!('{user}', user.to_s)
859
+
860
+ # Ruby turns all key-value arguments at the end into a single hash
861
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
862
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
863
+ last_arg = args.pop if args.last.is_a?(Hash)
864
+ last_arg = args.pop if args.last.is_a?(Array)
865
+ last_arg ||= {}
866
+
867
+ # Look for a kwarg called :request_only, whose presence indicates
868
+ # that we want the request itself back, not the response body
869
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
870
+ request_only = true
871
+ last_arg.delete(:request_only)
872
+ end
873
+
874
+ params = last_arg
875
+ body ||= {}
876
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
877
+ request_only ? request : request.response.body
878
+ end
879
+
880
+ # Subscribes to an object.
881
+ #
882
+ def add_subscription(user, objectType, objectIdentifier, *args)
883
+ http_method = :post
884
+ path = '/user/{user}/subscriptions/{objectType}/{objectIdentifier}'
885
+ path.sub!('{user}', user.to_s)
886
+ path.sub!('{objectType}', objectType.to_s)
887
+ path.sub!('{objectIdentifier}', objectIdentifier.to_s)
888
+
889
+ # Ruby turns all key-value arguments at the end into a single hash
890
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
891
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
892
+ last_arg = args.pop if args.last.is_a?(Hash)
893
+ last_arg = args.pop if args.last.is_a?(Array)
894
+ last_arg ||= {}
895
+
896
+ # Look for a kwarg called :request_only, whose presence indicates
897
+ # that we want the request itself back, not the response body
898
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
899
+ request_only = true
900
+ last_arg.delete(:request_only)
901
+ end
902
+
903
+ params = last_arg
904
+ body ||= {}
905
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
906
+ request_only ? request : request.response.body
907
+ end
908
+
909
+ # Deletes a subscription to an object.
910
+ #
911
+ def remove_subscription(user, objectType, objectIdentifier, *args)
912
+ http_method = :delete
913
+ path = '/user/{user}/subscriptions/{objectType}/{objectIdentifier}'
914
+ path.sub!('{user}', user.to_s)
915
+ path.sub!('{objectType}', objectType.to_s)
916
+ path.sub!('{objectIdentifier}', objectIdentifier.to_s)
917
+
918
+ # Ruby turns all key-value arguments at the end into a single hash
919
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
920
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
921
+ last_arg = args.pop if args.last.is_a?(Hash)
922
+ last_arg = args.pop if args.last.is_a?(Array)
923
+ last_arg ||= {}
924
+
925
+ # Look for a kwarg called :request_only, whose presence indicates
926
+ # that we want the request itself back, not the response body
927
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
928
+ request_only = true
929
+ last_arg.delete(:request_only)
930
+ end
931
+
932
+ params = last_arg
933
+ body ||= {}
934
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
935
+ request_only ? request : request.response.body
936
+ end
937
+
938
+ # Fetches Favorite Words for a user.
939
+ #
940
+ def get_user_favorite_words(user, *args)
941
+ http_method = :get
942
+ path = '/user/{user}/favorites/words'
943
+ path.sub!('{user}', user.to_s)
944
+
945
+ # Ruby turns all key-value arguments at the end into a single hash
946
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
947
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
948
+ last_arg = args.pop if args.last.is_a?(Hash)
949
+ last_arg = args.pop if args.last.is_a?(Array)
950
+ last_arg ||= {}
951
+
952
+ # Look for a kwarg called :request_only, whose presence indicates
953
+ # that we want the request itself back, not the response body
954
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
955
+ request_only = true
956
+ last_arg.delete(:request_only)
957
+ end
958
+
959
+ params = last_arg
960
+ body ||= {}
961
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
962
+ request_only ? request : request.response.body
963
+ end
964
+
965
+ # Fetches favorite word count for a user.
966
+ #
967
+ def get_user_favorite_count(user, *args)
968
+ http_method = :get
969
+ path = '/user/{user}/favorites/wordCount'
970
+ path.sub!('{user}', user.to_s)
971
+
972
+ # Ruby turns all key-value arguments at the end into a single hash
973
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
974
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
975
+ last_arg = args.pop if args.last.is_a?(Hash)
976
+ last_arg = args.pop if args.last.is_a?(Array)
977
+ last_arg ||= {}
978
+
979
+ # Look for a kwarg called :request_only, whose presence indicates
980
+ # that we want the request itself back, not the response body
981
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
982
+ request_only = true
983
+ last_arg.delete(:request_only)
984
+ end
985
+
986
+ params = last_arg
987
+ body ||= {}
988
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
989
+ request_only ? request : request.response.body
990
+ end
991
+
992
+ # Fetches Favorite WordLists for a user.
993
+ #
994
+ def get_user_favorite_word_lists(user, *args)
995
+ http_method = :get
996
+ path = '/user/{user}/favorites/wordLists'
997
+ path.sub!('{user}', user.to_s)
998
+
999
+ # Ruby turns all key-value arguments at the end into a single hash
1000
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
1001
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
1002
+ last_arg = args.pop if args.last.is_a?(Hash)
1003
+ last_arg = args.pop if args.last.is_a?(Array)
1004
+ last_arg ||= {}
1005
+
1006
+ # Look for a kwarg called :request_only, whose presence indicates
1007
+ # that we want the request itself back, not the response body
1008
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
1009
+ request_only = true
1010
+ last_arg.delete(:request_only)
1011
+ end
1012
+
1013
+ params = last_arg
1014
+ body ||= {}
1015
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
1016
+ request_only ? request : request.response.body
1017
+ end
1018
+
1019
+ # Fetches Favorite WordList count for a user.
1020
+ #
1021
+ def get_user_favorite_word_lists_count(user, *args)
1022
+ http_method = :get
1023
+ path = '/user/{user}/favorites/wordListCount'
1024
+ path.sub!('{user}', user.to_s)
1025
+
1026
+ # Ruby turns all key-value arguments at the end into a single hash
1027
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
1028
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
1029
+ last_arg = args.pop if args.last.is_a?(Hash)
1030
+ last_arg = args.pop if args.last.is_a?(Array)
1031
+ last_arg ||= {}
1032
+
1033
+ # Look for a kwarg called :request_only, whose presence indicates
1034
+ # that we want the request itself back, not the response body
1035
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
1036
+ request_only = true
1037
+ last_arg.delete(:request_only)
1038
+ end
1039
+
1040
+ params = last_arg
1041
+ body ||= {}
1042
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
1043
+ request_only ? request : request.response.body
1044
+ end
1045
+
1046
+ # Fetches SearchHistory for a User.
1047
+ #
1048
+ def get_user_search_history(user, *args)
1049
+ http_method = :get
1050
+ path = '/user/{user}/searches'
1051
+ path.sub!('{user}', user.to_s)
1052
+
1053
+ # Ruby turns all key-value arguments at the end into a single hash
1054
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
1055
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
1056
+ last_arg = args.pop if args.last.is_a?(Hash)
1057
+ last_arg = args.pop if args.last.is_a?(Array)
1058
+ last_arg ||= {}
1059
+
1060
+ # Look for a kwarg called :request_only, whose presence indicates
1061
+ # that we want the request itself back, not the response body
1062
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
1063
+ request_only = true
1064
+ last_arg.delete(:request_only)
1065
+ end
1066
+
1067
+ params = last_arg
1068
+ body ||= {}
1069
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
1070
+ request_only ? request : request.response.body
1071
+ end
1072
+
1073
+ # Fetches SearchHistory for a User.
1074
+ #
1075
+ def remove_user_search_history_item(user, *args)
1076
+ http_method = :delete
1077
+ path = '/user/{user}/searches'
1078
+ path.sub!('{user}', user.to_s)
1079
+
1080
+ # Ruby turns all key-value arguments at the end into a single hash
1081
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
1082
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
1083
+ last_arg = args.pop if args.last.is_a?(Hash)
1084
+ last_arg = args.pop if args.last.is_a?(Array)
1085
+ last_arg ||= {}
1086
+
1087
+ # Look for a kwarg called :request_only, whose presence indicates
1088
+ # that we want the request itself back, not the response body
1089
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
1090
+ request_only = true
1091
+ last_arg.delete(:request_only)
1092
+ end
1093
+
1094
+ params = last_arg
1095
+ body ||= {}
1096
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
1097
+ request_only ? request : request.response.body
1098
+ end
1099
+
1100
+ # Fetches the total search count for a User.
1101
+ #
1102
+ def get_user_search_history_count(user, *args)
1103
+ http_method = :get
1104
+ path = '/user/{user}/totalSearches'
1105
+ path.sub!('{user}', user.to_s)
1106
+
1107
+ # Ruby turns all key-value arguments at the end into a single hash
1108
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
1109
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
1110
+ last_arg = args.pop if args.last.is_a?(Hash)
1111
+ last_arg = args.pop if args.last.is_a?(Array)
1112
+ last_arg ||= {}
1113
+
1114
+ # Look for a kwarg called :request_only, whose presence indicates
1115
+ # that we want the request itself back, not the response body
1116
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
1117
+ request_only = true
1118
+ last_arg.delete(:request_only)
1119
+ end
1120
+
1121
+ params = last_arg
1122
+ body ||= {}
1123
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
1124
+ request_only ? request : request.response.body
1125
+ end
1126
+
1127
+ # Fetches the total search count for a User.
1128
+ #
1129
+ def get_user_pronunciations(user, *args)
1130
+ http_method = :get
1131
+ path = '/user/{user}/pronunciations'
1132
+ path.sub!('{user}', user.to_s)
1133
+
1134
+ # Ruby turns all key-value arguments at the end into a single hash
1135
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
1136
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
1137
+ last_arg = args.pop if args.last.is_a?(Hash)
1138
+ last_arg = args.pop if args.last.is_a?(Array)
1139
+ last_arg ||= {}
1140
+
1141
+ # Look for a kwarg called :request_only, whose presence indicates
1142
+ # that we want the request itself back, not the response body
1143
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
1144
+ request_only = true
1145
+ last_arg.delete(:request_only)
1146
+ end
1147
+
1148
+ params = last_arg
1149
+ body ||= {}
1150
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
1151
+ request_only ? request : request.response.body
1152
+ end
1153
+
1154
+ # Fetches the total search count for a User.
1155
+ #
1156
+ def get_user_activity_stream(user, *args)
1157
+ http_method = :get
1158
+ path = '/user/{user}/activitystream'
1159
+ path.sub!('{user}', user.to_s)
1160
+
1161
+ # Ruby turns all key-value arguments at the end into a single hash
1162
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
1163
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
1164
+ last_arg = args.pop if args.last.is_a?(Hash)
1165
+ last_arg = args.pop if args.last.is_a?(Array)
1166
+ last_arg ||= {}
1167
+
1168
+ # Look for a kwarg called :request_only, whose presence indicates
1169
+ # that we want the request itself back, not the response body
1170
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
1171
+ request_only = true
1172
+ last_arg.delete(:request_only)
1173
+ end
1174
+
1175
+ params = last_arg
1176
+ body ||= {}
1177
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
1178
+ request_only ? request : request.response.body
1179
+ end
1180
+
1181
+ # Returns information about API parameters
1182
+ #
1183
+ def get_help(*args)
1184
+ http_method = :get
1185
+ path = '/user'
1186
+
1187
+ # Ruby turns all key-value arguments at the end into a single hash
1188
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
1189
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
1190
+ last_arg = args.pop if args.last.is_a?(Hash)
1191
+ last_arg = args.pop if args.last.is_a?(Array)
1192
+ last_arg ||= {}
1193
+
1194
+ # Look for a kwarg called :request_only, whose presence indicates
1195
+ # that we want the request itself back, not the response body
1196
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
1197
+ request_only = true
1198
+ last_arg.delete(:request_only)
277
1199
  end
278
1200
 
1201
+ params = last_arg
1202
+ body ||= {}
279
1203
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
280
1204
  request_only ? request : request.response.body
281
1205
  end