{
	"info": {
		"_postman_id": "b09683a7-72db-440f-b51d-e0a9487c2d3f",
		"name": "Appointment Manager - Integration Tests with Notification Manager",
		"description": "## Configuration\n\nIn order to run the tests the Appointment Manager must be configured to send notifications to the Notification Manager.",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "26367572"
	},
	"item": [
		{
			"name": "Create Availability",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"Check response status code\", function () {",
							"    pm.response.to.have.status(200);",
							"});",
							"",
							"pm.test(\"Check response body\", function () {",
							"    const payload = pm.response.json()",
							"    pm.expect(payload._id).to.be.a('string')",
							"    pm.variables.set('availabilityId', payload._id)",
							"});",
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Cookie",
						"value": "sid={{sid}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"startDate\": \"2023-09-20T09:00:00.000Z\",\n    \"endDate\": \"2023-09-20T18:00:00.000Z\",\n    \"slotDuration\": 60,\n    \"each\": \"day\",\n    \"untilDate\": \"2023-09-30T00:00:00.000Z\",\n    \"resourceId\": \"auth0|dr.mario.rossi\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrlAppointmentManager}}/availabilities/",
					"host": [
						"{{baseUrlAppointmentManager}}"
					],
					"path": [
						"availabilities",
						""
					]
				}
			},
			"response": []
		},
		{
			"name": "Appointment/post",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"Check response status code\", function () {",
							"    pm.response.to.have.status(200);",
							"});",
							"",
							"pm.test(\"Check response body\", function () {",
							"    const payload = pm.response.json()",
							"    pm.expect(payload._id).to.be.a('string')",
							"    pm.expect(payload.errors).to.be.empty",
							"    pm.variables.set('appointmentId', payload._id)",
							"});",
							"",
							"pm.test(\"Check response status code\", function () {",
							"    pm.response.to.have.status(200);",
							"});"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Cookie",
						"value": "sid={{sid}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"startDate\": \"2023-09-21T10:00:00Z\",\n    \"endDate\": \"2023-09-21T11:00:00Z\",\n    \"availabilityId\": \"{{availabilityId}}\",\n    \"ownerId\": \"auth0|dr.mario.rossi\",\n    \"participants\": [\n        \"auth0|dr.mario.rossi\",\n        \"auth0|giovanni.bianchi\"\n    ]\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrlAppointmentManager}}/appointments/",
					"host": [
						"{{baseUrlAppointmentManager}}"
					],
					"path": [
						"appointments",
						""
					]
				}
			},
			"response": []
		},
		{
			"name": "Appointment/patchById",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"Check response status code\", function () {",
							"    pm.response.to.have.status(200);",
							"});",
							"",
							"pm.test(\"Check response body\", function () {",
							"    const payload = pm.response.json()",
							"",
							"    const doctor1 = payload.data.participants.find(participant => participant.id === 'auth0|dr.mario.rossi')",
							"    const doctor2 = payload.data.participants.find(participant => participant.id === 'auth0|dr.lucia.verdi')",
							"",
							"    pm.expect(doctor1.type).to.equal('resourceId')",
							"    pm.expect(doctor2.type).to.equal('ownerId')",
							"    pm.expect(payload.errors).to.be.empty",
							"});"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "PATCH",
				"header": [
					{
						"key": "Cookie",
						"value": "sid={{sid}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"$set\": {\n        \"ownerId\": \"auth0|dr.lucia.verdi\"\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrlAppointmentManager}}/appointments/{{appointmentId}}",
					"host": [
						"{{baseUrlAppointmentManager}}"
					],
					"path": [
						"appointments",
						"{{appointmentId}}"
					]
				}
			},
			"response": []
		},
		{
			"name": "Appointment/deleteById",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"Check response status code\", function () {",
							"    pm.response.to.have.status(204);",
							"});",
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "DELETE",
				"header": [
					{
						"key": "Cookie",
						"value": "sid={{sid}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrlAppointmentManager}}/appointments/{{appointmentId}}",
					"host": [
						"{{baseUrlAppointmentManager}}"
					],
					"path": [
						"appointments",
						"{{appointmentId}}"
					]
				}
			},
			"response": []
		},
		{
			"name": "Appointment/post for patch deleted",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"Check response status code\", function () {",
							"    pm.response.to.have.status(200);",
							"});",
							"",
							"pm.test(\"Check response body\", function () {",
							"    const payload = pm.response.json()",
							"    pm.expect(payload._id).to.be.a('string')",
							"    pm.expect(payload.errors).to.be.empty",
							"    pm.variables.set('appointmentId', payload._id)",
							"});",
							"",
							"pm.test(\"Check response status code\", function () {",
							"    pm.response.to.have.status(200);",
							"});"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Cookie",
						"value": "sid={{sid}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"startDate\": \"2023-09-21T10:00:00Z\",\n    \"endDate\": \"2023-09-21T11:00:00Z\",\n    \"availabilityId\": \"{{availabilityId}}\",\n    \"ownerId\": \"auth0|dr.mario.rossi\",\n    \"participants\": [\n        \"auth0|dr.mario.rossi\",\n        \"auth0|giovanni.bianchi\"\n    ]\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrlAppointmentManager}}/appointments/",
					"host": [
						"{{baseUrlAppointmentManager}}"
					],
					"path": [
						"appointments",
						""
					]
				}
			},
			"response": []
		},
		{
			"name": "Appointment/patchStatus",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"Check response status code\", function () {",
							"    pm.response.to.have.status(200);",
							"});",
							"",
							"pm.test(\"Check response body\", function () {",
							"    const payload = pm.response.json()",
							"    pm.expect(payload.updated).to.equal(1)",
							"    pm.expect(payload.errors).to.be.empty",
							"});"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Cookie",
						"value": "sid={{sid}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "[\n    {\n        \"filter\": {\n            \"_id\": \"{{appointmentId}}\"\n        },\n        \"stateTo\": \"TRASH\"\n    }\n]",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrlAppointmentManager}}/appointments/state",
					"host": [
						"{{baseUrlAppointmentManager}}"
					],
					"path": [
						"appointments",
						"state"
					]
				}
			},
			"response": []
		},
		{
			"name": "Delete availability",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"Check response status code\", function () {",
							"    pm.response.to.have.status(204);",
							"});",
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "DELETE",
				"header": [
					{
						"key": "Cookie",
						"value": "sid={{sid}}",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{baseUrlAppointmentManager}}/availabilities/650bff64714ae80ee34199ca",
					"host": [
						"{{baseUrlAppointmentManager}}"
					],
					"path": [
						"availabilities",
						"650bff64714ae80ee34199ca"
					]
				}
			},
			"response": []
		}
	]
}