For example, to use Excon:
require 'excon' # somewhere in your code Faraday.default_adapter = :excon
All supported adapters are listed on Faraday official website.
Request timeouts may be adjusted during client initialization:
# The same approach will work with the `.oauth_client` method: @client = Lokalise.client('YOUR_TOKEN', open_timeout: 100, timeout: 500) @client.open_timeout # => 100 @client.timeout # => 500
Both values are in seconds. They can be adjusted later with simple accessors:
@client.open_timeout = 200 @client.timeout = 600 @client.open_timeout # => 200 @client.timeout # => 600
By default we are using a built-in JSON module but you may utilize any other parser by overriding the
#custom_load methods inside the
For example, to use Oj you would do the following:
require 'oj' module Lokalise module JsonHandler # This method accepts a Ruby object and must return a JSON string def custom_dump(obj) Oj.dump obj end # This method accepts JSON and must return Ruby object def custom_load(obj) Oj.load obj end end end
Lokalise API supports gzip compression but it’s off by default. If you’re working with large amounts of data it’s a good idea to enable it by setting the
enable_compression option to
# The same approach will work with the `.oauth_client` method: client = Lokalise.client('YOUR_TOKEN', enable_compression: true)
Now you can use the
client as usual and the API responses will be uncompressed automatically.