API documentation for working with discount cards
Table with field descriptions:
| Field | Type | Required? | Description |
|---|---|---|---|
| id | int | No | Unique card identifier (required when updating). |
| user_id | int/null | No | ID of the user to whom the card is linked (null if the user is not specified). https://admin.ecom.md/ru/admin/users/usergroup/ |
| code | string | Yes | Card code. |
| legalentityname | string | No | Legal name. |
| first_name | string | No | Cardholder's name. |
| last_name | string | No | Last name of the card owner. |
| barcode | string | Yes | Unique card barcode. |
| accumulated_amount | decimal | No | The amount of charges on the card. |
| sex | string | No | Gender of the card owner (m- male, f- female). |
| dateofbirth | date | No | Date of birth of the card owner. |
*addresses
*| string| No| Card owner's address.
*active
*| bool| No| Activity
1. Receiving all cards
Method: GET
URL: {domain}/external/discount-card/
Description:
Returns a list of all discount cards on the site.
Query example:
GET {domain}/external/discount-card/
Example answer:
[
{
"id": 1,
"user_id": null,
"code": "1234567890123",
"legal_entity_name": "Test Company",
"first_name": "John",
"last_name": "Doe",
"barcode": "123456789012378476234768",
"accumulated_amount": "5166.00",
"sex": "m",
"date_of_birth": "2006-07-08",
"address": "Test Address"
}
]
2. Receive one card
Method: GET
URL: {domain}/external/discount-card/{id}/
Description:
Returns the data of one discount card by its identifier.
Query example:
GET {domain}/external/discount-card/1/
Example answer:
{
"id": 1,
"user_id": null,
"code": "1234567890123",
"legal_entity_name": "Test Company",
"first_name": "John",
"last_name": "Doe",
"barcode": "123456789012378476234768",
"accumulated_amount": "5166.00",
"sex": "m",
"date_of_birth": "2006-07-08",
"address": "Test Address"
}
3. Updating one card
Method: PUT
URL: {domain}/external/discount-card/{id}/
Description:
Updates the data of one discount card by its identifier.
Query example:
PUT {domain}/external/discount-card/1/
Content-Type: application/json
Request body:
{
"code": "9876543210987",
"barcode": "987654321012345678901234",
"accumulated_amount": "6000.00",
"first_name": "Jane",
"last_name": "Smith",
"sex": "f",
"date_of_birth": "1990-05-15",
"address": "New Test Address"
}
Example answer:
{
"id": 1,
"user_id": null,
"code": "9876543210987",
"legal_entity_name": "Test Company",
"first_name": "Jane",
"last_name": "Smith",
"barcode": "987654321012345678901234",
"accumulated_amount": "6000.00",
"sex": "f",
"date_of_birth": "1990-05-15",
"address": "New Test Address"
}
4. Creating multiple maps
Method: POST
URL: {domain}/external/discount-card/bulk-create/
Description:
Creates several discount cards at the same time.
Query example:
POST {domain}/external/discount-card/bulk-create/
Content-Type: application/json
Request body:
[
{
"code": "5432109876543",
"barcode": "543210987654321098765432",
"accumulated_amount": "5000.00",
"first_name": "Alice",
"last_name": "Johnson",
"sex": "f",
"date_of_birth": "1992-08-12",
"address": "Sample Address 1"
},
{
"code": "6789012345678",
"barcode": "678901234567890123456789",
"accumulated_amount": "3000.00",
"first_name": "Bob",
"last_name": "Brown",
"sex": "m",
"date_of_birth": "1985-03-20",
"address": "Sample Address 2"
}
]
Example answer:
[
{
"id": 2,
"user_id": null,
"code": "5432109876543", "legalentityname": null, "firstname": "Alice", "lastname": "Johnson", "barcode": "543210987654321098765432", "accumulatedamount": "5000.00", "sex": "f", "dateofbirth": "1992-08-12", "address": "Sample Address 1" }, { "id": 3, "userid": null, "code": "6789012345678", "legalentityname": null, "firstname": "Bob", "lastname": "Brown", "barcode": "678901234567890123456789", "accumulatedamount": "3000.00", "sex": "m", "dateof_birth": "1985-03-20", "address": "Sample Address 2" } ]
5. Update multiple maps
Method: PUT
URL: {domain}/external/discount-card/bulk-update/
Description:
Updates data for several discount cards simultaneously.
Query example:
PUT {domain}/external/discount-card/bulk-update/
Content-Type: application/json
Request body:
[
{
"id": 1,
"barcode": "987654321012345678901235",
"accumulated_amount": "7000.00",
"first_name": "John",
"last_name": "Doe Updated"
},
{
"id": 2,
"barcode": "5432109876543210987654321",
"accumulated_amount": "5500.00",
"first_name": "Alice Updated"
}
]
Example answer:
[
{
"id": 1,
"user_id": null,
"code": "9876543210987",
"legal_entity_name": "Test Company",
"first_name": "John",
"last_name": "Doe Updated",
"barcode": "987654321012345678901235",
"accumulated_amount": "7000.00",
"sex": "m",
"date_of_birth": "2006-07-08",
"address": "New Test Address"
},
{
"id": 2,
"user_id": null,
"code": "5432109876543",
"legal_entity_name": null,
"first_name": "Alice Updated",
"last_name": "Johnson",
"barcode": "5432109876543210987654321",
"accumulated_amount": "5500.00",
"sex": "f",
"date_of_birth": "1992-08-12",
"address": "Sample Address 1"
}
]
Was the article helpful?
Yes, thank you! Unfortunately no