Skip to content

Instantly share code, notes, and snippets.

@Luiyit
Created September 11, 2024 13:45
Show Gist options
  • Save Luiyit/5bbe82ba86708b2f8b38caeb41e8f546 to your computer and use it in GitHub Desktop.
Save Luiyit/5bbe82ba86708b2f8b38caeb41e8f546 to your computer and use it in GitHub Desktop.
Prosegur API contract

Backend Contract

This is the structure that clients need to follow to send and receive data from backend. In the future we will have swagger documentation, but for now you can check this contract rules. The capitalization to use is camel case.

1. Payload [Post & Put]

Always the payload must include a wrapper object called data

{ data: "Object || Array" }

2. OK Response

Always the http code will be 2xx. Pagination object is included only when apply.

{ success: true, data: "Object || Array", pagination?: { totalRecords: "number", totalPages: "number", page: "number", take: "number", skip: "number" } }

3. Error Response

When the response contains an error, the http code will be 4xx or 5xx

json { success: false, error: "String", details: { "[key]": "String", errorSource: "Internal error type", } }

4. Pagination [Query string]

Pagination params will be used in GET requests if apply.

json { page?: "number", take?: "number", }

5. Dashboard auth headers

Frontend needs to get the token using auth.currentUser.getIdToken(). It will be send in the request's headers for all dashboard request.

json { headers: { "Authorization": "Bearer FIREBASE_ID_TOKEN", "Client": "Dasboard", } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment