# SPARKLES WALLET APP API DOCUMENTATION
###### tags: `Documentation` `API`
## TABLE OF CONTENTS
[TOC]
## CREDIT CARD
### POST /credit-cards
Creates credit card for the user/law firm
**Request Headers**
| Key | Type | Description |
| -------- | -------- | -------- |
| Authorization | string | Authorization Bearer Token |
**Path Parameters**
| Key | Type | Description |
| -------- | -------- | -------- |
| owner_type | string | Object class of the associated entity for the credit card either User or LawFirm |
| owner_id | int | Object ID of the associated entity for the credit card either User ID or LawFirm ID |
| first_name | string | Credit card account first name |
| last_name | string | Credit card account last name |
| payment_scheme | string | Credit card payment scheme (visa, master, american_express, discover, diners_club, jcb, maestro) |
| number | string | Credit card account number |
| expiration_date | string | Credit card expiration_date |
**Success Response Examples**
- Successful creation of credit card
- Status Code: `200`
- Content:
```json=
{
"id": 23,
"name": "Pio Ryan Lumongsod",
"first_name": "Pio Ryan",
"last_name": "Lumongsod",
"number": "1111",
"masked_number": "XXXX1111",
"payment_scheme": "visa",
"expiration_date": "2020-11",
"status": "active",
"message": "Successful.",
"default": "false"
}
```
**Error Response Examples**
- Error in creation of credit card
- Status Code: `400`
- Content:
```json=
{
"message": "The credit card number is invalid."
}
```
### GET /credit-cards
Retrieves all associated credit card for the user/law firm
**Request Headers**
| Key | Type | Description |
| -------- | -------- | -------- |
| Authorization | string | Authorization Bearer Token |
**Path Parameters**
| Key | Type | Description |
| -------- | -------- | -------- |
| owner_type | string | Object class of the associated entity for the credit card either User or LawFirm |
| owner_id | int | Object ID of the associated entity for the credit card either User ID or LawFirm ID |
| show_all | boolean | Optional. If "true", will output both active and failed credit cards, otherwise only credit cards with active status are listed. |
**Success Response Examples**
can be paginated using page(pageNumber) & per_page (default:5 number of items )
example: localhost:3000/credit-cards?page=1&per_page=5
- Successful retrieval of credit cards
- Status Code: `200`
- Content:
```json=
[
{
// array of credit card hash with the same format as output of POST
}, ...
]
```
### GET /credit-cards/{id}
Retrieves associated credit card for the user/law firm
**Request Headers**
| Key | Type | Description |
| -------- | -------- | -------- |
| Authorization | string | Authorization Bearer Token |
**Path Parameters**
| Key | Type | Description |
| -------- | -------- | -------- |
| id | int | Credit card id |
| owner_type | string | Object class of the associated entity for the credit card either User or LawFirm |
| owner_id | int | Object ID of the associated entity for the credit card either User ID or LawFirm ID |
**Success Response Examples**
- Successful retrieval of credit card
- Status Code: `200`
- Content:
```json=
{
// credit card hash with the same format as output of POST
}
```
### PATCH /credit-cards/{id}
Make associated credit card for the user/law firm default
**Request Headers**
| Key | Type | Description |
| -------- | -------- | -------- |
| Authorization | string | Authorization Bearer Token |
**Path Parameters**
| Key | Type | Description |
| -------- | -------- | -------- |
| id | int | Credit card id |
| owner_type | string | Object class of the associated entity for the credit card either User or LawFirm |
| owner_id | int | Object ID of the associated entity for the credit card either User ID or LawFirm ID |
| make_default | boolean | set this as default card |
| first_name | string | Credit card account first name |
| last_name | string | Credit card account last name |
| payment_scheme | string | Credit card payment scheme (visa, master, american_express, discover, diners_club, jcb, maestro) |
| number | string | Credit card account number (use masked_number as input if you want to retain previous value since only the last 4 digits are retrievable) |
| expiration_date | string | Credit card expiration_date |
**Success Response Examples**
- Successful update of credit card
- Status Code: `200`
- Content:
```json=
{
// credit card hash with the same format as output of POST
}
```
**Error Response Examples**
- Error responses are the same as in POST.
### DELETE /credit-cards/{id}
Deletes associated credit card for the user/law firm
**Request Headers**
| Key | Type | Description |
| -------- | -------- | -------- |
| Authorization | string | Authorization Bearer Token |
**Path Parameters**
| Key | Type | Description |
| -------- | -------- | -------- |
| id | int | Credit card id |
| owner_type | string | Object class of the associated entity for the credit card either User or LawFirm |
| owner_id | int | Object ID of the associated entity for the credit card either User ID or LawFirm ID |
**Success Response Examples**
- Successful retrieval of credit cards
- Status Code: `204`
```