Bibliotecas de cliente da API Address Validation

Nesta página, mostramos como começar a usar as bibliotecas de cliente para a API Address Validation.

Leia mais sobre as bibliotecas de cliente em Explicações sobre bibliotecas de cliente.

Instalar a biblioteca de cliente

C#

Para mais informações, consulte Como configurar um ambiente de desenvolvimento em C#.

Install-Package Google.Maps.AddressValidation.V1 -Pre

Como configurar a autenticação

Quando você usa bibliotecas de cliente, utiliza o Application Default Credentials (ADC) para fazer a autenticação. Para acessar informações sobre como configurar o ADC, consulte Fornecer credenciais para o Application Default Credentials. Para informações sobre como usar o ADC com bibliotecas de cliente, consulte Autenticar usando bibliotecas de cliente.

Usar a biblioteca de cliente

C#

using Google.Maps.AddressValidation.V1;
using Google.Type;
using System.Threading.Tasks;

public sealed partial class GeneratedAddressValidationClientSnippets
{
    /// <summary>Snippet for ValidateAddressAsync</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task ValidateAddressRequestObjectAsync()
    {
        // Create client
        AddressValidationClient addressValidationClient = await AddressValidationClient.CreateAsync();
        // Initialize request argument(s)
        ValidateAddressRequest request = new ValidateAddressRequest
        {
            Address = new PostalAddress(),
            PreviousResponseId = "",
            EnableUspsCass = false,
            SessionToken = "",
        };
        // Make the request
        ValidateAddressResponse response = await addressValidationClient.ValidateAddressAsync(request);
    }
}

Outros recursos