yandex_dictionary_api 0.1.0 → 0.1.1
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.
@@ -8,7 +8,7 @@ module YandexDictionaryApi
|
|
8
8
|
class ApiInterface
|
9
9
|
|
10
10
|
def initialize(api_key)
|
11
|
-
@client = YandexDictionaryApi::ApiClient.new(
|
11
|
+
@client = YandexDictionaryApi::ApiClient.new(api_key)
|
12
12
|
end
|
13
13
|
|
14
14
|
#Executes getLangs (list of supported languages) request to YandexDictionaryApi api
|
@@ -32,17 +32,17 @@ module YandexDictionaryApi
|
|
32
32
|
when 200
|
33
33
|
response
|
34
34
|
when 401
|
35
|
-
raise ApiError.new("Invalid api key.")
|
35
|
+
raise ApiError.new(response.code, "Invalid api key.")
|
36
36
|
when 402
|
37
|
-
raise ApiError.new("Spicified api key is blocked.")
|
37
|
+
raise ApiError.new(response.code, "Spicified api key is blocked.")
|
38
38
|
when 403
|
39
|
-
raise ApiError.new("The daily limit on the number of requests exceeded.")
|
39
|
+
raise ApiError.new(response.code, "The daily limit on the number of requests exceeded.")
|
40
40
|
when 413
|
41
|
-
raise ApiError.new("Limit on the size of text exceeded.")
|
41
|
+
raise ApiError.new(response.code, "Limit on the size of text exceeded.")
|
42
42
|
when 501
|
43
|
-
raise ApiError.new("Spicified direction of translation is not supported.")
|
43
|
+
raise ApiError.new(response.code, "Spicified direction of translation is not supported.")
|
44
44
|
else
|
45
|
-
raise ApiError.new("Try again later.")
|
45
|
+
raise ApiError.new(response.code, "Try again later.")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe YandexDictionaryApi do
|
4
4
|
|
5
5
|
before do
|
6
|
-
$interface = YandexDictionaryApi::ApiInterface.new("
|
6
|
+
$interface = YandexDictionaryApi::ApiInterface.new(ENV["KEY"])
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should return a list of supported languages" do
|