wordnik 0.4.5 → 0.4.6

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.
@@ -0,0 +1,230 @@
1
+ # HEY HACKER! THIS IS AN AUTO-GENERATED FILE.
2
+ # So don't bother editing it. To see how it's built, take a look at the Rakefile
3
+
4
+ module AccountMethods
5
+
6
+ # Authenticates a User
7
+ #
8
+ def authenticate(username, *args)
9
+ http_method = :get
10
+ path = '/account/authenticate/{username}'
11
+ path.sub!('{username}', username)
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
+ if [:post, :put].include?(http_method)
28
+ params = nil
29
+ body = last_arg
30
+ else
31
+ params = last_arg
32
+ body = nil
33
+ end
34
+
35
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
36
+ request_only ? request : request.response.body
37
+ end
38
+
39
+ # Returns usage statistics for the API account.
40
+ #
41
+ def get_api_token_status(*args)
42
+ http_method = :get
43
+ path = '/account/apiTokenStatus'
44
+ # Ruby turns all key-value arguments at the end into a single hash
45
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
46
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
47
+ last_arg = args.pop if args.last.is_a?(Hash)
48
+ last_arg = args.pop if args.last.is_a?(Array)
49
+ last_arg ||= {}
50
+
51
+ # Look for a kwarg called :request_only, whose presence indicates
52
+ # that we want the request itself back, not the response body
53
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
54
+ request_only = true
55
+ last_arg.delete(:request_only)
56
+ end
57
+
58
+ if [:post, :put].include?(http_method)
59
+ params = nil
60
+ body = last_arg
61
+ else
62
+ params = last_arg
63
+ body = nil
64
+ end
65
+
66
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
67
+ request_only ? request : request.response.body
68
+ end
69
+
70
+ # Returns an ApiResponse indicating whether or not a username is available
71
+ #
72
+ def get_username_available(username, *args)
73
+ http_method = :get
74
+ path = '/account/usernameAvailable/{username}'
75
+ path.sub!('{username}', username)
76
+
77
+ # Ruby turns all key-value arguments at the end into a single hash
78
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
79
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
80
+ last_arg = args.pop if args.last.is_a?(Hash)
81
+ last_arg = args.pop if args.last.is_a?(Array)
82
+ last_arg ||= {}
83
+
84
+ # Look for a kwarg called :request_only, whose presence indicates
85
+ # that we want the request itself back, not the response body
86
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
87
+ request_only = true
88
+ last_arg.delete(:request_only)
89
+ end
90
+
91
+ if [:post, :put].include?(http_method)
92
+ params = nil
93
+ body = last_arg
94
+ else
95
+ params = last_arg
96
+ body = nil
97
+ end
98
+
99
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
100
+ request_only ? request : request.response.body
101
+ end
102
+
103
+ # Regenerates an API Token. Currently not supported or tested.
104
+ #
105
+ def create_api_account(*args)
106
+ http_method = :get
107
+ path = '/account/regenerateApiToken'
108
+ # Ruby turns all key-value arguments at the end into a single hash
109
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
110
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
111
+ last_arg = args.pop if args.last.is_a?(Hash)
112
+ last_arg = args.pop if args.last.is_a?(Array)
113
+ last_arg ||= {}
114
+
115
+ # Look for a kwarg called :request_only, whose presence indicates
116
+ # that we want the request itself back, not the response body
117
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
118
+ request_only = true
119
+ last_arg.delete(:request_only)
120
+ end
121
+
122
+ if [:post, :put].include?(http_method)
123
+ params = nil
124
+ body = last_arg
125
+ else
126
+ params = last_arg
127
+ body = nil
128
+ end
129
+
130
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
131
+ request_only ? request : request.response.body
132
+ end
133
+
134
+ # Authenticates a user
135
+ #
136
+ def authenticate_post(username, *args)
137
+ http_method = :post
138
+ path = '/account/authenticate/{username}'
139
+ path.sub!('{username}', username)
140
+
141
+ # Ruby turns all key-value arguments at the end into a single hash
142
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
143
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
144
+ last_arg = args.pop if args.last.is_a?(Hash)
145
+ last_arg = args.pop if args.last.is_a?(Array)
146
+ last_arg ||= {}
147
+
148
+ # Look for a kwarg called :request_only, whose presence indicates
149
+ # that we want the request itself back, not the response body
150
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
151
+ request_only = true
152
+ last_arg.delete(:request_only)
153
+ end
154
+
155
+ if [:post, :put].include?(http_method)
156
+ params = nil
157
+ body = last_arg
158
+ else
159
+ params = last_arg
160
+ body = nil
161
+ end
162
+
163
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
164
+ request_only ? request : request.response.body
165
+ end
166
+
167
+ # Returns the logged-in User
168
+ # Requires a valid auth_token to be set.
169
+ #
170
+ def get_logged_in_user(*args)
171
+ http_method = :get
172
+ path = '/account/user'
173
+ # Ruby turns all key-value arguments at the end into a single hash
174
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
175
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
176
+ last_arg = args.pop if args.last.is_a?(Hash)
177
+ last_arg = args.pop if args.last.is_a?(Array)
178
+ last_arg ||= {}
179
+
180
+ # Look for a kwarg called :request_only, whose presence indicates
181
+ # that we want the request itself back, not the response body
182
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
183
+ request_only = true
184
+ last_arg.delete(:request_only)
185
+ end
186
+
187
+ if [:post, :put].include?(http_method)
188
+ params = nil
189
+ body = last_arg
190
+ else
191
+ params = last_arg
192
+ body = nil
193
+ end
194
+
195
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
196
+ request_only ? request : request.response.body
197
+ end
198
+
199
+ # Fetches WordList objects for the logged-in user.
200
+ #
201
+ def get_word_lists_for_current_user(*args)
202
+ http_method = :get
203
+ path = '/account/wordLists'
204
+ # Ruby turns all key-value arguments at the end into a single hash
205
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
206
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
207
+ last_arg = args.pop if args.last.is_a?(Hash)
208
+ last_arg = args.pop if args.last.is_a?(Array)
209
+ last_arg ||= {}
210
+
211
+ # Look for a kwarg called :request_only, whose presence indicates
212
+ # that we want the request itself back, not the response body
213
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
214
+ request_only = true
215
+ last_arg.delete(:request_only)
216
+ end
217
+
218
+ if [:post, :put].include?(http_method)
219
+ params = nil
220
+ body = last_arg
221
+ else
222
+ params = last_arg
223
+ body = nil
224
+ end
225
+
226
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
227
+ request_only ? request : request.response.body
228
+ end
229
+
230
+ end
@@ -0,0 +1,37 @@
1
+ # HEY HACKER! THIS IS AN AUTO-GENERATED FILE.
2
+ # So don't bother editing it. To see how it's built, take a look at the Rakefile
3
+
4
+ module SystemMethods
5
+
6
+ # Returns a graph response for the supplied terms
7
+ #
8
+ def get_word_by_id(*args)
9
+ http_method = :get
10
+ path = '/system/graph'
11
+ # Ruby turns all key-value arguments at the end into a single hash
12
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
13
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
14
+ last_arg = args.pop if args.last.is_a?(Hash)
15
+ last_arg = args.pop if args.last.is_a?(Array)
16
+ last_arg ||= {}
17
+
18
+ # Look for a kwarg called :request_only, whose presence indicates
19
+ # that we want the request itself back, not the response body
20
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
21
+ request_only = true
22
+ last_arg.delete(:request_only)
23
+ end
24
+
25
+ if [:post, :put].include?(http_method)
26
+ params = nil
27
+ body = last_arg
28
+ else
29
+ params = last_arg
30
+ body = nil
31
+ end
32
+
33
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
34
+ request_only ? request : request.response.body
35
+ end
36
+
37
+ end
@@ -0,0 +1,283 @@
1
+ # HEY HACKER! THIS IS AN AUTO-GENERATED FILE.
2
+ # So don't bother editing it. To see how it's built, take a look at the Rakefile
3
+
4
+ module UserMethods
5
+
6
+ # Returns the WordOfTheDay for a given user on a given date
7
+ #
8
+ def get_word_of_the_day_by_date(username, date, *args)
9
+ http_method = :get
10
+ path = '/user/{username}/wordOfTheDay/{date}'
11
+ path.sub!('{username}', username)
12
+
13
+ path.sub!('{date}', date)
14
+
15
+ # Ruby turns all key-value arguments at the end into a single hash
16
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
17
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
18
+ last_arg = args.pop if args.last.is_a?(Hash)
19
+ last_arg = args.pop if args.last.is_a?(Array)
20
+ last_arg ||= {}
21
+
22
+ # Look for a kwarg called :request_only, whose presence indicates
23
+ # that we want the request itself back, not the response body
24
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
25
+ request_only = true
26
+ last_arg.delete(:request_only)
27
+ end
28
+
29
+ if [:post, :put].include?(http_method)
30
+ params = nil
31
+ body = last_arg
32
+ else
33
+ params = last_arg
34
+ body = nil
35
+ end
36
+
37
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
38
+ request_only ? request : request.response.body
39
+ end
40
+
41
+ # Returns a user's WordOfTheDayList
42
+ #
43
+ def get_word_of_the_day_list(username, *args)
44
+ http_method = :get
45
+ path = '/user/{username}/wordOfTheDayList'
46
+ path.sub!('{username}', username)
47
+
48
+ # Ruby turns all key-value arguments at the end into a single hash
49
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
50
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
51
+ last_arg = args.pop if args.last.is_a?(Hash)
52
+ last_arg = args.pop if args.last.is_a?(Array)
53
+ last_arg ||= {}
54
+
55
+ # Look for a kwarg called :request_only, whose presence indicates
56
+ # that we want the request itself back, not the response body
57
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
58
+ request_only = true
59
+ last_arg.delete(:request_only)
60
+ end
61
+
62
+ if [:post, :put].include?(http_method)
63
+ params = nil
64
+ body = last_arg
65
+ else
66
+ params = last_arg
67
+ body = nil
68
+ end
69
+
70
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
71
+ request_only ? request : request.response.body
72
+ end
73
+
74
+ # Updates a user's WordOfTheDayList
75
+ #
76
+ def update_word_of_the_day_list(username, *args)
77
+ http_method = :put
78
+ path = '/user/{username}/wordOfTheDayList'
79
+ path.sub!('{username}', username)
80
+
81
+ # Ruby turns all key-value arguments at the end into a single hash
82
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
83
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
84
+ last_arg = args.pop if args.last.is_a?(Hash)
85
+ last_arg = args.pop if args.last.is_a?(Array)
86
+ last_arg ||= {}
87
+
88
+ # Look for a kwarg called :request_only, whose presence indicates
89
+ # that we want the request itself back, not the response body
90
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
91
+ request_only = true
92
+ last_arg.delete(:request_only)
93
+ end
94
+
95
+ if [:post, :put].include?(http_method)
96
+ params = nil
97
+ body = last_arg
98
+ else
99
+ params = last_arg
100
+ body = nil
101
+ end
102
+
103
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
104
+ request_only ? request : request.response.body
105
+ end
106
+
107
+ # Creates a WordOfTheDayList
108
+ # A user can have only one WordOfTheDayList.
109
+ #
110
+ def create_word_of_the_day_list(username, *args)
111
+ http_method = :post
112
+ path = '/user/{username}/wordOfTheDayList'
113
+ path.sub!('{username}', username)
114
+
115
+ # Ruby turns all key-value arguments at the end into a single hash
116
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
117
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
118
+ last_arg = args.pop if args.last.is_a?(Hash)
119
+ last_arg = args.pop if args.last.is_a?(Array)
120
+ last_arg ||= {}
121
+
122
+ # Look for a kwarg called :request_only, whose presence indicates
123
+ # that we want the request itself back, not the response body
124
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
125
+ request_only = true
126
+ last_arg.delete(:request_only)
127
+ end
128
+
129
+ if [:post, :put].include?(http_method)
130
+ params = nil
131
+ body = last_arg
132
+ else
133
+ params = last_arg
134
+ body = nil
135
+ end
136
+
137
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
138
+ request_only ? request : request.response.body
139
+ end
140
+
141
+ # Adds a WordOfTheDay to a user's WordOfTheDayList
142
+ #
143
+ def update_item_in_word_of_the_day_list(username, permalink, *args)
144
+ http_method = :put
145
+ path = '/user/{username}/wordOfTheDayList/{permalink}'
146
+ path.sub!('{username}', username)
147
+
148
+ path.sub!('{permalink}', permalink)
149
+
150
+ # Ruby turns all key-value arguments at the end into a single hash
151
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
152
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
153
+ last_arg = args.pop if args.last.is_a?(Hash)
154
+ last_arg = args.pop if args.last.is_a?(Array)
155
+ last_arg ||= {}
156
+
157
+ # Look for a kwarg called :request_only, whose presence indicates
158
+ # that we want the request itself back, not the response body
159
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
160
+ request_only = true
161
+ last_arg.delete(:request_only)
162
+ end
163
+
164
+ if [:post, :put].include?(http_method)
165
+ params = nil
166
+ body = last_arg
167
+ else
168
+ params = last_arg
169
+ body = nil
170
+ end
171
+
172
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
173
+ request_only ? request : request.response.body
174
+ end
175
+
176
+ # Deletes a user's WordOfTheDayList
177
+ #
178
+ def update_word_of_the_day_list(username, permalink, *args)
179
+ http_method = :delete
180
+ path = '/user/{username}/wordOfTheDayList/{permalink}'
181
+ path.sub!('{username}', username)
182
+
183
+ path.sub!('{permalink}', permalink)
184
+
185
+ # Ruby turns all key-value arguments at the end into a single hash
186
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
187
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
188
+ last_arg = args.pop if args.last.is_a?(Hash)
189
+ last_arg = args.pop if args.last.is_a?(Array)
190
+ last_arg ||= {}
191
+
192
+ # Look for a kwarg called :request_only, whose presence indicates
193
+ # that we want the request itself back, not the response body
194
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
195
+ request_only = true
196
+ last_arg.delete(:request_only)
197
+ end
198
+
199
+ if [:post, :put].include?(http_method)
200
+ params = nil
201
+ body = last_arg
202
+ else
203
+ params = last_arg
204
+ body = nil
205
+ end
206
+
207
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
208
+ request_only ? request : request.response.body
209
+ end
210
+
211
+ # Deletes a specific word from a user's WordOfTheDayList
212
+ #
213
+ def delete_word_from_word_of_the_day_list(username, permalink, wordToDelete, *args)
214
+ http_method = :delete
215
+ path = '/user/{username}/wordOfTheDayList/{permalink}/{wordToDelete}'
216
+ path.sub!('{username}', username)
217
+
218
+ path.sub!('{permalink}', permalink)
219
+
220
+ path.sub!('{wordToDelete}', wordToDelete)
221
+
222
+ # Ruby turns all key-value arguments at the end into a single hash
223
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
224
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
225
+ last_arg = args.pop if args.last.is_a?(Hash)
226
+ last_arg = args.pop if args.last.is_a?(Array)
227
+ last_arg ||= {}
228
+
229
+ # Look for a kwarg called :request_only, whose presence indicates
230
+ # that we want the request itself back, not the response body
231
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
232
+ request_only = true
233
+ last_arg.delete(:request_only)
234
+ end
235
+
236
+ if [:post, :put].include?(http_method)
237
+ params = nil
238
+ body = last_arg
239
+ else
240
+ params = last_arg
241
+ body = nil
242
+ end
243
+
244
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
245
+ request_only ? request : request.response.body
246
+ end
247
+
248
+ # Adds an item to a user's WordOfTheDayList
249
+ #
250
+ def add_word_to_word_of_the_day_list(username, permalink, *args)
251
+ http_method = :put
252
+ path = '/user/{username}/wordOfTheDayList/{permalink}/add'
253
+ path.sub!('{username}', username)
254
+
255
+ path.sub!('{permalink}', permalink)
256
+
257
+ # Ruby turns all key-value arguments at the end into a single hash
258
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
259
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
260
+ last_arg = args.pop if args.last.is_a?(Hash)
261
+ last_arg = args.pop if args.last.is_a?(Array)
262
+ last_arg ||= {}
263
+
264
+ # Look for a kwarg called :request_only, whose presence indicates
265
+ # that we want the request itself back, not the response body
266
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
267
+ request_only = true
268
+ last_arg.delete(:request_only)
269
+ end
270
+
271
+ if [:post, :put].include?(http_method)
272
+ params = nil
273
+ body = last_arg
274
+ else
275
+ params = last_arg
276
+ body = nil
277
+ end
278
+
279
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
280
+ request_only ? request : request.response.body
281
+ end
282
+
283
+ end