Back to top

Loyalty Points System API

This API allows customers create accounts, login, earn points for purchases, and redeem those points for rewards.

Membership Service

Loyalty Program Membership Service endpoints

Create Account

Create User account and send activation email

Account creation
POST/api/auth/register

Example URI

POST /api/auth/register
Request  with Body
HideShow
Headers
Content-Type: application/json
Body
{
  "username": "YourUsername23",
  "firstname": "your",
  "lastname": "your",
  "gender": "your",
  "email": "user@example.com",
  "password": "your",
  "city": "your",
  "phone_number": "your"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "username": {
      "type": "string"
    },
    "firstname": {
      "type": "string",
      "description": "firstname (required)"
    },
    "lastname": {
      "type": "string",
      "description": "lastname (required)"
    },
    "gender": {
      "type": "string",
      "description": "gender (required)"
    },
    "email": {
      "type": "string"
    },
    "password": {
      "type": "string",
      "description": "password (required)"
    },
    "city": {
      "type": "string",
      "description": "city (required)"
    },
    "phone_number": {
      "type": "string",
      "description": "phone-number (required)"
    }
  },
  "required": [
    "username",
    "email"
  ]
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "\"We sent an email with a verification code to user@example.com\""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ]
}
Response  400
HideShow
Body
{
  "status": "fail",
  "message": "error"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  409
HideShow
Body
{
  "status": "fail",
  "message": "\"User with that credential already exists\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "\"Things have gone really bad!\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  502
HideShow
Body
{
  "status": "error",
  "message": "\"Error!\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

VerifyEmail

Verify email of correspondent account and grant login access

User email verification
GET/api/auth/verify-email/:{secret_code}

Example URI

GET /api/auth/verify-email/:26dlFidiTVJHFH7Y
URI Parameters
HideShow
secret_code
string (required) Example: 26dlFidiTVJHFH7Y
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "\"Email verified successfully\""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ]
}
Response  400
HideShow
Body
{
  "status": "fail",
  "message": "\"Invalid verification code or user doesn't exist\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  409
HideShow
Body
{
  "status": "fail",
  "message": "\"User already verified\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "\"Things have gone really bad!\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Signin

Validate logging in of user

User login
POST/api/auth/login

Example URI

POST /api/auth/login
Request  with Body
HideShow
Headers
Content-Type: application/json
Body
{
  "email": "user@example.com",
  "password": "your_password"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "email": {
      "type": "string"
    },
    "password": {
      "type": "string"
    }
  },
  "required": [
    "email",
    "password"
  ]
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "token": "dfghjkloiuytredfghjiuytredfcvbjkiouytr"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "token": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "token"
  ]
}
Response  400
HideShow
Body
{
  "status": "fail",
  "message": "\"Invalid email or Password\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  403
HideShow
Body
{
  "status": "fail",
  "message": "\"Please verify your email\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "\"Things have gone really bad!\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Logout

Send an expired cookie to the user’s browser or client. Sending the expired cookie will invalidate the user’s ‘session’.

User logout
GET/api/auth/logout

Example URI

GET /api/auth/logout
Response  200
HideShow
Body
{
  "status": "success",
  "message": "\"You have been logged out!\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Get User Data

Retrieve the currently logged-in user’s information.

Get user data
GET/api/users/me

Example URI

GET /api/users/me
Request
HideShow
Headers
Cookie: token=<token_value>
Response  200
HideShow
Body
{
  "status": "success",
  "data": {
    "user": {
      "username": "YourUsername23",
      "firstname": "yourFirstname",
      "lastname": "yourLastname",
      "email": "user@example.com",
      "phone_number": "+25412345789",
      "redeemable_points": 250,
      "city": "Nairobi",
      "card_number": "0123456789012"
    }
  }
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "data": {
      "type": "object",
      "properties": {
        "user": {
          "type": "object",
          "properties": {
            "username": {
              "type": "string",
              "description": "The user's username"
            },
            "firstname": {
              "type": "string",
              "description": "The user's first name"
            },
            "lastname": {
              "type": "string",
              "description": "The user's last name"
            },
            "email": {
              "type": "string",
              "description": "The user's email"
            },
            "phone_number": {
              "type": "string",
              "description": "The user's phone number"
            },
            "redeemable_points": {
              "type": "number",
              "description": "The user's total points"
            },
            "city": {
              "type": "string",
              "description": "The user's city"
            },
            "card_number": {
              "type": "string",
              "description": "The user's virtual card number"
            }
          },
          "required": [
            "username",
            "firstname",
            "lastname",
            "email",
            "phone_number",
            "redeemable_points",
            "city",
            "card_number"
          ],
          "description": "The user data"
        }
      },
      "required": [
        "user"
      ]
    }
  },
  "required": [
    "status",
    "data"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  401
HideShow
Body
{
  "status": "fail",
  "message": "\"You are not logged in\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Change User Product

Change Password
PATCH/api/users/me/change-password

Update the logged in user’s password

Example URI

PATCH /api/users/me/change-password
Request
HideShow
Headers
Content-Type: application/json
Cookie: token=<token-value>
Authorization: Bearer <jwt>
Body
{
  "new_password": "yournewpassword",
  "confirm_password": "yournewpassword"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "new_password": {
      "type": "string"
    },
    "confirm_password": {
      "type": "string"
    }
  },
  "required": [
    "new_password",
    "confirm_password"
  ]
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "Password change successful"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ]
}
Response  400
HideShow
Body
{
  "status": "error",
  "message": "Passwords do not match"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  401
HideShow
Body
{
  "status": "fail",
  "message": "You are not logged in"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "Failed to udpate password"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Products

Get All Available Products

Get All Products
GET/api/users/products

Retrieves a list of all available products.

Example URI

GET /api/users/products
Request
HideShow
Headers
Cookie: token=<token_value>
Authorization: Bearer <jwt>
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "Products Retrieval successful!",
  "data": {
    "products": [
      {
        "product_name": "Airtime 10 KES",
        "product_description": "By Lexcom",
        "product_price": 250
      }
    ]
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "data": {
      "type": "object",
      "properties": {
        "products": {
          "type": "array",
          "description": "The list of all available products"
        }
      },
      "required": [
        "products"
      ]
    }
  },
  "required": [
    "status",
    "message",
    "data"
  ]
}
Response  401
HideShow
Body
{
  "status": "fail",
  "message": "You are not logged in"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  404
HideShow
Body
{
  "status": "fail",
  "message": "Products not found"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "Failed to retrieve products"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Points

Loyalty Program Members Redeem Points endpoint

Redeem Points

Redeem Points earned for a product/service

Points Redemption
POST/api/users/me/redeem

Example URI

POST /api/users/me/redeem
Request  with Body
HideShow
Headers
Content-Type: application/json
Body
{
  "product_name": "Airtime 20 KES",
  "product_quantity": 1
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "product_name": {
      "type": "string"
    },
    "product_quantity": {
      "type": "number"
    }
  },
  "required": [
    "product_name",
    "product_quantity"
  ]
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "\"Redemption successful\"",
  "redeemed_product": "\"Airtime 20 KES\"",
  "redeemed_points": 500,
  "balance": {
    "redeemable_points": 0
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "redeemed_product": {
      "type": "string"
    },
    "redeemed_points": {
      "type": "number"
    },
    "balance": {
      "type": "object",
      "properties": {
        "redeemable_points": {
          "type": "number",
          "description": "The user's balance of redeemable points"
        }
      },
      "required": [
        "redeemable_points"
      ]
    }
  },
  "required": [
    "status",
    "message",
    "redeemed_product",
    "redeemed_points",
    "balance"
  ]
}
Response  401
HideShow
Body
{
  "status": "fail",
  "message": "\"You are not logged in\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  404
HideShow
Body
{
  "status": "fail",
  "message": "\"Product not found\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "\"Things have gone really bad!\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Transaction History

Loyalty Program Members View Transaction Data Endpoint

View Transaction History

Get a list of a logged in user’s transaction data

List all Transactions
GET/api/users/me/transaction-history

Example URI

GET /api/users/me/transaction-history
Request
HideShow
Headers
Cookie: token=<token_value>
Authorization: Bearer <jwt>
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "\"Transaction History Retrieval successful!\"",
  "data": {
    "transactions": [
      {
        "points": 150,
        "state": "EARN",
        "description": "COMPLETE INFO SITE BONUS",
        "date": "June 3, 2023",
        "time": "20:39:58"
      }
    ]
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "data": {
      "type": "object",
      "properties": {
        "transactions": {
          "type": "array",
          "description": "The user's list of transactions"
        }
      },
      "required": [
        "transactions"
      ]
    }
  },
  "required": [
    "status",
    "message",
    "data"
  ]
}
Response  401
HideShow
Body
{
  "status": "fail",
  "message": "\"You are not logged in\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  404
HideShow
Body
{
  "status": "fail",
  "message": "\"Transactions not found\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "\"Failed to retrieve transactions\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Reset Password

Endpoints to reset a user’s forgotten password

Forgot Password

Send password reset email to the requesting user email

Forgot password
POST/api/auth/forgot-password

Example URI

POST /api/auth/forgot-password
Request  with Body
HideShow
Headers
Content-Type: application/json
Body
{
  "email": "user@example.com"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "email": {
      "type": "string"
    }
  },
  "required": [
    "email"
  ]
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "We sent an email with a reset password code to user"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string",
      "description": "email@example.com  (required)"
    }
  },
  "required": [
    "status"
  ]
}
Response  400
HideShow
Body
{
  "status": "error",
  "message": "error"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string",
      "description": "msg"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  404
HideShow
Body
{
  "status": "fail",
  "message": "User not found"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "fail",
  "message": "Failed to retrieve user"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Reset Password

Reset user’s password

Reset password
PATCH/api/auth/reset-password/{resetToken}

Example URI

PATCH /api/auth/reset-password/resetToken
URI Parameters
HideShow
resetToken
string (required) 

user’s password reset token

Request  with Body
HideShow
Headers
Content-Type: application/json
Body
{
  "new_password": "yournewpassword",
  "confirm_password": "yournewpassword"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "new_password": {
      "type": "string"
    },
    "confirm_password": {
      "type": "string"
    }
  },
  "required": [
    "new_password",
    "confirm_password"
  ]
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "Password reset successful"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ]
}
Response  400
HideShow
Body
{
  "status": "fail",
  "message": "error"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string",
      "description": "msg (required)"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Admins

Admin endpoints of loyalty-program api

Login

Authenticates an admin user and returns an access token.

Admin login
POST/api/auth/admin/login

Example URI

POST /api/auth/admin/login
Request  with Body
HideShow
Headers
Content-Type: application/json
Body
{
  "username": "YourUsername23",
  "password": "your"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "username": {
      "type": "string"
    },
    "password": {
      "type": "string",
      "description": "password (required)"
    }
  },
  "required": [
    "username"
  ]
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "token": "dfghjkloiuytredfghjiuytredfcvbjkiouytr"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "token": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "token"
  ]
}
Response  400
HideShow
Body
{
  "status": "fail",
  "message": "\"Invalid Password\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "\"Things have gone really bad!\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Logout

Send an expired cookie to the browser or client. Sending the expired cookie will invalidate the admin’s ‘session’.

Admin logout
GET/api/admin/logout

Example URI

GET /api/admin/logout
Response  200
HideShow
Body
{
  "status": "success",
  "message": "\"You have been logged out!\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Add New Product

Create Product
POST/api/admin/product

Creates a new product.

Example URI

POST /api/admin/product
Request  with Body
HideShow
Headers
Content-Type: application/json
Body
{
  "product_name": "AIRTIME 10 KES",
  "product_description": "By Lexcom",
  "product_price": 250,
  "quantity": 10
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "product_name": {
      "type": "string"
    },
    "product_description": {
      "type": "string",
      "description": "Hellopay (required)"
    },
    "product_price": {
      "type": "number"
    },
    "quantity": {
      "type": "number"
    }
  },
  "required": [
    "product_name",
    "product_price",
    "quantity"
  ]
}
Response  201
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "\"Product added successfully\""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ]
}
Response  401
HideShow
Body
{
  "status": "fail",
  "message": "\"You are not logged in\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "\"Things have gone really bad!\""
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Update a Product

Update Product
PUT/api/admin/product/{id}

Updates a product by its id

Example URI

PUT /api/admin/product/id
URI Parameters
HideShow
id
number (required) 

id of the product to be update

Request  with Body
HideShow
Headers
Content-Type: application/json
Body
{
  "product_name": "AIRTIME 10 KES",
  "product_description": "By Lexcom",
  "product_price": 250,
  "quantity": 10
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "product_name": {
      "type": "string"
    },
    "product_description": {
      "type": "string",
      "description": "Hellopay (required)"
    },
    "product_price": {
      "type": "number"
    },
    "quantity": {
      "type": "number"
    }
  },
  "required": [
    "product_name",
    "product_price",
    "quantity"
  ]
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "Product updated successfully"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ]
}
Response  400
HideShow
Body
{
  "status": "fail",
  "message": "Failed to retrieve product"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  401
HideShow
Body
{
  "status": "fail",
  "message": "You are not logged in"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  404
HideShow
Body
{
  "status": "fail",
  "message": "Product not found"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "Failed to udpate product"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Delete a Product

Delete Product
DELETE/api/admin/product/{id}

Deletes a product by its id

Example URI

DELETE /api/admin/product/id
URI Parameters
HideShow
id
number (required) 

id of the product to be delete

Response  204
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "Product deleted successfully"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "message"
  ]
}
Response  400
HideShow
Body
{
  "status": "fail",
  "message": "Failed to retrieve product"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  401
HideShow
Body
{
  "status": "fail",
  "message": "You are not logged in"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  404
HideShow
Body
{
  "status": "fail",
  "message": "Product not found"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "Failed to delete product"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Get All Products

Get Products
GET/api/admin/product

Retrieves a list of all products.

Example URI

GET /api/admin/product
Request
HideShow
Headers
Cookie: token=<token_value>
Authorization: Bearer <jwt>
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "message": "Products Retrieval successful!",
  "data": {
    "products": [
      {
        "ID": 1,
        "CreatedAt": "2023",
        "UpdatedAt": "2023",
        "DeletedAt": "2023",
        "product_name": "Airtime 10 KES",
        "product_description": "By Lexcom",
        "product_price": 250,
        "quantity": 7
      }
    ]
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "data": {
      "type": "object",
      "properties": {
        "products": {
          "type": "array",
          "description": "The list of all available products"
        }
      },
      "required": [
        "products"
      ]
    }
  },
  "required": [
    "status",
    "message",
    "data"
  ]
}
Response  401
HideShow
Body
{
  "status": "fail",
  "message": "You are not logged in"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  404
HideShow
Body
{
  "status": "fail",
  "message": "Products not found"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  500
HideShow
Body
{
  "status": "error",
  "message": "Failed to retrieve products"
}
Schema
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Generated by aglio on 02 Jul 2023