API UpdateAccountProduct
Request parameters:
- tenant - (mandatory) - business tenant
- account_id - (conditional; group 1) - Account ID
- account_name - (conditional; group 1) - Account Name
- account_code - (conditional; group 1) - Account Code
- sold_product_id - (conditional; group 2) - Sold Product ID (ID of Product which is sold to Account)
- product_id - (conditional; group 2) - Product ID (ID of Product in configuration)
- product_name - (conditional; group 2) - Product Name (name of Product in configuration)
- params_to_modify - (optional; default []) - list of product parameters that should be updated; each object in the list consists of following details
- field - name of parameter that should be updated
- action - action that should be applied; supported values are set (ovewrite param value), update (increment or decrement param value), reset (reset param value to a default one) and delete (delete param value)
- value - value to apply; used only with set and update actions
- skip_lookup_account - (optional; default false) - is used only when account_id is provided; skips extra call to DB for Account verification
One of conditional parameters: account_id, or account_name, or account_code - is mandatory to be provided. One of conditional parameters: sold_product_id, or product_id, or product_name - is mandatory to be provided.
Response parameters:
- UpdateAccountProduct
- request
- "input" (request parameters) as is; only those parameters that were sent in input
- response
- account_id - Account identification
- sold_product_id - Sold Product identification
- modified_parameters - list of modified parameters; each object in the list consists of following details
- field - updated parameter name
- old_value - old value of updated parameter
- new_value - new value of updated parameter; empty in case of delete action
- diff - diff between old and new value; valueable for numeric parameters only; for all other types will have empty string ""
- request
Example of request
{
"tenant": "zegoal",
"account_id": 1187,
"sold_product_id": 1892,
"params_to_modify": [
{
"action": "update",
"field": "number_of_users_admin",
"value": 100
},
{
"action": "set",
"field": "price_of_user_admin",
"value": -160
},
{
"action": "reset",
"field": "gps_tracking"
},
{
"action": "delete",
"field": "number_of_tasks"
}
]
}
CODE
Example of response
{
"processing_result": {
"text": "success",
"status": "ok",
"code": 0
},
"processing_date": "2019-12-04 18:04:17",
"UpdateAccountProduct": {
"response": {
"sold_product_id": 1892,
"modified_parameters": [
{
"old_value": 20,
"new_value": 120,
"field": "number_of_users_admin",
"diff": 100
},
{
"old_value": -16,
"new_value": -160,
"field": "price_of_user_admin",
"diff": -144
},
{
"old_value": true,
"new_value": true,
"field": "gps_tracking",
"diff": ""
},
{
"old_value": 6000,
"new_value": 6000,
"field": "number_of_tasks",
"diff": 0
}
],
"account_id": 1187
},
"request": {
"tenant": "zegoal",
"sold_product_id": 1892,
"params_to_modify": [
{
"value": 100,
"field": "number_of_users_admin",
"action": "update"
},
{
"value": -160,
"field": "price_of_user_admin",
"action": "set"
},
{
"field": "gps_tracking",
"action": "reset"
},
{
"field": "number_of_tasks",
"action": "delete"
}
],
"account_id": 1187
}
}
}
CODE