Groups
This process simplifies the management of user permissions for divisions by using groups. Groups link users and divisions, enabling permissions to be assigned to many users at once. When a user is added to a group, they automatically gain access to the divisions associated with that group. This approach reduces the complexity of managing individual user permissions and ensures consistent application of permissions. Administrators can manage access easily by modifying group memberships and their associated divisions.
Create Group
Creates a new group to manage user permissions for divisions.
Example Request
curl --location --request POST '{B2B_Backend_URL}/api/v1/groups/' \
--header 'Authorization: Token {token} \
--header 'Content-Type: application/json' \
--data '{
"name": "Test Group"
}'
Example Response (201 Created)
{
"pk": 199,
"name": "Test Group"
}
List Groups
Retrieves a list of all groups, including their PKs and names.
Example Request
curl --location --request GET '{B2B_Backend_URL}/api/v1/groups/' \
--header 'Authorization: Token {token} \
--header 'Content-Type: application/json'
Example Response (200 OK)
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"pk": 199,
"name": "Test Group"
}
]
}
Update Group Name
Updates the name of a specific group.
Example Request
curl --location --request PUT '{B2B_Backend_URL}/api/v1/groups/{group_pk}/' \
--header 'Authorization: Token {token} \
--header 'Content-Type: application/json' \
--data '{
"name": "Test Group Updated"
}'
Example Response (200 OK)
{
"pk": 199,
"name": "Test Group Updated"
}
Delete Group
Deletes a specific group from the system.
Example Request
curl --location --request DELETE '{B2B_Backend_URL}/api/v1/groups/{group_id}/' \
--header 'Authorization: Token {token}'
Example Response (204 No Content)
204 No Content
Assign Users to Group
Adds one or more users to a group.
Request Parameters
Parameter | Data Type | Description |
---|---|---|
users | List | User ID information is provided in a list format. |
Example Request
curl --location --request POST '{B2B_Backend_URL}/api/v1/groups/{group_id}/users/' \
--header 'Authorization: Token {token} \
--header 'Content-Type: application/json' \
--data '{
"users": [859]
}'
Example Response (200 OK)
[
{
"id": 859,
"email": "example@example.com"
}
]
List Group Users
Retrieves a list of users associated with a specific group.
Example Request
curl --location --request GET '{B2B_Backend_URL}/api/v1/groups/{group_id}/users/' \
--header 'Authorization: Token {token} \
--header 'Content-Type: application/json'
Example Response (200 OK)
[
{
"id": 859,
"first_name": "John",
"last_name": "Doe",
"email": "example@example.com",
"division": null
}
]
Remove User from Group
Removes a specific user from a group.
Example Request
curl --location --request DELETE '{B2B_Backend_URL}/api/v1/groups/{group_id}/users/{user_id}' \
--header 'Authorization: Token {token}'
Example Response (204 No Content)
204 No Content
Assign Division to Group
Assigns one or more divisions to a group.
Request Parameters
Parameter | Data Type | Description |
---|---|---|
divisions | List | Division ID information is provided in a list format. |
Example Request
curl --location --request POST '{B2B_Backend_URL}/api/v1/groups/{group_id}/divisions/' \
--header 'Authorization: Token {token} \
--header 'Content-Type: application/json' \
--data '{
"divisions": [2097]
}'
Example Response (200 OK)
{
"divisions": [
2097
]
}
List Group Divisions
Retrieves a list of all divisions assigned to a specific group.
Example Request
curl --location --request GET '{B2B_Backend_URL}/api/v1/groups/{group_id}/divisions/' \
--header 'Authorization: Token {token} \
--header 'Content-Type: application/json'
Example Response (200 OK)
[
{
"id": 2097,
"name": "Division Name",
"division_type": "sub",
"parent": 1388,
"erp_code": "erp_code",
"country_id": 138,
"city_id": 516,
"township_id": 1144,
"district_id": 1145,
"address": "Test Address",
"phone_number": "05999999999",
"fax_number": "123123",
"is_active": true,
"latitude": null,
"longitude": null,
"monthly_order_limit": "0.00",
"current_balance": "0.00",
"current_balance_last_update": null,
"extra_data": {
"email": [],
"currency": "USD",
"channel_code": "9",
"channel_name": "channel name",
"payment_term": 0,
"discount_rate": 0,
"lot_properties": [],
"provision_limit": null
}
}
]
Remove Division from Group
Removes a specific division from the group.
Example Request
curl --location --request DELETE '{B2B_Backend_URL}/api/v1/groups/{group_id}/divisions/{division_id}' \
--header 'Authorization: Token {token}'
Example Response (204 No Content)
204 No Content