Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Roop-TL/c7673ca9f3bd0667463d6dd5a88ef778 to your computer and use it in GitHub Desktop.

Select an option

Save Roop-TL/c7673ca9f3bd0667463d6dd5a88ef778 to your computer and use it in GitHub Desktop.
An example of an API contract between the server and front-end devices

Users

  • User object
{
  id: integer
  username: string
  email: string
  created_at: datetime(iso 8601)
  updated_at: datetime(iso 8601)
}

Product

  • Product object
{
  id: integer
  name: string
  cost: float(2)
  available_quantity: integer
  created_at: datetime(iso 8601)
  updated_at: datetime(iso 8601)
}

Order

  • Order object
{
  id: integer
  user_id: <user_id>
  total: float(2)
  products: [
              { 
                product: <product_id>,
                quantity: integer 
              },
              { 
                product: <product_id>,
                quantity: integer 
              },
              { 
                product: <product_id>,
                quantity: integer 
              },
            ]
  created_at: datetime(iso 8601)
  updated_at: datetime(iso 8601)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment