aylien_text_api 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -6
  3. data/lib/aylien_text_api/client.rb +160 -12
  4. data/lib/aylien_text_api/configuration.rb +1 -0
  5. data/lib/aylien_text_api/error.rb +5 -2
  6. data/lib/aylien_text_api/version.rb +1 -1
  7. data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_invalid_client.yml +38 -0
  8. data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_invalid_params.yml +57 -0
  9. data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_invalid_taxonomy.yml +48 -0
  10. data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_text.yml +75 -0
  11. data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_unauthenticated_client.yml +42 -0
  12. data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_valid_url.yml +155 -0
  13. data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_value_as_text.yml +75 -0
  14. data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_value_as_valid_url.yml +155 -0
  15. data/spec/fixtures/aylien_text_api/client/classify_with_invalid_client.yml +3 -3
  16. data/spec/fixtures/aylien_text_api/client/classify_with_invalid_params.yml +5 -5
  17. data/spec/fixtures/aylien_text_api/client/classify_with_text.yml +5 -5
  18. data/spec/fixtures/aylien_text_api/client/classify_with_unauthenticated_client.yml +3 -3
  19. data/spec/fixtures/aylien_text_api/client/classify_with_valid_url.yml +5 -5
  20. data/spec/fixtures/aylien_text_api/client/classify_with_value_as_text.yml +5 -5
  21. data/spec/fixtures/aylien_text_api/client/classify_with_value_as_valid_url.yml +5 -5
  22. data/spec/fixtures/aylien_text_api/client/combined_with_invalid_client.yml +3 -3
  23. data/spec/fixtures/aylien_text_api/client/combined_with_invalid_params.yml +5 -5
  24. data/spec/fixtures/aylien_text_api/client/combined_with_text.yml +11 -11
  25. data/spec/fixtures/aylien_text_api/client/combined_with_unauthenticated_client.yml +3 -3
  26. data/spec/fixtures/aylien_text_api/client/combined_with_valid_url.yml +9 -9
  27. data/spec/fixtures/aylien_text_api/client/combined_with_value_as_text.yml +11 -11
  28. data/spec/fixtures/aylien_text_api/client/combined_with_value_as_valid_url.yml +9 -9
  29. data/spec/fixtures/aylien_text_api/client/concepts_with_invalid_client.yml +3 -3
  30. data/spec/fixtures/aylien_text_api/client/concepts_with_invalid_params.yml +5 -5
  31. data/spec/fixtures/aylien_text_api/client/concepts_with_text.yml +5 -5
  32. data/spec/fixtures/aylien_text_api/client/concepts_with_unauthenticated_client.yml +3 -3
  33. data/spec/fixtures/aylien_text_api/client/concepts_with_valid_url.yml +5 -5
  34. data/spec/fixtures/aylien_text_api/client/concepts_with_value_as_text.yml +5 -5
  35. data/spec/fixtures/aylien_text_api/client/concepts_with_value_as_valid_url.yml +5 -5
  36. data/spec/fixtures/aylien_text_api/client/entities_with_invalid_client.yml +3 -3
  37. data/spec/fixtures/aylien_text_api/client/entities_with_invalid_params.yml +5 -5
  38. data/spec/fixtures/aylien_text_api/client/entities_with_text.yml +5 -5
  39. data/spec/fixtures/aylien_text_api/client/entities_with_unauthenticated_client.yml +3 -3
  40. data/spec/fixtures/aylien_text_api/client/entities_with_valid_url.yml +5 -5
  41. data/spec/fixtures/aylien_text_api/client/entities_with_value_as_text.yml +5 -5
  42. data/spec/fixtures/aylien_text_api/client/entities_with_value_as_valid_url.yml +5 -5
  43. data/spec/fixtures/aylien_text_api/client/extract_with_invalid_client.yml +3 -3
  44. data/spec/fixtures/aylien_text_api/client/extract_with_invalid_params.yml +5 -5
  45. data/spec/fixtures/aylien_text_api/client/extract_with_unauthenticated_client.yml +3 -3
  46. data/spec/fixtures/aylien_text_api/client/extract_with_valid_url.yml +5 -5
  47. data/spec/fixtures/aylien_text_api/client/extract_with_value_as_text.yml +5 -5
  48. data/spec/fixtures/aylien_text_api/client/extract_with_value_as_valid_url.yml +5 -5
  49. data/spec/fixtures/aylien_text_api/client/hashtags_with_invalid_client.yml +3 -3
  50. data/spec/fixtures/aylien_text_api/client/hashtags_with_invalid_params.yml +5 -5
  51. data/spec/fixtures/aylien_text_api/client/hashtags_with_text.yml +8 -8
  52. data/spec/fixtures/aylien_text_api/client/hashtags_with_unauthenticated_client.yml +3 -3
  53. data/spec/fixtures/aylien_text_api/client/hashtags_with_valid_url.yml +9 -9
  54. data/spec/fixtures/aylien_text_api/client/hashtags_with_value_as_text.yml +8 -8
  55. data/spec/fixtures/aylien_text_api/client/hashtags_with_value_as_valid_url.yml +9 -9
  56. data/spec/fixtures/aylien_text_api/client/image_tags_with_invalid_client.yml +3 -3
  57. data/spec/fixtures/aylien_text_api/client/image_tags_with_invalid_params.yml +6 -6
  58. data/spec/fixtures/aylien_text_api/client/image_tags_with_unauthenticated_client.yml +3 -3
  59. data/spec/fixtures/aylien_text_api/client/image_tags_with_valid_url.yml +8 -8
  60. data/spec/fixtures/aylien_text_api/client/image_tags_with_value_as_text.yml +5 -5
  61. data/spec/fixtures/aylien_text_api/client/image_tags_with_value_as_valid_url.yml +8 -8
  62. data/spec/fixtures/aylien_text_api/client/language_with_invalid_client.yml +3 -3
  63. data/spec/fixtures/aylien_text_api/client/language_with_invalid_params.yml +5 -5
  64. data/spec/fixtures/aylien_text_api/client/language_with_unauthenticated_client.yml +3 -3
  65. data/spec/fixtures/aylien_text_api/client/language_with_valid_text.yml +6 -6
  66. data/spec/fixtures/aylien_text_api/client/language_with_valid_url.yml +6 -6
  67. data/spec/fixtures/aylien_text_api/client/language_with_value_as_text.yml +6 -6
  68. data/spec/fixtures/aylien_text_api/client/language_with_value_as_valid_url.yml +6 -6
  69. data/spec/fixtures/aylien_text_api/client/microformats_with_invalid_client.yml +3 -3
  70. data/spec/fixtures/aylien_text_api/client/microformats_with_invalid_params.yml +5 -5
  71. data/spec/fixtures/aylien_text_api/client/microformats_with_unauthenticated_client.yml +3 -3
  72. data/spec/fixtures/aylien_text_api/client/microformats_with_valid_url.yml +6 -6
  73. data/spec/fixtures/aylien_text_api/client/microformats_with_value_as_valid_url.yml +6 -6
  74. data/spec/fixtures/aylien_text_api/client/related_with_invalid_client.yml +3 -3
  75. data/spec/fixtures/aylien_text_api/client/related_with_invalid_params.yml +5 -5
  76. data/spec/fixtures/aylien_text_api/client/related_with_phrase.yml +5 -5
  77. data/spec/fixtures/aylien_text_api/client/related_with_unauthenticated_client.yml +3 -3
  78. data/spec/fixtures/aylien_text_api/client/related_with_value_as_phrase.yml +5 -5
  79. data/spec/fixtures/aylien_text_api/client/related_with_value_as_valid_url.yml +5 -5
  80. data/spec/fixtures/aylien_text_api/client/sentiment_with_invalid_client.yml +3 -3
  81. data/spec/fixtures/aylien_text_api/client/sentiment_with_invalid_params.yml +5 -5
  82. data/spec/fixtures/aylien_text_api/client/sentiment_with_text.yml +5 -5
  83. data/spec/fixtures/aylien_text_api/client/sentiment_with_unauthenticated_client.yml +3 -3
  84. data/spec/fixtures/aylien_text_api/client/sentiment_with_valid_url.yml +5 -5
  85. data/spec/fixtures/aylien_text_api/client/sentiment_with_value_as_text.yml +5 -5
  86. data/spec/fixtures/aylien_text_api/client/sentiment_with_value_as_valid_url.yml +5 -5
  87. data/spec/fixtures/aylien_text_api/client/summarize_with_invalid_client.yml +3 -3
  88. data/spec/fixtures/aylien_text_api/client/summarize_with_invalid_params.yml +5 -5
  89. data/spec/fixtures/aylien_text_api/client/summarize_with_title_and_text.yml +5 -5
  90. data/spec/fixtures/aylien_text_api/client/summarize_with_unauthenticated_client.yml +3 -3
  91. data/spec/fixtures/aylien_text_api/client/summarize_with_valid_url.yml +5 -5
  92. data/spec/fixtures/aylien_text_api/client/summarize_with_value_as_text_and_title.yml +5 -5
  93. data/spec/fixtures/aylien_text_api/client/summarize_with_value_as_text_and_without_title.yml +5 -5
  94. data/spec/fixtures/aylien_text_api/client/summarize_with_value_as_valid_url.yml +5 -5
  95. data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_invalid_client.yml +3 -3
  96. data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_invalid_params.yml +5 -5
  97. data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_text.yml +5 -5
  98. data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_unauthenticated_client.yml +3 -3
  99. data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_valid_url.yml +5 -5
  100. data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_value_as_text.yml +5 -5
  101. data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_value_as_valid_url.yml +5 -5
  102. data/spec/lib/aylien_text_api/classify_by_taxonomy.rb +124 -0
  103. data/spec/lib/aylien_text_api/client_spec.rb +1 -0
  104. metadata +21 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe9d4f356602fc1b9f1d70d21c187c775ef0d50b
4
- data.tar.gz: ea0e0d0ab966b97b8a62a582d18d926f574bf106
3
+ metadata.gz: f5ca9194dc31a1cff562728d3898aefd4b0d0b72
4
+ data.tar.gz: 0de02e92c4d55f1f84324d4ab5b694377ffaed8e
5
5
  SHA512:
6
- metadata.gz: 4f711cf5448383799904b579971ab911109e90099d70ff5927e25f2a000cf298dcd790a7604823fae1b1dfb4ebc674074d1ae9b2680eedf0661acb7d92763988
7
- data.tar.gz: 4fb437af83e64299b2129b007524056442680b923c027839f1b187e59709c13e9a7dce0244ad1a9c43c8b6b5938e52d4d036ef558d7936e3c179ca5832cd6092
6
+ metadata.gz: 02f89349fa72450dea8c2f20113cdf71a9f8447d26479f6131837b2c0d06da8549ecc947f24c8a46c050602860460c2d9fdc8d85639a207868a36ed2ddbe871d
7
+ data.tar.gz: b0cbfc361ca4f8d3cf21deb8beee50b4080a9e1aa61f2cac388571b9a2beb48e167fab62188d7be3e07e223f25b10b76e4009f360aab43f6c907d4cbde3570f3
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aylien_text_api (0.3.0)
4
+ aylien_text_api (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- addressable (2.3.6)
9
+ addressable (2.3.8)
10
10
  crack (0.4.2)
11
11
  safe_yaml (~> 1.0.0)
12
- minitest (5.4.3)
13
- rake (10.4.0)
12
+ minitest (5.8.0)
13
+ rake (10.4.2)
14
14
  safe_yaml (1.0.4)
15
15
  vcr (2.9.3)
16
- webmock (1.20.4)
16
+ webmock (1.21.0)
17
17
  addressable (>= 2.3.6)
18
18
  crack (>= 0.3.2)
19
19
 
@@ -28,4 +28,4 @@ DEPENDENCIES
28
28
  webmock (~> 1.20)
29
29
 
30
30
  BUNDLED WITH
31
- 1.10.5
31
+ 1.10.6
@@ -31,14 +31,6 @@ module AylienTextApi
31
31
  Configuration::VALID_CONFIG_KEYS.each do |key|
32
32
  send("#{key}=", merged_options[key])
33
33
  end
34
-
35
- Configuration::ENDPOINTS.keys.each do |endpoint|
36
- self.class.send(:define_method, "#{endpoint}!") do |value=nil, params={}|
37
- endpoint, params, config = common_endpoint(value, params,
38
- Configuration::ENDPOINTS[endpoint])
39
- Connection.new(endpoint, params, config).request!
40
- end
41
- end
42
34
  end
43
35
 
44
36
  # Extracts the main body of article, including embedded media such as
@@ -59,7 +51,45 @@ module AylienTextApi
59
51
  Configuration::ENDPOINTS[:extract])
60
52
  Connection.new(endpoint, params, config).request
61
53
  end
54
+
55
+ # Like extract, but calls request! so an exception is raised
56
+ # if the request fails.
57
+ #
58
+ def extract!(value=nil, params={})
59
+ endpoint, params, config = common_endpoint(value, params,
60
+ Configuration::ENDPOINTS[:extract])
61
+ Connection.new(endpoint, params, config).request!
62
+ end
62
63
 
64
+ # Classifies a piece of text according to a defined taxonomy.
65
+ #
66
+ # @param [String] value (nil) URL or Text
67
+ # @param [Hash] params The classify endpoint options
68
+ # @option params [String] :url The URL
69
+ # @option params [String] :text Text
70
+ # @option params [String] :language ('en') Language of text.
71
+ # Valid options are en, de, fr, es, it, pt, and auto.
72
+ # If set to auto, it'll try to detect the language.
73
+ #
74
+ # @return [Hash, nil] A hash of result. See
75
+ # http://docs.aylien.com/docs/classify_by_taxonomy for more information
76
+ # on the data returned.
77
+ #
78
+ def classify_by_taxonomy(value=nil, params={})
79
+ endpoint, params, config = common_endpoint(value, params,
80
+ Configuration::ENDPOINTS[:classify_by_taxonomy])
81
+ Connection.new(endpoint, params, config).request
82
+ end
83
+
84
+ # Like classify_by_taxonomy, but calls request! so an exception is raised
85
+ # if the request fails.
86
+ #
87
+ def classify_by_taxonomy!(value=nil, params={})
88
+ endpoint, params, config = common_endpoint(value, params,
89
+ Configuration::ENDPOINTS[:classify_by_taxonomy])
90
+ Connection.new(endpoint, params, config).request!
91
+ end
92
+
63
93
  # Classifies a piece of text according to IPTC NewsCode standard.
64
94
  #
65
95
  # @param [String] value (nil) URL or Text
@@ -79,6 +109,15 @@ module AylienTextApi
79
109
  Configuration::ENDPOINTS[:classify])
80
110
  Connection.new(endpoint, params, config).request
81
111
  end
112
+
113
+ # Like classify, but calls request! so an exception is raised
114
+ # if the request fails.
115
+ #
116
+ def classify!(value=nil, params={})
117
+ endpoint, params, config = common_endpoint(value, params,
118
+ Configuration::ENDPOINTS[:classify])
119
+ Connection.new(endpoint, params, config).request!
120
+ end
82
121
 
83
122
  # Extracts named entities mentioned in a document, disambiguates
84
123
  # and cross-links them to DBPedia and Linked Data entities, along with
@@ -101,6 +140,15 @@ module AylienTextApi
101
140
  Configuration::ENDPOINTS[:concepts])
102
141
  Connection.new(endpoint, params, config).request
103
142
  end
143
+
144
+ # Like concepts, but calls request! so an exception is raised
145
+ # if the request fails.
146
+ #
147
+ def concepts!(value=nil, params={})
148
+ endpoint, params, config = common_endpoint(value, params,
149
+ Configuration::ENDPOINTS[:concepts])
150
+ Connection.new(endpoint, params, config).request!
151
+ end
104
152
 
105
153
  # Suggests hashtags describing the document.
106
154
  #
@@ -121,6 +169,15 @@ module AylienTextApi
121
169
  Configuration::ENDPOINTS[:hashtags])
122
170
  Connection.new(endpoint, params, config).request
123
171
  end
172
+
173
+ # Like hashtags, but calls request! so an exception is raised
174
+ # if the request fails.
175
+ #
176
+ def hashtags!(value=nil, params={})
177
+ endpoint, params, config = common_endpoint(value, params,
178
+ Configuration::ENDPOINTS[:hashtags])
179
+ Connection.new(endpoint, params, config).request!
180
+ end
124
181
 
125
182
  # Extracts named entities (people, organizations and locations) and
126
183
  # values (URLs, emails, telephone numbers, currency amounts and percentages)
@@ -143,7 +200,16 @@ module AylienTextApi
143
200
  Configuration::ENDPOINTS[:entities])
144
201
  Connection.new(endpoint, params, config).request
145
202
  end
146
-
203
+
204
+ # Like entities, but calls request! so an exception is raised
205
+ # if the request fails.
206
+ #
207
+ def entities!(value=nil, params={})
208
+ endpoint, params, config = common_endpoint(value, params,
209
+ Configuration::ENDPOINTS[:entities])
210
+ Connection.new(endpoint, params, config).request!
211
+ end
212
+
147
213
  # Detects the main language a document is written in and returns it
148
214
  # in ISO 639-1 format.
149
215
  #
@@ -161,7 +227,16 @@ module AylienTextApi
161
227
  Configuration::ENDPOINTS[:language])
162
228
  Connection.new(endpoint, params, config).request
163
229
  end
164
-
230
+
231
+ # Like language, but calls request! so an exception is raised
232
+ # if the request fails.
233
+ #
234
+ def language!(value=nil, params={})
235
+ endpoint, params, config = common_endpoint(value, params,
236
+ Configuration::ENDPOINTS[:language])
237
+ Connection.new(endpoint, params, config).request!
238
+ end
239
+
165
240
  # Detects sentiment of a document in terms of
166
241
  # polarity ("positive" or "negative") and
167
242
  # subjectivity ("subjective" or "objective").
@@ -182,7 +257,15 @@ module AylienTextApi
182
257
  Configuration::ENDPOINTS[:sentiment])
183
258
  Connection.new(endpoint, params, config).request
184
259
  end
185
-
260
+
261
+ # Like sentiment, but calls request! so an exception is raised
262
+ # if the request fails.
263
+ #
264
+ def sentiment!(value=nil, params={})
265
+ endpoint, params, config = common_endpoint(value, params,
266
+ Configuration::ENDPOINTS[:sentiment])
267
+ Connection.new(endpoint, params, config).request!
268
+ end
186
269
  # Summarizes an article into a few key sentences.
187
270
  #
188
271
  # @param [String] value (nil) URL or Text
@@ -212,7 +295,16 @@ module AylienTextApi
212
295
  Configuration::ENDPOINTS[:summarize])
213
296
  Connection.new(endpoint, params, config).request
214
297
  end
215
-
298
+
299
+ # Like summarize, but calls request! so an exception is raised
300
+ # if the request fails.
301
+ #
302
+ def summarize!(value=nil, params={})
303
+ endpoint, params, config = common_endpoint(value, params,
304
+ Configuration::ENDPOINTS[:summarize])
305
+ Connection.new(endpoint, params, config).request!
306
+ end
307
+
216
308
  # Returns phrases related to the provided unigram, or bigram.
217
309
  #
218
310
  # @param [String] value (nil) URL or Text
@@ -231,6 +323,15 @@ module AylienTextApi
231
323
  Connection.new(endpoint, params, config).request
232
324
  end
233
325
 
326
+ # Like related, but calls request! so an exception is raised
327
+ # if the request fails.
328
+ #
329
+ def related!(value=nil, params={})
330
+ endpoint, params, config = common_endpoint(value, params,
331
+ Configuration::ENDPOINTS[:related])
332
+ Connection.new(endpoint, params, config).request!
333
+ end
334
+
234
335
  # Return Microformats.
235
336
  #
236
337
  # @param [String] value (nil) URL
@@ -250,6 +351,15 @@ module AylienTextApi
250
351
  Connection.new(endpoint, params, config).request
251
352
  end
252
353
 
354
+ # Like microformats, but calls request! so an exception is raised
355
+ # if the request fails.
356
+ #
357
+ def microformats!(value=nil, params={})
358
+ endpoint, params, config = common_endpoint(value, params,
359
+ Configuration::ENDPOINTS[:microformats])
360
+ Connection.new(endpoint, params, config).request!
361
+ end
362
+
253
363
  # Return Unsupervised Classify.
254
364
  #
255
365
  # @param [String] value (nil) URL or Text
@@ -270,6 +380,15 @@ module AylienTextApi
270
380
  Connection.new(endpoint, params, config).request
271
381
  end
272
382
 
383
+ # Like unsupervised_classify, but calls request! so an exception is raised
384
+ # if the request fails.
385
+ #
386
+ def unsupervised_classify!(value=nil, params={})
387
+ endpoint, params, config = common_endpoint(value, params,
388
+ Configuration::ENDPOINTS[:unsupervised_classify])
389
+ Connection.new(endpoint, params, config).request!
390
+ end
391
+
273
392
  # Runs multiple analysis operations in one API call.
274
393
  #
275
394
  # @param [String] value (nil) URL or Text
@@ -288,6 +407,14 @@ module AylienTextApi
288
407
  Connection.new(endpoint, params, config).request
289
408
  end
290
409
 
410
+ # Like combined, but calls request! so an exception is raised
411
+ # if the request fails.
412
+ #
413
+ def combined!(value=nil, params={})
414
+ endpoint, params, config = common_endpoint(value, params,
415
+ Configuration::ENDPOINTS[:combined])
416
+ Connection.new(endpoint, params, config).request!
417
+ end
291
418
  # Assigns relevant tags to an image.
292
419
  #
293
420
  # @param [String] value (nil) URL
@@ -302,6 +429,15 @@ module AylienTextApi
302
429
  Configuration::ENDPOINTS[:image_tags])
303
430
  Connection.new(endpoint, params, config).request
304
431
  end
432
+
433
+ # Like image_tags, but calls request! so an exception is raised
434
+ # if the request fails.
435
+ #
436
+ def image_tags!(value=nil, params={})
437
+ endpoint, params, config = common_endpoint(value, params,
438
+ Configuration::ENDPOINTS[:image_tags])
439
+ Connection.new(endpoint, params, config).request!
440
+ end
305
441
 
306
442
  private
307
443
 
@@ -324,6 +460,18 @@ module AylienTextApi
324
460
  params[:text] = value
325
461
  end
326
462
  end
463
+
464
+ if endpoint == Configuration::ENDPOINTS[:classify_by_taxonomy]
465
+ if params[:taxonomy] && !params[:taxonomy].empty?
466
+ endpoint = Configuration::ENDPOINTS[:classify_by_taxonomy]
467
+ .gsub(/\:taxonomy/, params[:taxonomy])
468
+ else
469
+ error_message = "Invalid taxonomy. Taxonomy can't be blank."
470
+ error = AylienTextApi::Error::InvalidInput.new(error_message)
471
+ raise error
472
+ end
473
+ end
474
+
327
475
  config = {}
328
476
  Configuration::VALID_CONFIG_KEYS.each do |key|
329
477
  config[key] = send(key)
@@ -28,6 +28,7 @@ module AylienTextApi
28
28
  ENDPOINTS = {
29
29
  extract: 'extract',
30
30
  classify: 'classify',
31
+ classify_by_taxonomy: 'classify/:taxonomy',
31
32
  concepts: 'concepts',
32
33
  entities: 'entities',
33
34
  hashtags: 'hashtags',
@@ -16,7 +16,10 @@ module AylienTextApi
16
16
  class Error < StandardError
17
17
  # Raised when Aylien Text API returns a 4xx HTTP status code
18
18
  ClientError = Class.new(self)
19
-
19
+
20
+ # Raised when Aylien Text API input is invalid
21
+ InvalidInput = Class.new(ClientError)
22
+
20
23
  # Raised when Aylien Text API returns the HTTP status code 400
21
24
  BadRequest = Class.new(ClientError)
22
25
 
@@ -68,7 +71,7 @@ module AylienTextApi
68
71
  500 => AylienTextApi::Error::InternalServerError,
69
72
  502 => AylienTextApi::Error::BadGateway,
70
73
  503 => AylienTextApi::Error::ServiceUnavailable,
71
- 504 => AylienTextApi::Error::GatewayTimeout,
74
+ 504 => AylienTextApi::Error::GatewayTimeout
72
75
  }
73
76
 
74
77
  class << self
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module AylienTextApi
16
- VERSION = "0.3.0" unless defined? AylienTextApi::VERSION
16
+ VERSION = "0.4.0" unless defined? AylienTextApi::VERSION
17
17
  end
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.aylien.com/api/v1/classify/iab-qag
6
+ body:
7
+ encoding: US-ASCII
8
+ string: text=CCTV+footage+shows+the+moment+a+suicide+car+bomber+detonates%0A++++++a+device+in+Beirut+on+Tuesday.+The+incident+took+place+in+an+area%0A++++++of+support+for+Hezbollah+and+left+four+people+dead+with+many+more+wounded.%0A++++++A+group+calling+itself+the+al-Nusra+Front+in+Lebanon+has+claimed%0A++++++responsibility+for+the+attack+saying+it+was+in+retaliation+for%0A++++++Hezbollah%27s+military+support+of+president+Bashar+al-Assad%27s+forces+in+Syria&taxonomy=iab-qag
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Aylien Text API Ruby Gem 0.4.0
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ response:
19
+ status:
20
+ code: 403
21
+ message: Forbidden
22
+ headers:
23
+ Server:
24
+ - openresty/1.7.7.2
25
+ Date:
26
+ - Thu, 17 Sep 2015 11:17:32 GMT
27
+ Content-Type:
28
+ - text/plain; charset=us-ascii
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ body:
34
+ encoding: UTF-8
35
+ string: Authentication parameters missing
36
+ http_version:
37
+ recorded_at: Thu, 17 Sep 2015 11:17:32 GMT
38
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,57 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.aylien.com/api/v1/classify/iab-qag
6
+ body:
7
+ encoding: US-ASCII
8
+ string: wrong_param=CCTV+footage+shows+the+moment+a+suicide+car+bomber+detonates%0A++++++a+device+in+Beirut+on+Tuesday.+The+incident+took+place+in+an+area%0A++++++of+support+for+Hezbollah+and+left+four+people+dead+with+many+more+wounded.%0A++++++A+group+calling+itself+the+al-Nusra+Front+in+Lebanon+has+claimed%0A++++++responsibility+for+the+attack+saying+it+was+in+retaliation+for%0A++++++Hezbollah%27s+military+support+of+president+Bashar+al-Assad%27s+forces+in+Syria&taxonomy=iab-qag
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Aylien Text API Ruby Gem 0.4.0
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ X-Aylien-Textapi-Application-Id:
19
+ - "<PASSWORD>"
20
+ X-Aylien-Textapi-Application-Key:
21
+ - "<PASSWORD>"
22
+ response:
23
+ status:
24
+ code: 400
25
+ message: Bad Request
26
+ headers:
27
+ Server:
28
+ - openresty/1.7.7.2
29
+ Date:
30
+ - Thu, 17 Sep 2015 11:17:30 GMT
31
+ Content-Type:
32
+ - application/json;charset=UTF-8
33
+ Content-Length:
34
+ - '219'
35
+ Connection:
36
+ - keep-alive
37
+ X-Ratelimit-Limit:
38
+ - '207000'
39
+ X-Ratelimit-Remaining:
40
+ - '206407'
41
+ X-Ratelimit-Reset:
42
+ - '1442534400'
43
+ body:
44
+ encoding: UTF-8
45
+ string: |-
46
+ {
47
+ "error": "requirement failed: either text or url is required",
48
+ "errors": [{
49
+ "reason": "required",
50
+ "message": "either text or url is required",
51
+ "locationType": "parameter",
52
+ "location": "text"
53
+ }]
54
+ }
55
+ http_version:
56
+ recorded_at: Thu, 17 Sep 2015 11:17:31 GMT
57
+ recorded_with: VCR 2.9.3