Tasks
The SDK provides methods for working with tasks in Lokalise Vantage projects.
List tasks
Section titled “List tasks”Use tasks to retrieve tasks belonging to a project:
tasks = client.tasks('team-id', 'project-id')
tasks.each do |task| puts "#{task.public_id}: #{task.title} (#{task.status})"endReturns a LokaliseApiNext::Collections::Vantage::Tasks collection containing LokaliseApiNext::Models::Vantage::Task objects.
You can access individual task attributes:
task = tasks.first
puts task.idputs task.public_idputs task.titleputs task.typeputs task.statusputs task.descriptionputs task.task_assignmentsputs task.due_dateputs task.created_atputs task.requested_byTask assignments
Section titled “Task assignments”The task_assignments attribute contains an array of hashes with assignment details, including assignees and progress:
task.task_assignments.each do |assignment| puts assignment['languageId'] puts assignment['progress']['completedWords'] puts assignment['progress']['totalWords']endPagination and filtering
Section titled “Pagination and filtering”The tasks method supports cursor-based pagination and several filtering options.
For example, retrieve up to 20 tasks and include segments associated with their assignments:
tasks = client.tasks( 'team-id', 'project-id', limit: 20, 'include-segments': true)Set include-segments to true to include segments associated with each assignment. By default, these arrays are empty.
tasks.each do |task| task.task_assignments.each do |assignment| assignment['segments'].each do |segment| puts "#{segment['id']}: #{segment['status']}" end endendTo retrieve the next page, pass the cursor returned by the previous response:
if tasks.more? next_page = client.tasks( 'team-id', 'project-id', limit: 20, after: tasks.cursor, 'include-segments': true )endOther supported filters include:
filter-ids— Filter tasks by their identifiers.filter-item-ids— Filter tasks associated with specific project items.
Refer to the API documentation for accepted values and limits.