Skip to content
Jeffrey Leung edited this page Feb 20, 2019 · 19 revisions

Create an Ask

Description

Creates a new Ask for a given user.

Does not need to be unique.

If there exists a Give which:

  • Is currently unmatched (i.e. neither matched nor fulfilled), and
  • Has the same item as this Ask,

Then both this Ask and the Give will have their statuses set to matched, and they will be connected such that the Give data will contain the match_ fields of the corresponding information of their match, and vice versa.

Example script to call the API

Request

Method

POST

Mapping

/ask

JSON Body

{
  "user_name": String,
  "user_email": String,
  "user_location": String,
  "item": String,
  "quantity": Number
}

Response

Codes

HTTP Status Code Meanings
201 Created Created the ask succesfully
500 Internal Server Error The server crapped itself

JSON body

{
  "id": String UUID
}

Retrieve all Asks

Description

Returns all Asks from all users.

If the Ask has been matched or fulfilled, it will have the ID of the corresponding match as well as the name, email, and location of the match.

Example script to call the API

Request

Method

GET

Mapping

/ask

Response

Codes

HTTP Status Code Meanings
200 OK Retrieved all Asks successfully
500 Internal Server Error The server crapped itself

JSON body

[ array
  {
    "posted": Number (Unix timestamp)
    "id": String UUID,
    "user_name": String,
    "user_email": String,
    "user_location": String,
    "item": String,
    "quantity": Number,
    "status": String,
    "match_id": String (Optional),
    "match_name": String (Optional),
    "match_email": String (Optional),
    "match_location": String (Optional)
  }
]

For the possible values of status, see Values.

Fulfill Ask-Give Matching

Description

Sets the status of the Ask (and, if linked, the status of the corresponding Give) to the value fulfilled.

The resultant status is returned.

Example script to call the API

Request

Method

PUT

Mapping

/ask/status

JSON Body

{
  "id": String
}

Response

Codes

HTTP Status Code Meanings
200 OK Updated the status(es) successfully
500 Internal Server Error The server crapped itself

JSON body

{
  "status": String
}

For the possible values of status, see Values.

Clone this wiki locally