Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Create a new user

Description

TheĀ Add() method is used to create a new user.

Package Details

Interface

IUserManager

Syntax

await UserManager.Add(User user)

Returns

Task<User>

API

POST
/api/v1/users

Parameters

Parameter

Description

Parameter Type

userDTO

UserDTO

Request body

excludeCoordinates (optional)

Set excludeCoordinates to true to exclude coordinates information

Request body

Sample request body

Code Block
{
  "FirstName": "string",
  "LastName": "string",
  "GCKey": {
    "MBUN": "string",
    "Issuer": "string"
  },
  "WindowsUserName": "string",
  "Verified": true,
  "PKI": "string",
  "AuthenticationType": "Anonymous",
  "Id": 0,
  "Phones": [
    {
      "Id": 0,
      "LocalNumber": "string",
      "AreaCode": "string",
      "CountryCode": "string",
      "ExtensionNumber": "string",
      "InternationalAccessNumber": "string",
      "InternationalNumber": "string",
      "LocationType": "Business",
      "IsPrimary": true,
      "PhoneType": "Landline",
      "DisplayPhoneNumber": "string"
    }
  ],
  "Emails": [
    {
      "Id": 0,
      "LocationType": "Business",
      "IsPrimary": true,
      "EmailAddress": "string"
    }
  ],
  "Addresses": [
    {
      "Id": 0,
      "LocationType": "Business",
      "IsPrimary": true,
      "CoordinateType": "Mail",
      "SubAddressType": "string",
      "FloorSectionNumber": "string",
      "SuiteApartmentNumber": "string",
      "StreetCivicNumber": "string",
      "StreetName": "string",
      "PostalZipCode": "string",
      "BuildingName": "string",
      "StreetDirection": "None",
      "StreetType": "None",
      "CountryCode": 0,
      "CountrySubdivisionCode": "string",
      "DeliveryInstallationArea": "string",
      "DeliveryInstallQualifier": "string",
      "GenDeliveryCategory": "string",
      "RouteServiceType": "string",
      "BoxNumber": "string",
      "RouteServiceNumber": "string",
      "UnregisteredCityTownName": "string",
      "DeliveryDirective": "string",
      "GeneratedStreetAddress": "string",
      "CityTown": "string",
      "CityTownName": "string"
    }
  ]
}

Returns

On success, 200 Ok

On error, 400 Bad Request

On authorization error, 403 Forbidden

Example

Code Block
languagec#
var user = new User
  {
      FirstName = "John",
      LastName = "Doe",
      AuthenticationContext = new AuthenticationContext
      {
          GCKey = new GCKey
          {
              MBUN = Guid.NewGuid().ToString(),
              Issuer = MTOAConstants.GCKeyDefaultIssuer,
          },
          Type = AuthenticationType.GCKey
      }
  };
  
var phoneCoordinate = new PhoneCoordinate
  {
      LocalNumber = Rand.Next(2000000, 9999999).ToString("D7"),
      AreaCode = "613",
      CountryCode = "1",
      IsPrimary = true,
      PhoneType = PhoneType.Landline,
      LocationType = CoordinateLocationType.Business
  };
  
var emailCoordinate = new EmailCoordinate
  {
      LocationType = CoordinateLocationType.Business,
      IsPrimary = true,
      EmailAddress = "domain@domain.com"
  };
  
var mailCoordinate = new MailCoordinate
  {
      LocationType = CoordinateLocationType.Individual,
      CoordinateType = CoordinateType.Mail,
      StreetName = "300 Sparks Street",
      PostalZipCode = "K1R7S3",
      CountryCode = 124,
      CountrySubdivisionCode = "ON",
      CityTownName = "OTTAWA"
  };
            
user.Coordinates.Add(phoneCoordinate);
user.Coordinates.Add(emailCoordinate);
user.Coordinates.Add(mailCoordinate);
            
await _userManager.Add(user);