Exemplo n.º 1
0
        /// <summary>
        /// Registar um novo usuário
        /// </summary>
        /// <param name="registerRequest">Dados para o registro</param>
        /// <returns></returns>
        public async Task<RegisterResponse> RegisterNewUserAsync(
            RegisterRequest registerRequest)
        {
            _httpClient.DefaultRequestHeaders.Authorization = null;

            HttpResponseMessage response = await _httpClient.PostAsync(
                Endpoints.Auth.Register_v1_0,
                registerRequest.ToStringContent()).ConfigureAwait(false);
            response.StatusCode.Should().Be(HttpStatusCode.OK);

            string bodyResponse = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            RegisterResponse registerResponse = JsonConvert.DeserializeObject<RegisterResponse>(
                    bodyResponse);

            registerResponse.Should().NotBeNull();
            registerResponse.FirstName.Should().Be(registerRequest.FirstName);
            registerResponse.LastName.Should().Be(registerRequest.LastName);
            registerResponse.Email.Should().Be(registerRequest.Email);
            registerResponse.Phone.Should().Be(registerRequest.Phone);
            registerResponse.IsEmailValidated.Should().BeFalse();
            registerResponse.RecoveryPasswordToken.Should().BeNullOrEmpty();

            return registerResponse;
        }