Unit¶
The Unit is part of Tenant. A Unit may be a department or contact center within an organization. Each Unit may contain one or more other organizational sub-units and act as a “Parent Unit” to them.
Unit Domain Model¶
Represent the Unit domain model with available properties and its behaviors.
Note
Note that domain model is used for write methods POST (Create) and PUT (Update) and as result of read-only method GET/:id (GetById).
| Name | Description | Type | Required | Read-only | Default |
|---|---|---|---|---|---|
id |
Representing Unit identifier. | guid |
yes | yes | |
name |
The name of Unit. | string(50) |
yes | no | |
description |
The description of Unit. | string(255) |
no | no | |
isActive |
Denotes whether the Unit state is active or inactive. | boolean |
yes | no | active (true) |
isDeleted |
Denotes whether the Unit state is deleted or not. | boolean |
yes | [partially] | not deleted (false) |
parentUnitId |
Represent the hierarchical parent of Unit. If there is no parent Unit, then Unit is root. | guid |
no | no | Unit is root (null) |
managers |
The Unit assigned [Managers (User)](/v1/user). | array(guid) |
no | no | |
| Lookups | |||||
unitsLookup |
The dictionary of active and not deleted Units,
needed for choosing parent Unit and setting parentUnitId. |
dictionary(guid, string) |
N/A | N/A | N/A |
usersLookup |
The dictionary of active and not deleted Users
needed for setting the Unit managers. |
dictionary(guid, string) |
N/A | N/A | N/A |
Note
The Unit properties names (Name column) is for default usage by JSON, for C# Wrapper usage the Unit properties are capitalized (eg. Id, Name,..)!
Warning
isDeleted as true and also by default it is flagged isActive as false. Note that status isActive will remain “locked” until the Unit’s isDeleted state is updated to false or not deleted anymore. Then isActive is “unlocked” and can be changed. If the Unit is deleted and on update is tried to change isActive property, server will silently ignore sent isActive property.Unit List Model¶
Represent the Unit list model with available properties.
Note
| Name | Description | Type |
|---|---|---|
id |
Representing Unit identifier. | guid |
name |
The name of Unit. | string |
description |
The description of Unit. | string |
isActive |
Denotes whether the Unit state is active or inactive. | boolean |
isDeleted |
Denotes whether the Unit state is deleted or not. | boolean |
parentUnitName |
The name of Unit parent. Needed for representing the parent unit in list of Units. | string |
Note
The Unit properties names (Name column) is for default usage by JSON, for C# Wrapper usage the Unit properties are capitalized (eg. Id, Name,..)!
List of Units¶
The list of Units for current Tenant.
Default REST approach¶
GET /api/v1/:tenantCode/units
Parameters¶
tenantCodeCurrent Tenant code, a validintegergreater or equal to 1000.
Danger
Remember to add API Key as customer key and API Secret as customer secret into your Request HTTP Header. See more in Getting Started.
Return value¶
- If there is no error:
JSONarray of [Unit List Model](/v1/unit#unit-list-model). - If there is an error:
JSONClient Errors object.
C# Wrapper approach¶
1 | UnitWrapper(int tenantCode, string apiKey, string apiSecret).GetAll();
|
Parameters¶
Return value¶
- If there is no error:
ResaultContent<ICollection<UnitList>>.Resultobject as collection of the [Unit List Model](/v1/unit#unit-list-model). - If there is an error:
ResaultContent<ICollection<UnitList>>.Errorobject. See more in Client Errors .
Example usage¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | int tenantCode = 1000;
string key = "ddZXdAZvWefFqxAEH62u";
string secret = "wx6GiQggg9YRH89XT5aKoY2qZLVquYjxARtgZhuGoFQX5w6Lws";
ITreeApiWrapper<Unit, UnitList>unitWrapper = new UnitWrapper(tenantCode, key, secret);
ResponseContent<ICollection<UnitList>> response = unitWrapper.GetAll();
if (response.Result != null)
{
// Use Result as List of Units for displaying.
ICollection<UnitList> units = response.Result;
}
else
{
// TODO: The error handling...
Console.WriteLine(response.Error);
}
|
Get Unit by Id¶
The Unit by requested Id for current Tenant.
Default REST approach¶
GET /api/v1/:tenantCode/units/:id
Parameters¶
tenantCodeCurrent Tenant code, a validintegergreater or equal to 1000.idThe Unit id, a valid and non-emptyguid.
Danger
Remember to add API Key as customer*key and API Secret as customer*secret into your Request HTTP Header. See more in Getting Started.
Return value¶
- If there is no error:
JSONas the [Unit Domain Model](/v1/unit#unit-model) object. - If there is an error:
JSONas the Client Errors object.
C# Wrapper approach¶
1 | UnitWrapper(int tenantCode, string apiKey, string apiSecret).GetById(Guid id);
|
Parameters¶
Return value¶
- If there is no error:
ResaultContent<Unit>.Resultobject as the [Unit Domain Model](/v1/unit#unit-model). - If there is an error:
ResaultContent<Unit>.Errorobject. See more in Client Errors .
Example usage¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | int tenantCode = 1000;
string key = "ddZXdAZvWefFqxAEH62u";
string secret = "wx6GiQggg9YRH89XT5aKoY2qZLVquYjxARtgZhuGoFQX5w6Lws";
Guid unitId = new Guid("f4fe3ea7-ed2a-41dd-acd2-91c45c8b4891");
ITreeApiWrapper<Unit, UnitList> unitWrapper = new UnitWrapper(tenantCode, key, secret);
ResponseContent<Unit> response = unitWrapper.GetById(unitId);
if (response.Result != null)
{
// Use Result as requested Unit for displaying.
Unit unit = response.Result;
}
else
{
// TODO: The error handling...
Console.WriteLine(response.Error);
}
|
Create Unit¶
The creation of new Unit for current Tenant.
Default REST approach¶
POST /api/v1/:tenantCode/units
Parameters¶
tenantCodeCurrent Tenant code, a validintegergreater or equal to 1000.unitJSONrepresentation of [Unit Domain Model](/v1/unit#unit-model) sent via Request HTTP Header.
Danger
Remember to add API Key as customer*key and API Secret as customer*secret into your Request HTTP Header. See more in Getting Started.
Return value¶
- If there is no error:
JSONrepresentation of newly created Unit as the [Unit Domain Model](/v1/unit#unit-model). - If there is an error:
JSONClient Errors object.
C# Wrapper approach¶
1 | UnitWrapper(int tenantCode, string apiKey, string apiSecret).Create(Unit unit);
|
Parameters¶
Return value¶
- If there is no error:
ResaultContent<Unit>.Resultobject as the [Unit Domain Model](/v1/unit#unit-model). - If there is an error:
ResaultContent<Unit>.Errorobject. See more in Client Errors .
Example usage¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | int tenantCode = 1000;
string key = "ddZXdAZvWefFqxAEH62u";
string secret = "wx6GiQggg9YRH89XT5aKoY2qZLVquYjxARtgZhuGoFQX5w6Lws";
ITreeApiWrapper<Unit, UnitList> unitWrapper = new UnitWrapper(tenantCode, key, secret);
// Get default data and lookup for units
Unit newUnit = unitWrapper.GetById(new Guid()).Result;
newUnit.Name = "Unit created from test";
newUnit.Description = "Unit created from test description.";
// Set parent Unit key from units lookup key.
newUnit.ParentUnitId = newUnit.UnitsLookup.FirstOrDefault().Key;
ResponseContent<Unit> response = unitWrapper.Create(newUnit);
if (response.Result != null)
{
// Use Result as newly created Unit for display.
Unit unit = response.Result;
}
else
{
// TODO: The error handling...
Console.WriteLine(response.Error);
}
|
Update Unit¶
Updates already existent Unit for current Tenant.
Default REST approach¶
PUT /api/v1/:tenantCode/units/:id
Parameters¶
tenantCodeCurrent Tenant code, a validintegergreater or equal to 1000.idThe Unit id, a valid and non-emptyguid.unitJSONrepresentation of [Unit Domain Model](/v1/unit#unit-model) sent via Request HTTP Header.
Danger
PUT verb method read more in Getting Started.Return value¶
- If there is no error:
JSONrepresentation of uodated Unit as the [Unit Domain Model](/v1/unit#unit-model). - If there is an error:
JSONClient Errors object.
C# Wrapper approach¶
1 | UnitWrapper(int tenantCode, string apiKey, string apiSecret).Update(Unit unit, bool updateViaPost = false);
|
Parameters¶
tenantCodeCurrent Tenant code, a validintegergreater or equal to 1000.apiKeyCurrent Tenant API Key provided by Qualtrak.apiSecretCurrent Tenant API Secret provided by Qualtrak.unitThe Unit model constructed from [Unit Domain Model](/v1/unit#unit-model) andIdmust be provided in it. If notArgumentExceptionwill be thrown!updateViaPostSet totrueif in your Web Server you don’t want to enablePUTmethod. Default isfalseor usePUTmethod!
Return value¶
- If there is no error:
ResaultContent<Unit>.Resultobject as the [Unit Domain Model](/v1/unit#unit-model). - If there is an error:
ResaultContent<Unit>.Errorobject. See more in Client Errors .
Example usage¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | int tenantCode = 1000;
string key = "ddZXdAZvWefFqxAEH62u";
string secret = "wx6GiQggg9YRH89XT5aKoY2qZLVquYjxARtgZhuGoFQX5w6Lws";
Guid unitId = new Guid("f4fe3ea7-ed2a-41dd-acd2-91c45c8b4891");
ITreeApiWrapper<Unit, UnitList> unitWrapper = new UnitWrapper(tenantCode, key, secret);
Unit unit = unitWrapper.GetById(unitId).Result;
unit.Name = "Unit updated from test";
unit.Description = "Unit updated from test description.";
// Set parent Unit key from units lookup key.
unit.ParentUnitId = unit.UnitsLookup.FirstOrDefault().Key;
// Update via PUT method (default).
ResponseContent<Unit> response = unitWrapper.Update(unit);
// Update via POST method (use true argument).
// ResponseContent<Unit> response = unitWrapper.Update(unit, true);
if (response.Result != null)
{
// Use Result of updated Unit for display.
Unit updatedUnit = response.Result;
}
else
{
// TODO: The error handling...
Console.WriteLine(response.Error);
}
|
Delete Unit¶
Deletes existent Unit for current Tenant.
Warning
isDeleted. When Unit is deleted it can be undeleted by setting isDeleted to false while updating Unit. \Default REST approach¶
DELETE /api/v1/:tenantCode/units/:id
Parameters¶
tenantCodeCurrent Tenant code, a validintegergreater or equal to 1000.idThe Unit id, a valid and non-emptyguid.
Danger
DELETE verb method read more in Getting Started.Return value¶
- There is no return value except if there is an error, the
JSONClient Errors object.
C# Wrapper approach¶
1 | UnitWrapper(int tenantCode, string apiKey, string apiSecret).Delete(Guid id, bool updateViaPost = false);
|
Parameters¶
tenantCodeCurrent Tenant code, a validintegergreater or equal to 1000.apiKeyCurrent Tenant API Key provided by Qualtrak.apiSecretCurrent Tenant API Secret provided by Qualtrak.idThe Unit id, a valid and non-emptyguid.updateViaPostSet totrueif in your Web Server you don’t want to enableDELETEmethod. Default isfalseor useDELETEmethod!
Return value¶
- If there is no error: no return value or
void. - If there is an error:
ResaultContent<Unit>.Errorobject. See more in Client Errors .
Example usage¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | int tenantCode = 1000;
string key = "ddZXdAZvWefFqxAEH62u";
string secret = "wx6GiQggg9YRH89XT5aKoY2qZLVquYjxARtgZhuGoFQX5w6Lws";
Guid unitId = new Guid("f4fe3ea7-ed2a-41dd-acd2-91c45c8b4891");
ITreeApiWrapper<Unit, UnitList> unitWrapper = new UnitWrapper(tenantCode, key, secret);
// Delete via DELETE method (default).
ResponseContent response = unitWrapper.Delete(unitId);
// Delete via POST method (use true argument).
// ResponseContent response = unitWrapper.Delete(unitId, true);
if (response.Error != null)
{
// TODO: The error handling...
Console.WriteLine(response.Error);
}
|