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




Comments

Fetch project comments

Doc

@client.project_comments(project_id, params = {})   # Input:
                                                    ## project_id (string, required)
                                                    ## params (hash)
                                                    ### :page and :limit
                                                    # Output:
                                                    ## Collection of comments available in the given project

For example:

project_id = '123.abc'
key_id = 1234

comments = test_client.project_comments project_id, key_id, page: 2, limit: 3

comments[0].comment_id # => 789
comments[0].comment # => '<p>Hi!</p>'

Fetch key comments

Doc

@client.comments(project_id, key_id, params = {})   # Input:
                                                    ## project_id (string, required)
                                                    ## key_id (string, required)
                                                    ## params (hash)
                                                    ### :page and :limit
                                                    # Output:
                                                    ## Collection of comments available for the specified key in the given project

For example:

project_id = '123.abc'
key_id = 1234

comments = @client.comments project_id, key_id, limit: 1, page: 2

comments[0].comment_id # => 789
comments[0].comment # => '<p>Hi!</p>'

Alternatively:

params = {
  page: 2,
  limit: 3
}

project = @client.project project_id

comments = project.key_comments key_id, params

# OR

key = @client.key project_id, key_id
comments = key.key_comments params

Create key comments

Doc

@client.create_comments(project_id, key_id, params)   # Input:
                                                      ## project_id (string, required)
                                                      ## key_id (string, required)
                                                      ## params (array or hash, required) - contains parameter of newly created comments. Pass array of hashes to create multiple comments, or a hash to create a single comment
                                                      ### :comment (string, required)
                                                      # Output:
                                                      ## Newly created comment

For example:

params = [
  {comment: 'demo comment'},
  {comment: 'another comment'}
]

comments = @client.create_comments project_id, key_id, params

comments[0].comment # => 'demo comment'

Alternatively:

project = @client.project project_id

comments = project.create_comments key_id, params

# OR

key = @client.key project_id, key_id
comments = key.create_comments params

Fetch key comment

Doc

@client.comment(project_id, key_id, comment_id)   # Input:
                                                  ## project_id (string, required)
                                                  ## key_id (string, required)
                                                  ## comment_id (string, required)
                                                  # Output:
                                                  ## Comment for the key in the given project

For example:

comment = @client.comment project_id, key_id, comment_id

comment.comment_id # => 1234
comment.comment # => '<p>Hi!</p>'

Alternatively:

project = @client.project project_id

comment = project.key_comment key_id, comment_id

# OR

key = @client.key project_id, key_id
comment = key.key_comment comment_id

Delete key comment

Doc

@client.destroy_comment(project_id, key_id, comment_id)   # Input:
                                                          ## project_id (string, required)
                                                          ## key_id (string, required)
                                                          ## comment_id (string, required)
                                                          # Output:
                                                          ## Generic object with the project id and "comment_deleted"=>true

For example:

response = @client.destroy_comment project_id, key_id, comment_id

response.comment_deleted # => true

Alternatively:

comment = @client.comment project_id, key_id, comment_id

response = comment.destroy

# OR

project = @client.project project_id
response = project.destroy_comment key_id, comment_id

# OR

key = @client.key project_id, key_id
response = key.destroy_comment comment_id