Lokalise APIv2 Ruby SDK

Ruby interface for the Lokalise APIv2 that represents returned data as Ruby objects.

View the Project on GitHub lokalise/ruby-lokalise-api




Webhooks

Fetch webhooks

Doc

@client.webhooks(project_id, params = {}) # Input:
                                          ## project_id (string, required)
                                          ## params (hash)
                                          ### :page and :limit
                                          # Output:
                                          ## Collection of webhooks for the project

For example:

@client.webhooks project_id, limit: 1, page: 2

Fetch a single webhook

Doc

@client.webhook(project_id, webhook_id)   # Input:
                                          ## project_id (string, required)
                                          ## webhook_id (string, required)
                                          # Output:
                                          ## Webhook for the given project

Create webhook

Doc

@client.create_webhook(project_id, params)    # Input:
                                              ## project_id (string, required)
                                              ## params (hash, required)
                                              ### :url (string, required) - webhook URL
                                              ### :events (array, required) - events to subscribe to. Check the API docs to find the list of supported events
                                              ### :event_lang_map (array) - map the event with an array of languages iso codes
                                              # Output:
                                              ## Created webhook

For example:

@client.create_webhook project_id,
                       url: 'http://example.com',
                       events: ['project.imported', 'project.exported']

Update webhook

Doc

@client.update_webhook(project_id, webhook_id, params)    # Input:
                                                          ## project_id (string, required)
                                                          ## webhook_id (string, required)
                                                          ## params (hash)
                                                          ### :url (string) - webhook URL
                                                          ### :events (array) - events to subscribe to. Check the API docs to find the list of supported events
                                                          ### :event_lang_map (array) - map the event with an array of languages iso codes
                                                          # Output:
                                                          ## Updated webhook

Alternatively:

webhook = @client.webhook(project_id, webhook_id)
webhook.update(params)

For example:

@client.update_webhook project_id,
                       new_webhook_id,
                       url: 'http://updated.example.com'

Delete webhook

Doc

@client.destroy_webhook(project_id, webhook_id)   # Input:
                                                  ## project_id (string, required)
                                                  ## webhook_id (string, required)
                                                  # Output:
                                                  ## Result of the delete operation

Alternatively:

webhook = @client.webhook(project_id, webhook_id)
webhook.destroy

Regenerate webhook secret

Doc

@client.regenerate_webhook_secret(project_id, webhook_id) # Input:
                                                          ## project_id (string, required)
                                                          ## webhook_id (string, required)
                                                          # Output:
                                                          ## Hash containing `project_id` and new `secret`

Alternatively:

webhook = @client.webhook(project_id, webhook_id)
webhook.regenerate_secret