日本時間5月16日のContent Cloud Summitで、カスタムアプリにBox AI APIを活用する方法を紹介します。

詳細を表示

既存のタスクの変更

ガイド タスク 既存のタスクの変更

既存のタスクの変更

Boxでタスクを更新するには、タスクのIDを指定してPUT /tasks/:task_id APIを呼び出す必要があります。このAPIを使用すると、タスクのactionタイプの変更、messageの追加、期日の変更を行うことができます。

cURL
curl -i -X PUT "https://api.box.com/2.0/tasks/12345" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "action": "review"
     }'
.NET
var updates = new BoxTaskUpdateRequest()
{
    Id = "22222",
    Message = "Could you please review this?"
};
BoxTask updatedTask = await client.TasksManager.UpdateTaskAsync(updates);
Java
BoxTask task = new BoxTask(api, "id");
BoxTask.Info info = task.new Info();
info.setMessage("An edited message.");
task.updateInfo(info);
Python
task_update = {'message': 'New Message', 'due_at': '2014-04-03T11:09:43-10:00'}
updated_task = client.task(task_id='12345').update_info(data=task_update)
print(f'New task message is {updated_task.message} and the new due time is {updated_task.due_at}')
Node
client.tasks.update('11111', { message: 'Could you please review?' })
	.then(task => {
		/* task -> {
			type: 'task',
			id: '11111',
			item: 
			{ type: 'file',
				id: '22222',
				sequence_id: '0',
				etag: '0',
				sha1: '0bbd79a105c504f99573e3799756debba4c760cd',
				name: 'box-logo.png' },
			due_at: '2014-04-03T11:09:43-07:00',
			action: 'review',
			message: 'Could you please review?',
			task_assignment_collection: { total_count: 0, entries: [] },
			is_completed: false,
			created_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			created_at: '2013-04-03T11:12:54-07:00' }
		*/
	});

タスクのアクション

Boxは現在、action値によって定義される、reviewcompleteという2種類のタスクをサポートしています。

タスクのタイプによって、タスクがなりうる解決状態と、ウェブアプリおよびモバイルアプリでユーザーに表示されるインターフェースが決まります。

タスクのアクション考えられる解決状態
reviewincomplete, approved, rejected
completeincomplete, complete

reviewタスクはincomplete状態で開始され、incompleteapproved、またはrejectedとしてマークすることができます。ユーザーインターフェースには、テキストボックスのほか、タスクを承認または拒否する1組のボタンが表示されます。

completeタスクはincomplete状態で開始され、incompleteまたはcompletedとしてマークすることができます。このタスクが完了としてマークされると、タスクの状態をそれ以上変更することはできなくなります。ユーザーインターフェースには、テキストボックスのほか、タスクを完了としてマークするためのボタンが表示されます。

完了のルール

ファイルに関連するタスクは、そのファイルの複数のコラボレータに割り当てることができます。また、タスクのcompletion_ruleを使用すると、タスクを完了する必要があるのはタスクが割り当てられているすべてのユーザー (all_assignees) か1人の担当者のみ (any_assignee) かを定義できます。