# Update von Bonus Punkten mit der API

Wir stellen die API für die Aktualisierung von Kundenpunkten zur Verfügung.\
Nachfolgend findest du eine Postman-Sammlung mit allen erforderlichen Daten.\
Die postman-Sammlung enthält diese Variablen:

```
SHOPWARE_DOMAIN - Die Domain des Shopware Projekts, ohne http/https Protokol.
SW_ACCESS_KEY - Der Shopware Access Key. (Wird in Shopware definiert)
SW_SECRET_ACCESS_KEY - Der Shopware Secret Key. (Wird in Shopware definiert)
ACCESS_TOKEN - Das Bearer Token. (Wird automatisch ausgefüllt nach Ausführung von "1. Obtain API access token" aus der Kollektion)
```

Der Testvorgang mit einem Postman:\
Erstelle eine JSON Datei mit dem unten stehenden Code.

1. Importieren eine Sammlung. (eine Datei im JSON-Format)
2. Füllen die Variablen der Sammlung aus.
3. Führen den Post „1. Obtain API access token“ aus, um die erforderliche Variable ACCESS\_TOKEN zu füllen.
4. Führe andere Einträge aus der Sammlung aus. (Aktualisierung der Bonuspunkte nach Kunden-ID oder -nummer)

```
{
	"info": {
		"_postman_id": "55d7c3c5-bd28-44ad-bb5a-093a40ccd426",
		"name": "PremsBonusSystem: Update bonus points",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "5184947"
	},
	"item": [
		{
			"name": "1. Obtain API access token",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var jsonData = JSON.parse(responseBody);",
							"pm.collectionVariables.set(\"ACCESS_TOKEN\", jsonData.access_token);"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"grant_type\": \"client_credentials\",\n  \"client_id\": \"{{SW_ACCESS_KEY}}\",\n  \"client_secret\": \"{{SW_SECRET_ACCESS_KEY}}\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://{{SHOPWARE_DOMAIN}}/api/oauth/token",
					"protocol": "https",
					"host": [
						"{{SHOPWARE_DOMAIN}}"
					],
					"path": [
						"api",
						"oauth",
						"token"
					]
				}
			},
			"response": []
		},
		{
			"name": "Update bonus points by customer number",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{ACCESS_TOKEN}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"customerNumber\": \"10382\",      // Customer number\n    \"description\": \"Test points\",   // Description for added/removed bonus points\n    \"points\": 5,                    // Amount of points, can be positive or negative\n    \"salesChannelId\": \"\"            // Optional: If it's not defined, it's obtained from the customer\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://{{SHOPWARE_DOMAIN}}/api/v2/prems-bonus-system/create-bonus-booking",
					"protocol": "https",
					"host": [
						"{{SHOPWARE_DOMAIN}}"
					],
					"path": [
						"api",
						"v2",
						"prems-bonus-system",
						"create-bonus-booking"
					]
				}
			},
			"response": []
		},
		{
			"name": "Update bonus points by customer ID",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{ACCESS_TOKEN}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"customerId\": \"019685763d44731cb4ac5938f107993e\",   // Customer ID\n    \"description\": \"Test points\",                       // Description for added/removed bonus points\n    \"points\": 5,                                        // Amount of points, can be positive or negative\n    \"salesChannelId\": \"\"                                // Optional: If it's not defined, it's obtained from the customer\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://{{SHOPWARE_DOMAIN}}/api/_action/prems/create-bonus-booking-by-customer-id",
					"protocol": "https",
					"host": [
						"{{SHOPWARE_DOMAIN}}"
					],
					"path": [
						"api",
						"_action",
						"prems",
						"create-bonus-booking-by-customer-id"
					]
				}
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "SHOPWARE_DOMAIN",
			"value": "domain.dev",
			"type": "string"
		},
		{
			"key": "SW_ACCESS_KEY",
			"value": "xxx",
			"type": "string"
		},
		{
			"key": "SW_SECRET_ACCESS_KEY",
			"value": "xxx",
			"type": "string"
		},
		{
			"key": "ACCESS_TOKEN",
			"value": "",
			"type": "string"
		}
	]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.premsoft.de/plugins/bonus-system/admin-api/update-von-bonus-punkten-mit-der-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
