Exemplo n.º 1
0
        public async Task AddCustomerProfileAsync(CustomerDto customerDto)
        {
            if (await Store.ProfileExists(customerDto.Id))
            {
                return;
            }

            var dto = new PostVerificationProfileDto
            {
                locale = "en-US"
            };
            var result = await Client.PostAsync("verificationProfiles",
                                                new StringContent(JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json"));

            if (!result.IsSuccessStatusCode)
            {
                throw new VerificationException("Cannot add profile");
            }
            var jsonResponse = await result.Content.ReadAsStringAsync();

            var profile = JsonConvert.DeserializeObject <GetVerificationProfileDto>(jsonResponse);
            await Store.AddOrUpdateProfile(customerDto.Id, new Profile
            {
                Enrollments = 0,
                Id          = profile.VerificationProfileId
            });
        }