Skip to content

Latest commit

 

History

History
461 lines (434 loc) · 8.74 KB

user.md

File metadata and controls

461 lines (434 loc) · 8.74 KB

User

The User API Schema contains the user account information. In this module, it will let you:

Data Structure

Field Type Description
id string The unique user ID and the sort key.
user_type string The type of this account.
There are 2 different user types:
1 = "ADMIN"
2 = "CUSTOMER"
first_name string The first name of the user.
last_name string The last name of the user.
username string The username of the user account and the primary key.
password string The user security password for the account.
address string The user address.
email string The user e-mail address.
mobile_number string The user phone number.
date_created string The date that this account was created.
last_login string The last login session of the user.

API Usage and Specification

Headers

Key Value
Content-Type application/json

Setting to application/json is recommended.

HTTP Response Status Codes

Status Code Description
200 OK
400 Bad Request
500 Internal Server Error

Create an account

To create a new user account instance, you need to instantiate an object that represents a user account property. The user account instance holds the information related to the user.

Method: POST

Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/user/create

Payload

Field Type Description Required
user_type string The type of this account.
There are 2 different user types:
1 = "ADMIN"
2 = "CUSTOMER"
first_name string The first name of the user.
last_name string The last name of the user.
username string The username of the user account.
password string Minimum length: 8
The user security password for the account.
address string The user address.
email string The user e-mail address.
mobile_number string The user phone number.

Sample Payload

{
  "user_type": "1",
  "first_name": "Emily",
  "last_name": "Davis",
  "username": "emilydavis",
  "password": "passwordabc",
  "address": "321 Cedar Road",
  "email": "emilydavis@example.com",
  "mobile_number": "4449876543"
}

Login

By providing the username and password in the payload, the authentication process will be initiated, allowing the user to access their account. Upon successful login, it will return a representation of an account that is related to the user as a response.

Method: POST

Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/user/login

Payload

Field Type Description Required
username string The username of the user account.
password string Minimum length: 8
The user security password for the account.

Sample Request

Payload:

{
  "username": "emilydavis",
  "password": "passwordabc"
}

Response:

{
  "id": "ADMN-878495",
  "user_type": "ADMIN",
  "first_name": "Emily",
  "last_name": "Davis",
  "username": "emilydavis",
  "address": "321 Cedar Road",
  "email": "emilydavis@example.com",
  "mobile_number": "4449876543"
}

Get user account

When retrieving the specific user account information, the id and username query parameters must be present in the URL. These parameters identify which user account should be returned. It will either return a representation of a specific an account that is related to the user or a list of user account.

Method: GET

Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/user/account/get

Specific User Account

Query Parameters

Parameter Type Description Required
id string The user account unique ID.
username string The username of the user account.

Sample Response

[
  {
    "id": "ADMN-878495",
    "user_type": "ADMIN",
    "first_name": "Emily",
    "last_name": "Davis",
    "username": "emilydavis",
    "address": "321 Cedar Road",
    "email": "emilydavis@example.com",
    "mobile_number": "(407) 435-6841"
  }
]

Update user account

When modifying the user profile, the id and username query parameters must be present in the URL. These parameters identify which user account should be modified. After the update is performed, it will return a representation of the updated account information.

Method: POST

Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/user/account/update?id=xxxxx&username=xxxxx

Query Parameters

Parameter Type Description Required
id string The user account unique ID.
username string The username of the user account.

Payload

Field Type Description Required
first_name string The first name of the user.
last_name string The last name of the user.
address string The user address.
email string The user e-mail address.
mobile_number string The user phone number.

Sample Request

Payload:

{
  "mobile_number": "(407) 435-6841"
}

Response:

{
  "id": "ADMN-878495",
  "user_type": "ADMIN",
  "first_name": "Emily",
  "last_name": "Davis",
  "username": "emilydavis",
  "password": "passwordabc",
  "address": "321 Cedar Road",
  "email": "emilydavis@example.com",
  "mobile_number": "(407) 435-6841",
  "date_created": "1687849585"
}