README.md in yandex_cloud-0.2.0 vs README.md in yandex_cloud-0.3.0

- old
+ new

@@ -26,31 +26,120 @@ You can use your Oauth token directly in spesific requests or put it to the ENV variables. ## Using -### Get IAM-token for cloud API access +## Get IAM-token for cloud API access Request for getting IAM-token for access to cloud API. Valid 12 hours. ```ruby # with oauth_token in ENV auth_service = YandexCloud::Auth.new auth_service.token -# or with oauth_token in request +# or with oauth_token in service declaration auth_service = YandexCloud::Auth.new(oauth_token: oauth_token) auth_service.token ``` #### Responses ```ruby # successful response -{ "iamToken" => iam_token } +{ 'iamToken' => iam_token } # response with errors -{ "code" => 16, "message" => "Token is invalid or has expired.", "details" => [...] } +{ 'code' => 16, 'message' => 'Token is invalid or has expired.', 'details' => [...] } +``` + +## Translate service + +### Configuration + +For using Translate service you need additionally get FOLDER_ID. + +Instruction for getting FOLDER_ID is [here](https://cloud.yandex.com/docs/translate/concepts/auth) + +You can use your FOLDER_ID directly in spesific requests or put it to the ENV variables. + +```ruby +# with FOLDER_ID in ENV +translator = YandexCloud::Translate.new(iam_token: iam_token) + +# or with FOLDER_ID in service declaration +translator = YandexCloud::Translate.new(iam_token: iam_token, folder_id: '12345') +``` + +#### Options + + iam_token - IAM-token, required + folder_id - folder ID of your account at YandexCloud, optional + +### Supported languages + +Request for getting list of supported languages is #languages. + +```ruby +translator.languages() +``` + +#### Responses + +```ruby +# successful response +{ 'languages' => [...] } + +# response with errors +{ 'error_message' => '' } +``` + +### Detection + +Request for detecting language of text is #detect. + +```ruby +translator.detect(text: 'Hello') +``` + +#### Options + + text - text for detection, required + hint - list of possible languages, optional, example - 'en,ru' + +#### Responses + +```ruby +# successful response +{ 'language' => 'es' } + +# response with errors +{ 'error_message' => '' } +``` + +### Translation + +Request for translating text is #translate. + +```ruby +translator.translate(text: 'Hola', target: 'en') +``` + +#### Options + + text - text for detection, required + source - source language, ISO 639-1 format (like 'en'), optional + target - target language, ISO 639-1 format (like 'ru'), required + format - text format, one of the [plain|html], default - plain, optional + +#### Responses + +```ruby +# successful response +{ 'translations' => [{ 'text' => 'Hello' }]} + +# response with errors +{ 'error_message' => '' } ``` ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/kortirso/yandex_cloud.