wordnik 4.06.05 → 4.06.06
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/Gemfile.lock +22 -16
- data/Rakefile +29 -166
- data/api_docs/account.json +1 -1
- data/api_docs/analytics.json +1 -0
- data/api_docs/corpus.json +1 -1
- data/api_docs/document.json +1 -1
- data/api_docs/partner.json +1 -0
- data/api_docs/partners.json +1 -1
- data/api_docs/suggest.json +1 -0
- data/api_docs/system.json +1 -0
- 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 +58 -17
- data/lib/wordnik/configuration.rb +21 -6
- data/lib/wordnik/operation.rb +3 -2
- data/lib/wordnik/operation_parameter.rb +4 -6
- data/lib/wordnik/request.rb +53 -53
- data/lib/wordnik/resource.rb +68 -3
- data/lib/wordnik/resource_modules/account.rb +0 -26
- data/lib/wordnik/resource_modules/analytics.rb +89 -0
- data/lib/wordnik/resource_modules/corpus.rb +26 -26
- data/lib/wordnik/resource_modules/document.rb +0 -26
- data/lib/wordnik/resource_modules/partner.rb +140 -0
- data/lib/wordnik/resource_modules/partners.rb +0 -26
- data/lib/wordnik/resource_modules/suggest.rb +33 -0
- data/lib/wordnik/resource_modules/system.rb +192 -0
- data/lib/wordnik/resource_modules/tag.rb +0 -26
- data/lib/wordnik/resource_modules/user.rb +0 -26
- data/lib/wordnik/resource_modules/users.rb +12 -38
- data/lib/wordnik/resource_modules/word.rb +23 -49
- data/lib/wordnik/resource_modules/word_list.rb +0 -26
- data/lib/wordnik/resource_modules/word_lists.rb +0 -26
- data/lib/wordnik/resource_modules/words.rb +0 -26
- data/lib/wordnik/response.rb +3 -5
- data/lib/wordnik/version.rb +1 -1
- data/spec/endpoint_spec.rb +2 -5
- data/spec/operation_parameter_spec.rb +32 -11
- data/spec/operation_spec.rb +2 -5
- data/spec/request_spec.rb +9 -30
- data/spec/resource_spec.rb +7 -7
- data/spec/response_spec.rb +13 -19
- data/spec/spec_helper.rb +14 -2
- data/spec/vcr/crazier_json_request.yml +31 -0
- data/spec/vcr/default_response.yml +25 -0
- data/spec/vcr/get_word_dynamo.yml +33 -0
- data/spec/vcr/unauthorized_response.yml +25 -0
- data/spec/vcr/wordnik_authenticate.yml +31 -0
- data/spec/vcr/wordnik_authenticate_fail.yml +172 -0
- data/spec/vcr/xml_response_request.yml +25 -0
- data/spec/wordnik_spec.rb +68 -17
- data/wordnik.gemspec +2 -0
- metadata +48 -5
@@ -109,32 +109,6 @@ module CorpusMethods
|
|
109
109
|
request_only ? request : request.response.body
|
110
110
|
end
|
111
111
|
|
112
|
-
# Returns information about API parameters
|
113
|
-
#
|
114
|
-
def get_help(*args)
|
115
|
-
http_method = :get
|
116
|
-
path = '/corpus'
|
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
112
|
# Returns the count of documents in the Corpus.
|
139
113
|
#
|
140
114
|
def get_total_document_count(*args)
|
@@ -345,6 +319,32 @@ module CorpusMethods
|
|
345
319
|
request_only ? request : request.response.body
|
346
320
|
end
|
347
321
|
|
322
|
+
# Fetches views from the website.
|
323
|
+
#
|
324
|
+
def get_views(*args)
|
325
|
+
http_method = :get
|
326
|
+
path = '/corpus/views'
|
327
|
+
|
328
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
329
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
330
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
331
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
332
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
333
|
+
last_arg ||= {}
|
334
|
+
|
335
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
336
|
+
# that we want the request itself back, not the response body
|
337
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
338
|
+
request_only = true
|
339
|
+
last_arg.delete(:request_only)
|
340
|
+
end
|
341
|
+
|
342
|
+
params = last_arg
|
343
|
+
body ||= {}
|
344
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
345
|
+
request_only ? request : request.response.body
|
346
|
+
end
|
347
|
+
|
348
348
|
# Mock method to return Contextual Lookup info.
|
349
349
|
# Internal Only
|
350
350
|
#
|
@@ -57,32 +57,6 @@ module DocumentMethods
|
|
57
57
|
request_only ? request : request.response.body
|
58
58
|
end
|
59
59
|
|
60
|
-
# Returns information about API parameters
|
61
|
-
#
|
62
|
-
def get_help(*args)
|
63
|
-
http_method = :get
|
64
|
-
path = '/document'
|
65
|
-
|
66
|
-
# Ruby turns all key-value arguments at the end into a single hash
|
67
|
-
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
68
|
-
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
69
|
-
last_arg = args.pop if args.last.is_a?(Hash)
|
70
|
-
last_arg = args.pop if args.last.is_a?(Array)
|
71
|
-
last_arg ||= {}
|
72
|
-
|
73
|
-
# Look for a kwarg called :request_only, whose presence indicates
|
74
|
-
# that we want the request itself back, not the response body
|
75
|
-
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
76
|
-
request_only = true
|
77
|
-
last_arg.delete(:request_only)
|
78
|
-
end
|
79
|
-
|
80
|
-
params = last_arg
|
81
|
-
body ||= {}
|
82
|
-
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
83
|
-
request_only ? request : request.response.body
|
84
|
-
end
|
85
|
-
|
86
60
|
# Fetches Document objects by Content Provider code.
|
87
61
|
#
|
88
62
|
def get_documents_by_content_provider(provider, *args)
|
@@ -0,0 +1,140 @@
|
|
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 PartnerMethods
|
5
|
+
|
6
|
+
# Fetches model search results.
|
7
|
+
#
|
8
|
+
def get_results(id, *args)
|
9
|
+
http_method = :get
|
10
|
+
path = '/partner/{id}/result'
|
11
|
+
path.sub!('{id}', id.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
|
+
# Fetches glossaries for the specified Provider.
|
34
|
+
#
|
35
|
+
def get_glossaries(*args)
|
36
|
+
http_method = :get
|
37
|
+
path = '/partner/glossaries'
|
38
|
+
|
39
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
40
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
41
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
42
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
43
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
44
|
+
last_arg ||= {}
|
45
|
+
|
46
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
47
|
+
# that we want the request itself back, not the response body
|
48
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
49
|
+
request_only = true
|
50
|
+
last_arg.delete(:request_only)
|
51
|
+
end
|
52
|
+
|
53
|
+
params = last_arg
|
54
|
+
body ||= {}
|
55
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
56
|
+
request_only ? request : request.response.body
|
57
|
+
end
|
58
|
+
|
59
|
+
# Fetches a glossary by permalink.
|
60
|
+
#
|
61
|
+
def get_glossary(permalink, *args)
|
62
|
+
http_method = :get
|
63
|
+
path = '/partner/glossary/{permalink}'
|
64
|
+
path.sub!('{permalink}', permalink.to_s)
|
65
|
+
|
66
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
67
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
68
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
69
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
70
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
71
|
+
last_arg ||= {}
|
72
|
+
|
73
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
74
|
+
# that we want the request itself back, not the response body
|
75
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
76
|
+
request_only = true
|
77
|
+
last_arg.delete(:request_only)
|
78
|
+
end
|
79
|
+
|
80
|
+
params = last_arg
|
81
|
+
body ||= {}
|
82
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
83
|
+
request_only ? request : request.response.body
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns weighted terms related to the input word
|
87
|
+
#
|
88
|
+
def get_related_words(word, *args)
|
89
|
+
http_method = :get
|
90
|
+
path = '/partner/{word}/related'
|
91
|
+
path.sub!('{word}', word.to_s)
|
92
|
+
|
93
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
94
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
95
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
96
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
97
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
98
|
+
last_arg ||= {}
|
99
|
+
|
100
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
101
|
+
# that we want the request itself back, not the response body
|
102
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
103
|
+
request_only = true
|
104
|
+
last_arg.delete(:request_only)
|
105
|
+
end
|
106
|
+
|
107
|
+
params = last_arg
|
108
|
+
body ||= {}
|
109
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
110
|
+
request_only ? request : request.response.body
|
111
|
+
end
|
112
|
+
|
113
|
+
# Fetches GlossaryEntry objects for the specified Glossary.
|
114
|
+
#
|
115
|
+
def get_glossary_entries(permalink, *args)
|
116
|
+
http_method = :get
|
117
|
+
path = '/partner/glossary/{permalink}/entries'
|
118
|
+
path.sub!('{permalink}', permalink.to_s)
|
119
|
+
|
120
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
121
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
122
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
123
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
124
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
125
|
+
last_arg ||= {}
|
126
|
+
|
127
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
128
|
+
# that we want the request itself back, not the response body
|
129
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
130
|
+
request_only = true
|
131
|
+
last_arg.delete(:request_only)
|
132
|
+
end
|
133
|
+
|
134
|
+
params = last_arg
|
135
|
+
body ||= {}
|
136
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
137
|
+
request_only ? request : request.response.body
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
@@ -141,32 +141,6 @@ module PartnersMethods
|
|
141
141
|
request_only ? request : request.response.body
|
142
142
|
end
|
143
143
|
|
144
|
-
# Returns information about API parameters
|
145
|
-
#
|
146
|
-
def get_help(*args)
|
147
|
-
http_method = :get
|
148
|
-
path = '/partners'
|
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
|
-
params = last_arg
|
165
|
-
body ||= {}
|
166
|
-
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
167
|
-
request_only ? request : request.response.body
|
168
|
-
end
|
169
|
-
|
170
144
|
# Fetches GlossaryEntry objects for the specified Glossary.
|
171
145
|
#
|
172
146
|
def get_glossary_entries(contentProvider, permalinkId, *args)
|
@@ -0,0 +1,33 @@
|
|
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 SuggestMethods
|
5
|
+
|
6
|
+
# Returns Word strings based on the input.
|
7
|
+
#
|
8
|
+
def get_tag_suggestions(word, *args)
|
9
|
+
http_method = :get
|
10
|
+
path = '/suggest/tags/{word}'
|
11
|
+
path.sub!('{word}', word.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
|
+
end
|
@@ -0,0 +1,192 @@
|
|
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 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 system-wide statistics for the platform.
|
33
|
+
#
|
34
|
+
def get_stats(*args)
|
35
|
+
http_method = :get
|
36
|
+
path = '/system/stats'
|
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
|
+
|
112
|
+
# Returns a graph response for the supplied terms
|
113
|
+
#
|
114
|
+
def get_word_by_id(*args)
|
115
|
+
http_method = :get
|
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
|
+
|
144
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
145
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
146
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
147
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
148
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
149
|
+
last_arg ||= {}
|
150
|
+
|
151
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
152
|
+
# that we want the request itself back, not the response body
|
153
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
154
|
+
request_only = true
|
155
|
+
last_arg.delete(:request_only)
|
156
|
+
end
|
157
|
+
|
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
|
+
# Sets duration of an Audio File
|
165
|
+
#
|
166
|
+
def set_audio_duration(audioFileId, duration, *args)
|
167
|
+
http_method = :post
|
168
|
+
path = '/system/audioDuration'
|
169
|
+
path.sub!('{audioFileId}', audioFileId.to_s)
|
170
|
+
path.sub!('{duration}', duration.to_s)
|
171
|
+
|
172
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
173
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
174
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
175
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
176
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
177
|
+
last_arg ||= {}
|
178
|
+
|
179
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
180
|
+
# that we want the request itself back, not the response body
|
181
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
182
|
+
request_only = true
|
183
|
+
last_arg.delete(:request_only)
|
184
|
+
end
|
185
|
+
|
186
|
+
params = last_arg
|
187
|
+
body ||= {}
|
188
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
189
|
+
request_only ? request : request.response.body
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|