Elixir interface for the Lokalise APIv2.
View the Project on GitHub lokalise/elixir-lokalise-api
config :elixir_lokalise_api, base_url_api: "YOUR_API_BASE_URL"
config :elixir_lokalise_api, base_url_oauth2: "YOUR_OAUTH2_BASE_URL"
PermissionTemplates
endpoint:{:ok, %PermissionTemplatesCollection{} = templates} = PermissionTemplates.all(team_id)
template = hd(templates)
template.id # => 1
template.role # => "Manager"
template.permissions # => ['branches_main_modify', ...]
template.description # => 'Manage project settings ...'
template.tag # => 'Full access'
template.tagColor # => 'green'
template.tagInfo # => ''
template.doesEnableAllReadOnlyLanguages # => true
role_id
attribute to the user group object. For example:group = TeamUserGroups.find(team_id, group_id)
group.role_id # => 5
role_id
attribute to the contributor object. For example:contributor = Contributors.find(project_id, contributor_id)
contributor.role_id # => 5
{:ok, %KeysCollection{} = keys} = Keys.all(@project_id, limit: 2, pagination: "cursor", cursor: "eyIxIjozNzk3ODEzODh9")
keys.per_page_limit # => 2
keys.next_cursor # => "eyIxIjo0NTc4NDUxMDd9"
oauth2_client_id
and oauth2_client_secret
. For example, you can say:config :elixir_lokalise_api, oauth2_client_id: {:system, "OAUTH_CLIENT_ID"}
# 1. Generate an authentication URL:
uri = ElixirLokaliseApi.OAuth2.Auth.auth(
["read_projects", "write_tasks"], # scopes
"http://example.com/callback", # redirect uri
"secret state" # state
)
# 2. The user should visit this URL. They'll be redirected to the callback along with a secret code.
# 3. Use the secret code to obtain an access token:
{:ok, response} = ElixirLokaliseApi.OAuth2.Auth.token("secret code")
response.access_token # => 123abc
response.refresh_token # => 345xyz
# 4. Use the refresh token to obtain a new access token:
{:ok, response} = ElixirLokaliseApi.OAuth2.Auth.refresh("OAUTH2_REFRESH_TOKEN")
response.access_token # => 789xyz
{:ok, %{} = resp} = Files.delete(project_id, file_id)
resp.file_deleted # => true
resp.project_id # => "123.abc"
config :elixir_lokalise_api, oauth2_token: "YOUR_API_OAUTH2_TOKEN"
:oauth2_token |> ElixirLokaliseApi.Config.put_env(oauth2_token)
TeamUserBillingDetails
endpointSegments
endpointconfig :your_app, api_token: "LOKALISE_API_TOKEN"
, you should now provide config in the following way:config :elixir_lokalise_api, api_token: "LOKALISE_API_TOKEN"
# OR
config :elixir_lokalise_api, api_token: {:system, "ENV_VARIABLE_NAME"} # for env variables
:request_options
inside the config.exs
, for example:config :elixir_lokalise_api,
api_token: {:system, "LOKALISE_API_TOKEN"},
request_options: [
timeout: 5000,
recv_timeout: 5000
]