STARTHERE : General Guide


API BASE URL
https://api.deltasystematics360.com

Passing request paramaters/values

FOR POST/PATCH/DELETE and PUT REQUESTS - use JSON object e.g:

{
	parameter1: 'value',
	parameter2: 'value'
}

FOR GET REQUESTS, use URL query strings e.g:

http://apiurl.ext/endpoint?paramter1=value1&parameter2=value2

Authenticating REQUESTS

Include authorization header in calls to all endpoints marked:

---AUTHENTICATION REQUIRED---

If no token is supplied or provided token is invalid/expired, HTTP 400 error (status = fail) will be returned with code UNAUTHORISED

authorization: 'Bearer authenticated_admin_token'

API Responses (success, fail and error)

Success RESPONSE format - HTTP status code 2xx

{
	status: 'success',
	data: JSON payload of operation result
}

Errors - HTTP status codes 400 and 500

- `400` if any of the data was invalid. (status = fail)
- `500` with a database/server error (status = error)

Error RESPONSE format

{
	'status' : 'error|fail',
	'message': 'description of error',
	'code'  : 'error code (optional)'
}

POST /admin/login

Login admin with username and password

REQUEST format

{
	username: 'username',
	password: 'password',
	return_refresh_token: true|false (optional)
}

RESPONSE format

{
	status: 'success',
	data: {
		token: 'token for subsequent requests'
	}
}

PATCH /admin/password

Update/change admin password

---AUTHENTICATION REQUIRED---

REQUEST format

{
	old_password: 'old password',
	new_password: 'new password',
	return_refresh_token: true|false (optional)
}

RESPONSE format

{
	status: 'success',
	data: {
		token: 'new token'
	}
}

GET /admin/hospitals

Get all hospitals matching filter(s)

---AUTHENTICATION REQUIRED---

REQUEST format

To return all APPROVED hospitals, no parameter is required

To return all UNAPPROVED hospitals, append "?status=unapproved" to request URL
e.g https://api.deltasystematics360.com/admin/hospitals?status=unapproved

To return single hospital, append "?id=hospital_id" to request URL
e.g https://api.deltasystematics360.com/admin/hospitals?id=1	(hospital with id 1)

To return all hospitals with category(ies), append "?categories=categoryid1,categoryid2,etc" to request URL
e.g https://api.deltasystematics360.com/admin/categories?1		(hospitals with category id 1)
e.g https://api.deltasystematics360.com/admin/categories?1,2	(hospitals with category id 1 AND 2)

To return all hospitals in radius (miles) (not working yet), append "?center=lat,long&radius=number_of_miles" to request URL
e.g https://api.deltasystematics360.com/admin/hospitals?center=10.895,183.567&radius=4  (hospitals within 4 miles of center location)

RESPONSE format

{
	status: 'success',
	data: [
		{
			id: number,
			name: string,
			login: string,
			phones: [phone1, phone2, phone3],
			address: string,
			location: string,
			latitude: number (floating point/decimal/long),
			longitude: number (floating point/decimal/long),
			categories: [category1_title, category2_title, ...],
			work_hours: {
				mon: {open: string, close: string},
				tue: {open: string, close: string},
				wed: {open: string, close: string},
				thu: {open: string, close: string},
				fri: {open: string, close: string},
				sat: {open: string, close: string},
				sun: {open: string, close: string}
			},
			logo: url,
			banner: url,
			email: string,
			website: string,
			description: string
		},
		....
	]
}

GET /admin/hospitals/all

Get all hospitals, approved and unapproved

---AUTHENTICATION REQUIRED---

REQUEST format

No parameter is required

RESPONSE format

{
	status: 'success',
	data: [
		{
			id: number,
			name: string,
			login: string,
			phones: [phone1, phone2, phone3],
			address: string,
			location: string,
			latitude: number (floating point/decimal/long),
			longitude: number (floating point/decimal/long),
			categories: [category1_title, category2_title, ...],
			work_hours: {
				mon: {open: string, close: string},
				tue: {open: string, close: string},
				wed: {open: string, close: string},
				thu: {open: string, close: string},
				fri: {open: string, close: string},
				sat: {open: string, close: string},
				sun: {open: string, close: string}
			},
			logo: url,
			banner: url,
			email: string,
			website: string,
			description: string
		},
		....
	]
}

POST /admin/hospitals

Save new hospital record to database

---AUTHENTICATION REQUIRED---

REQUEST format

{
	name: string,
	login: string,
	password: string,
	phones: [phone1, phone2, phone3],
	address: string,
	location: string,
	latitude: number (floating point/decimal/long),
	longitude: number (floating point/decimal/long),
	categories: [category1_id, category2_id, ...],
	work_hours: {
		mon: {open: string, close: string},
		tue: {open: string, close: string},
		wed: {open: string, close: string},
		thu: {open: string, close: string},
		fri: {open: string, close: string},
		sat: {open: string, close: string},
		sun: {open: string, close: string}
	},
	logo: file (optional),
	banner: file (optional),
	email: string (optional),
	website: string (optional),
	description: string (optional)
}

RESPONSE format

{
	status: 'success',
	data: {
		new_hospital_id: id
	}
}

PATCH /admin/hospitals

Update hospital record in database

---AUTHENTICATION REQUIRED---

REQUEST format

{
	id: int,
	name: string,
	phones: [phone1, phone2, phone3],
	address: string,
	location: string,
	latitude: number (floating point/decimal/long),
	longitude: number (floating point/decimal/long),
	categories: [category1_id, category2_id, ...],
	work_hours: {
		mon: {open: string, close: string},
		tue: {open: string, close: string},
		wed: {open: string, close: string},
		thu: {open: string, close: string},
		fri: {open: string, close: string},
		sat: {open: string, close: string},
		sun: {open: string, close: string}
	},
	logo: file (optional),
	banner: file (optional),
	email: string (optional),
	website: string (optional),
	description: string (optional)
}

RESPONSE format

{
	status: 'success',
	data: 'Update successful'
}

DELETE /admin/hospitals

Delete hospital record from database

---AUTHENTICATION REQUIRED---

REQUEST format

{
	id: int
}

RESPONSE format

{
	status: 'success',
	data: 'Delete successful'
}

PUT /admin/hospitals

Mark hospital record as approved

---AUTHENTICATION REQUIRED---

REQUEST format

{
	id: int
}

RESPONSE format

{
	status: 'success',
	data: 'Hospital approved'
}

GET /admin/categories

Get single or all categories

---AUTHENTICATION REQUIRED---

REQUEST format

To return all categories, no parameter is required

To return single category, append "?id=category_id" to request URL
e.g https://api.deltasystematics360.com/admin/categories?id=1	(category with id 1)

RESPONSE format

{
	status: 'success',
	data: [
		{
			id: number,
			title: string,
			icon: url
		},
		....
	]
}

POST /admin/categories

Save new category record to database

---AUTHENTICATION REQUIRED---

REQUEST format

{
	title: string
	icon: file (optional)
}

RESPONSE format

{
	status: 'success',
	data: {
		new_category_id: id
	}
}

PATCH /admin/categories

Update category record in database

---AUTHENTICATION REQUIRED---

REQUEST format

{
	id: int,
	title: string
	icon: file (optional)
}

RESPONSE format

{
	status: 'success',
	data: 'Update successful'
}

DELETE /admin/categories

Delete category record from database

---AUTHENTICATION REQUIRED---

REQUEST format

{
	id: int
}

RESPONSE format

{
	status: 'success',
	data: 'Delete successful'
}

GET /admin/users

Get active/disabled/all users

---AUTHENTICATION REQUIRED---

REQUEST format

To return all users info, no parameter is required

To return all ACTIVE users, append "?status=active" to request URL
e.g https://api.deltasystematics360.com/admin/users?status=active

To return all DISABLED users, append "?status=disabled" to request URL
e.g https://api.deltasystematics360.com/admin/users?status=disabled

RESPONSE format

{
	status: 'success',
	data: [
		{
			email: string,
			gcm_code: string,
			name: string,
			password: string,
			phone: string,
			imei: string,
			city: string,
			zip: string,
			reg_date: string,
			last_login: string,
			facebook_id: string
		},
		....
	]
}

DELETE /admin/users

Mark user account as disabled

---AUTHENTICATION REQUIRED---

REQUEST format

{
	email: string
}

RESPONSE format

{
	status: 'success',
	data: 'Disabled successfully'
}

PATCH /admin/users

Re-enable user account / Mark user account as enabled

---AUTHENTICATION REQUIRED---

REQUEST format

{
	email: string
}

RESPONSE format

{
	status: 'success',
	data: 'Enabled successfully'
}