createSubOrganization method

Future<TCreateSubOrganizationResponse> createSubOrganization({
  1. required TCreateSubOrganizationBody input,
})

Create a new sub-organization.

Sign the provided TCreateSubOrganizationBody with the client's stamp function and submit the request (POST /public/v1/submit/create_sub_organization).

See also: stampCreateSubOrganization.

Implementation

Future<TCreateSubOrganizationResponse> createSubOrganization({
  required TCreateSubOrganizationBody input,
}) async {
  final body = packActivityBody(
    bodyJson: input.toJson(),
    fallbackOrganizationId: input.organizationId ??
        config.organizationId ??
        (throw Exception(
            "Missing organization ID, please pass in a sub-organizationId or instantiate the client with one.")),
    activityType: 'ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7',
  );
  return await request<Map<String, dynamic>, TCreateSubOrganizationResponse>(
      "/public/v1/submit/create_sub_organization",
      body,
      (json) => TCreateSubOrganizationResponse.fromJson(
          transformActivityResponse(json, 'CreateSubOrganization')));
}