Пример #1
0
        // creating a user that already exists with a Pending status does not create an additional user
        // creating a user that already exists with a Closed status creates an additional user
        private static void AddUser()
        {
            var user = new AccountCreationRequestUser {
                userName = "******", email = "*****@*****.**"
            };
            var authorizationHeaderValue = AuthorizationHeaderValueGetter.Get(ClientId, UserId, OAuthBasePath, PrivateKeyText);
            var result = AccountCreator.Create(ApiBaseUrl, AccountId, authorizationHeaderValue, user);

            Console.WriteLine($"Created User ID: {result.newUsers[0].userId}");
            Console.ReadKey();
        }
        public static AccountCreationResponse Create(string apiBaseUrl, int accountId, string authorizationHeaderValue, AccountCreationRequestUser user)
        {
            var resource     = $"v2/accounts/{accountId}/users";
            var headerParams = new Dictionary <string, string> {
                { "Content-Type", "application/json" }, { "Authorization", authorizationHeaderValue }
            };
            var users = new List <AccountCreationRequestUser> {
                user
            };
            var postBody = new Dictionary <string, object> {
                { "newUsers", users }
            };
            var result = RestResponseGetter <AccountCreationResponse> .GetPostResponse(apiBaseUrl, resource, headerParams, body : postBody);

            return(result);
        }