Skip to content

Collections

當前用戶創建收藏操作

掛載功能

  • like/unlike
  • favorite/unfavorite
  • subscribe/unsubscribe
  • tags

CURD Resource

[GET][AUTH][CURRENT_USER] /api/collections

取得當前用戶收藏清單。

response

json
{
	"data": [
		{
			"id": 1,
			"user_id": 1,
			"slug": "9c6947c0-fa7e-422d-a83e-44354dcd6f77",
			"name": "hello collection",
			"description": null,
			"visibility": "public",
			"created_at": "2024-06-30T15:04:53.000000Z",
			"updated_at": "2024-06-30T15:04:53.000000Z",
			"deleted_at": null
		},
		{
			"id": 2,
			"user_id": 1,
			"slug": "hello-collection",
			"name": "hello collection",
			"description": "hello collection",
			"visibility": "public",
			"created_at": "2024-06-30T15:09:51.000000Z",
			"updated_at": "2024-06-30T15:09:51.000000Z",
			"deleted_at": null
		},
	],
		"links": {
		"first": "http:\/\/nordpress-next.test\/api\/collections?page=1",
		"last": "http:\/\/nordpress-next.test\/api\/collections?page=1",
		"prev": null,
		"next": null
	},
	"meta": {
		"current_page": 1,
		"from": 1,
		"last_page": 1,
		"links": [
			{
				"url": null,
				"label": "« Previous",
				"active": false
			},
			{
				"url": "http:\/\/nordpress-next.test\/api\/collections?page=1",
				"label": "1",
				"active": true
			},
			{
				"url": null,
				"label": "Next »",
				"active": false
			}
		],
		"path": "http:\/\/nordpress-next.test\/api\/collections",
		"per_page": 10,
		"to": 3,
		"total": 3
	}
}

[POST][AUTH][CURRENT_USER] /api/collections

建立當前用戶收藏集。

validation

  • name: required,str:255
  • slug: sometimes,required,alpha_dash,min:3,max:255,unique
  • description: nullable,str
  • visibility: required, in:public,private

request

json
{
	"name": "hello collection",
	"visibility": "public",
	"slug": "hello-coll1ection",
	"description": "hello collection"
}

response

json
{
	"data": {
		"user_id": 1,
		"slug": "hello-coll1ection",
		"name": "hello collection",
		"description": "hello collection",
		"visibility": "public",
		"updated_at": "2024-06-30T15:09:59.000000Z",
		"created_at": "2024-06-30T15:09:59.000000Z",
		"id": 3
	}
}

[GET][AUTH][CURRENT_USER] /api/collections/:id

當前用戶取得指定收藏集。

response

json
{
	"data": {
		"id": 2,
		"user_id": 1,
		"slug": "hello-collection",
		"name": "hello collection",
		"description": "hello collection",
		"visibility": "public",
		"created_at": "2024-06-30T15:09:51.000000Z",
		"updated_at": "2024-06-30T15:09:51.000000Z",
		"deleted_at": null
	}
}

[PUT][AUTH][CURRENT_USER] /api/collections/:id

更新當前用戶創建的收藏集。

request

json
{
	"name": "aaaaa",
	"slug": "aaaaaa"
}

response

json
{
	"data": {
		"id": 1,
		"user_id": 1,
		"slug": "aaaaaa",
		"name": "aaaaa",
		"description": null,
		"visibility": "public",
		"created_at": "2024-06-30T15:04:53.000000Z",
		"updated_at": "2024-06-30T15:15:20.000000Z",
		"deleted_at": null
	}
}

[DELETE][AUTH][CURRENT_USER] /api/collections/:id

刪除當前用戶創建的收藏集。

response

HTTP_NO_CONTENT = 204

[POST][AUTH][CURRENT_USER] /api/collections/:id/subscribes/toggle

當前用戶對指定收藏集訂閱/取消訂閱。

response

subscribe

json
{
	"data": {
		"attached": [
			1
		],
		"detached": [],
		"count": 1
	}
}

unsubscribe

json
{
	"data": {
		"attached": [],
		"detached": [
			1
		],
		"count": 0
	}
}

[POST][AUTH][CURRENT_USER] /api/collections/:id/likes/toggle

當前用戶對指定收藏集按讚/取消按讚。

response

like

json
{
	"data": {
		"attached": [
			1
		],
		"detached": [],
		"count": 1
	}
}

unlike

json
{
	"data": {
		"attached": [],
		"detached": [
			1
		],
		"count": 0
	}
}

[POST][AUTH][CURRENT_USER] /api/collections/:id/favorites/toggle

當前用戶對指定收藏集最愛/取消最愛。

response

favorite

json
{
	"data": {
		"attached": [
			1
		],
		"detached": [],
		"count": 1
	}
}

unfavorite

json
{
	"data": {
		"attached": [],
		"detached": [
			1
		],
		"count": 0
	}
}

[POST][AUTH][CURRENT_USER] /api/collections/:id/toggle

當前用戶創建的收藏集加入 [link, note, highlight]。

validation

  • collectable_type: required, str, in: [link, note, highlight]
  • collectable_id: required, array[id as integer]

request

json
{
	"collectable_type": "link",
	"collectable_id": [1,2,3]
}

response

added

json
{
	"data": {
		"attached": [
			1
		],
		"detached": [],
		"type": "link"
	}
}

remove

json
{
	"data": {
		"attached": [],
		"detached": [
			1
		],
		"type": "link"
	}
}