|
46 | 46 | # This ensures backwards compatibility if OpenSSL behavior changes |
47 | 47 | end |
48 | 48 |
|
| 49 | +# Ruby SDK for Lingo.dev localization and translation API. |
| 50 | +# |
| 51 | +# This module provides a simple and powerful interface for localizing content |
| 52 | +# in Ruby applications. It supports text, object (Hash), and chat message |
| 53 | +# localization with batch operations, progress tracking, and concurrent processing. |
| 54 | +# |
| 55 | +# @example Basic usage |
| 56 | +# engine = LingoDotDev::Engine.new(api_key: 'your-api-key') |
| 57 | +# result = engine.localize_text('Hello world', target_locale: 'es') |
| 58 | +# puts result # => "Hola mundo" |
| 59 | +# |
| 60 | +# @see Engine |
49 | 61 | module LingoDotDev |
| 62 | + # Base error class for all SDK errors. |
50 | 63 | class Error < StandardError; end |
| 64 | + |
| 65 | + # Error raised for invalid arguments. |
51 | 66 | class ArgumentError < Error; end |
| 67 | + |
| 68 | + # Error raised for API request failures. |
52 | 69 | class APIError < Error; end |
| 70 | + |
| 71 | + # Error raised for server-side errors (5xx responses). |
53 | 72 | class ServerError < APIError; end |
| 73 | + |
| 74 | + # Error raised for authentication failures. |
54 | 75 | class AuthenticationError < APIError; end |
| 76 | + |
| 77 | + # Error raised for validation failures (invalid input or configuration). |
55 | 78 | class ValidationError < ArgumentError; end |
56 | 79 |
|
| 80 | + # Configuration for the Lingo.dev Engine. |
| 81 | + # |
| 82 | + # Holds API credentials and batch processing settings. |
57 | 83 | class Configuration |
58 | | - attr_accessor :api_key, :api_url, :batch_size, :ideal_batch_item_size |
59 | | - |
| 84 | + # @return [String] the Lingo.dev API key |
| 85 | + attr_accessor :api_key |
| 86 | + |
| 87 | + # @return [String] the API endpoint URL |
| 88 | + attr_accessor :api_url |
| 89 | + |
| 90 | + # @return [Integer] maximum number of items per batch (1-250) |
| 91 | + attr_accessor :batch_size |
| 92 | + |
| 93 | + # @return [Integer] target word count per batch item (1-2500) |
| 94 | + attr_accessor :ideal_batch_item_size |
| 95 | + |
| 96 | + # Creates a new Configuration instance. |
| 97 | + # |
| 98 | + # @param api_key [String] your Lingo.dev API key (required) |
| 99 | + # @param api_url [String] the API endpoint URL (default: 'https://engine.lingo.dev') |
| 100 | + # @param batch_size [Integer] maximum items per batch, 1-250 (default: 25) |
| 101 | + # @param ideal_batch_item_size [Integer] target word count per batch item, 1-2500 (default: 250) |
| 102 | + # |
| 103 | + # @raise [ValidationError] if any parameter is invalid |
60 | 104 | def initialize(api_key:, api_url: 'https://engine.lingo.dev', batch_size: 25, ideal_batch_item_size: 250) |
61 | 105 | @api_key = api_key |
62 | 106 | @api_url = api_url |
|
0 commit comments