Skip to content

Latest commit

 

History

History
498 lines (470 loc) · 10.2 KB

File metadata and controls

498 lines (470 loc) · 10.2 KB

API Documentation

API /promo_codes

index

list all promo codes regardless of state

Request
  • Method: GET
  • Path: /api/promo_codes
  • Request headers:
accept: application/json
Response
  • Status: 200
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW5OijUBTJSgAAAQh
  • Response body:
{
  "data": [
    {
      "status": true,
      "radius": 120.5,
      "p_code": "some p_code",
      "id": 1716,
      "expiry_date": "2019-11-08",
      "event_location": {
        "place": "Nairobi, Ngong Racecourse",
        "longitude": "36.73916371",
        "latitude": "-1.30583211"
      },
      "amount": 120.5
    }
  ]
}

lists all valid promo_codes (promo codes where validity == active)

Request
  • Method: GET
  • Path: /api/promo_codes?validity=active
  • Request headers:
accept: application/json
Response
  • Status: 200
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW5bz3wgYT4QAAAUh
  • Response body:
{
  "data": [
    {
      "status": true,
      "radius": 120.5,
      "p_code": "some p_code",
      "id": 1720,
      "expiry_date": "2019-11-08",
      "event_location": {
        "place": "Nairobi, Ngong Racecourse",
        "longitude": "36.73916371",
        "latitude": "-1.30583211"
      },
      "amount": 120.5
    }
  ]
}

create

renders (generates) promo_code when data is valid

Request
  • Method: POST
  • Path: /api/promo_codes
  • Request headers:
accept: application/json
content-type: multipart/mixed; boundary=plug_conn_test
  • Request body:
{
  "promo_code": {
    "status": true,
    "radius": 120.5,
    "p_code": "some p_code",
    "expiry_date": "2019-11-08",
    "event_location_id": 0,
    "event_location": {
      "place": "Nairobi, Ngong Racecourse",
      "longitude": "36.73916371",
      "latitude": "-1.30583211"
    },
    "amount": 120.5
  }
}

NB: the p_code must not be supplied. It is autogenerated if null.

Response
  • Status: 201
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW5G1hmgY_AIAAAOh
location: /api/promo_codes/1714
  • Response body:
{
  "data": {
    "status": true,
    "radius": 120.5,
    "p_code": "some p_code",
    "id": 1714,
    "expiry_date": "2019-11-08",
    "event_location_id": 3474,
    "amount": 120.5
  }
}

show

retrieve a single promo_code by id

Request
  • Method: GET
  • Path: /api/promo_codes/1714
  • Request headers:
accept: application/json
Response
  • Status: 200
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW5JHoMAY_AIAAAPB
  • Response body:
{
  "data": {
    "status": true,
    "radius": 120.5,
    "p_code": "some p_code",
    "id": 1714,
    "expiry_date": "2019-11-08",
    "event_location_id": 3474,
    "amount": 120.5
  }
}

create

renders errors when data is invalid

Request
  • Method: POST
  • Path: /api/promo_codes
  • Request headers:
accept: application/json
content-type: multipart/mixed; boundary=plug_conn_test
  • Request body:
{
  "promo_code": {
    "status": null,
    "radius": null,
    "p_code": null,
    "expiry_date": null,
    "event_location_id": null,
    "event_location": {
      "place": null,
      "longitude": null,
      "latitude": null
    },
    "amount": null
  }
}
Response
  • Status: 422
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW5T2fLB5Z1EAAATB
  • Response body:
{
  "errors": {
    "detail": "Unprocessable Entity"
  }
}

update

renders promo_code when data is valid

Request
  • Method: PUT
  • Path: /api/promo_codes/1718
  • Request headers:
accept: application/json
content-type: multipart/mixed; boundary=plug_conn_test
  • Request body:
{
  "promo_code": {
    "status": false,
    "radius": 456.7,
    "p_code": "some updated p_code",
    "expiry_date": "2019-11-02",
    "event_location_id": 3479,
    "event_location": {
      "place": "Nairobi, Upperhill",
      "longitude": "36.820030",
      "latitude": "-1.285790"
    },
    "amount": 456.7
  }
}
Response
  • Status: 200
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW5Sz-VjA6_AAAASB
  • Response body:
{
  "data": {
    "status": false,
    "radius": 456.7,
    "p_code": "some updated p_code",
    "id": 1718,
    "expiry_date": "2019-11-02",
    "event_location_id": 3479,
    "amount": 456.7
  }
}

renders errors when data is invalid

Request
  • Method: PUT
  • Path: /api/promo_codes/1715
  • Request headers:
accept: application/json
content-type: multipart/mixed; boundary=plug_conn_test
  • Request body:
{
  "promo_code": {
    "status": null,
    "radius": null,
    "p_code": null,
    "expiry_date": null,
    "event_location_id": null,
    "event_location": {
      "place": null,
      "longitude": null,
      "latitude": null
    },
    "amount": null
  }
}
Response
  • Status: 422
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW5KxxKDbnp0AAAQB
  • Response body:
{
  "errors": {
    "status": [
      "can't be blank"
    ],
    "radius": [
      "can't be blank"
    ],
    "p_code": [
      "can't be blank"
    ],
    "expiry_date": [
      "can't be blank"
    ],
    "event_location_id": [
      "can't be blank"
    ],
    "amount": [
      "can't be blank"
    ]
  }
}

delete

deletes chosen promo_code

Request
  • Method: DELETE
  • Path: /api/promo_codes/1719
  • Request headers:
accept: application/json
Response
  • Status: 204
  • Response headers:
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW5VGzzBI8acAAATh
  • Response body:

check_validity

check validity of supplied promo_code (active && yet to expire)

Request
  • Method: POST
  • Path: /api/promo_codes/check_validity/some_p_code
  • Request headers:
accept: application/json
content-type: multipart/mixed; boundary=plug_conn_test
  • Request body:
{
  "origin": {
  "place": "Nairobi, Westlands",
  "latitude": "-1.269650",
  "longitude": "36.808922"
  },
  "destination": {
  "place": "Nairobi, Ngong Racecourse",
  "latitude": "-1.30583211",
  "longitude": "36.73916371"
  }
}
Response
  • Status: 200
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW2zR2GDAhjcAAANh
  • Response body:
{
  "data": {
    "status": true,
    "radius": 120.5,
    "polyline": {
      "points": "h~vFyft_Fx@u@jArAlAzAn@t@VZVWZWVUx@q@ZUFAJ?h@_@xAwALG^LYb@aBfBsD`DeAv@u@p@YVs@p@y@h@{@n@}CjCcBnAm@h@mFrEgFhEoCxBa@f@CHQf@]\\WH}@Pc@Li@XoAdA}ApAwAjAi@j@q@|@c@z@i@~Ac@fBa@bBStAMdAOvBK|A[tEIjBGjBEnCIfBMdAcApFc@pDWbCe@hKStDKxBq@dL{@lO_@pFGzAChCBpAP|Bt@`IPpBZLP@rBSfAGn@DVF^Nd@\\`@n@hA~Bb@`Al@tAf@~@t@dAl@l@v@`@v@VfAP~@Bf@EpA[nAg@r@c@t@e@nCeBp@_@pEiCpAw@x@[jAWv@K`AEjA?vBJ`CRpAX|Ad@r@Xt@^`DbCfDfCvAhAp@f@ZV\\N\\NJFp@^`@NFANBJJDPADNNd@d@p@t@\\TvDhBdFbCvBfAdBbAx@f@vBtA\\Tp@t@~@pAhD|EzB|CjBnCvCbEhApAr@n@x@r@x@p@r@n@r@`@zBfAlCbAhBZlC\\dALz@D~@FbHHjGLrDDrD?dHJdCBdD@rBDfD@dABBOReAHe@J_ADGHEF@LFLj@@XGXOvBFf@Lf@l@vBBb@ANILBTj@pBfA~D~CnLnG~UhFdSrGtV`DtLVhAL|@f@fE^zCl@`Fu@?NjA"
    },
    "p_code": "some p_code",
    "id": 1713,
    "expiry_date": "2019-11-08",
    "event_location": {
      "place": "Nairobi, Ngong Racecourse",
      "longitude": "36.73916371",
      "latitude": "-1.30583211"
    },
    "distance_to_destination": 12.9,
    "amount": 120.5
  }
}

radius

configure a promo_code's radius

Request
  • Method: POST
  • Path: /api/promo_codes/radius/some_p_code
  • Request headers:
accept: application/json
accept: application/json
content-type: multipart/mixed; boundary=plug_conn_test
  • Request body:
{
  "promo_code": {
  "radius": 16
  }
}
Response
  • Status: 200
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW5Qe1agldnQAAARh
  • Response body:
{
  "data": {
    "status": true,
    "radius": 120.5,
    "p_code": "some p_code",
    "id": 1717,
    "expiry_date": "2019-11-08",
    "event_location_id": 3477,
    "amount": 120.5
  }
}

deactivate

deactivate a promo_code

Request
  • Method: POST
  • Path: /api/promo_codes/deactivate/some%20p_code
  • Request headers:
accept: application/json
Response
  • Status: 200
  • Response headers:
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: FdOtW2ns_DiYj7oAAADE
  • Response body:
{
  "data": {
    "status": true,
    "radius": 120.5,
    "p_code": "some p_code",
    "id": 1712,
    "expiry_date": "2019-11-08",
    "event_location_id": 3472,
    "amount": 120.5
  }
}