Ruby interface for the Lokalise APIv2 that represents returned data as Ruby objects.
View the Project on GitHub lokalise/ruby-lokalise-api
jwt
method. It is now mandatory to provide the project ID to request JWT for:resp = @client.jwt("123.abcd")
resp.jwt # => 'eyJ0eXAiOi...`
Jwt
endpoint. You can now request JWT easily (please note that these tokens are used only to work with OTA):resp = @client.jwt
resp.jwt # => 'eyJ0eXAiOi...`
#token
and #refresh
methods (used to request OAuth 2 access and refresh tokens) now return proper Ruby objects:RubyLokaliseApi.auth_client('client_id', 'client_secret')
# Previously:
token = auth_client.token 'oauth2_code' # this method used to return a hash
token['access_token']
token['refresh_token']
refresh = auth_client.refresh 'refresh_token' # this method used to return a hash
token['access_token']
token['expires_in']
# NOW:
token = auth_client.token 'oauth2_code' # this is an instance of the Token class
token.access_token
token.refresh_token
refresh = auth_client.refresh 'refresh_token' # this is an instance of the Refresh class
token.access_token
token.expires_in
auth_client = RubyLokaliseApi.auth_client('id', 'secret', timeout: 5, open_timeout: 10)
New feature: added ability to access resources’ attributes with the []
notation. In other words, previously you could only write:
branch.branch_id
branch.name
Now you can also write:
branch[:branch_id]
branch['name']
This feature was introduced so that all resources can play nicely with methods like pluck
.
Lokalise
main module to RubyLokaliseApi
and changed the way you require the gem. You can use find-replace to fix all occurences. For example, if previously you wrote:require 'ruby-lokalise-api'
@client = Lokalise.client 'YOUR_TOKEN_HERE'
Now you should say:
require 'ruby_lokalise_api'
@client = RubyLokaliseApi.client 'YOUR_TOKEN_HERE'
enable_compression
option. Compression is now enabled for all requests (however the API might still send uncompressed data if the body is small) and the response will be decompressed automatically.auth_client = RubyLokaliseApi.auth_client 'OAUTH2_CLIENT_ID', 'OAUTH2_CLIENT_SECRET'
# Generate authentication URL:
url = auth_client.auth scope: %w[read_projects write_tasks]
# Generate a new token:
response = auth_client.token 'secret code'
access_token = response['access_token']
refresh_token = response['refresh_token']
# Refresh an expired token:
response = auth_client.refresh('YOUR_REFRESH_TOKEN')['access_token']
# Use the access token to perform requests on the user's behalf:
@client = RubyLokaliseApi.oauth2_client access_token
@client.projects # list user's projects
client
(issues with multithreading)Segments
endpointTeamUserBillingDetails
endpoint.oauth_client
method for the Lokalise
module. This method must be used when you’re initializing a new API client with a token obtained via OAuth 2 flow, not by copy-pasting the token from the “Personal profile” section on Lokalise website. So in this case instead of saying RubyLokaliseApi.client
, you should do the following:@client = RubyLokaliseApi.oauth_client("TOKEN_OBTAINED_VIA_OAUTH2", params)
params
are the same as for the .client
method..reset_oauth_client!
method for the Lokalise
module to reset the currently set oauth_client
.RubyLokaliseApi.reset_oauth_client! # effectively sets the `@oauth_client` to `nil`
:enable_compression
option to true
:client = RubyLokaliseApi.client('YOUR_TOKEN', enable_compression: true)
task_id
attribute for the Translation
modelpayment_method
and dry_run
attributes to Order
auto_close_items
attribute for the Task
endpointContributor
and Key
queue
parameter doesn’t have any effect anymore. Therefore, removed all code and docs related to sync uploading.queued_process = @client.upload_file project_id,
data: 'Base-64 encoded data... ZnI6DQogI...',
filename: 'my_file.yml',
lang_iso: 'en'
queued_process.status # => 'queued'
# ...after some time...
queued_process = queued_process.reload_data
queued_process.status # => 'finished'
QueuedProcess
endpointreload_data
method which fetches new data from the API@client.regenerate_webhook_secret(project_id, webhook_id)
webhook.regenerate_secret
https://api.lokalise.com/api2/
instead of https://api.lokalise.co/api2/
branch.merge params
client.merge_branch project_id, branch_id, params
Branch
endpointWebhook
endpoint (thanks to @snkashis for help!):timeout
and :open_timeout
options for the client to customize request timeoutsTranslationStatus
endpointTeamUserGroup
endpointOrder
, TranslationProvider
, and PaymentCard
endpointsDELETE
requests with bodies. It seems like Faraday team decided to abandon the idea of writing delete request one-liners, so we’ll stick with another approach#delete
interface methods to #destroy
next_page?
, last_page?
, prev_page?
, first_page?
, next_page
, prev_page
)