@googlemaps/addressvalidation
Version:
239 lines (238 loc) • 14.1 kB
TypeScript
import type * as gax from 'google-gax';
import type { Callback, CallOptions, Descriptors, ClientOptions } from 'google-gax';
import * as protos from '../../protos/protos';
/**
* The service for validating addresses.
* @class
* @memberof v1
*/
export declare class AddressValidationClient {
private _terminated;
private _opts;
private _providedCustomServicePath;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
private _universeDomain;
private _servicePath;
private _log;
auth: gax.GoogleAuth;
descriptors: Descriptors;
warn: (code: string, message: string, warnType?: string) => void;
innerApiCalls: {
[name: string]: Function;
};
addressValidationStub?: Promise<{
[name: string]: Function;
}>;
/**
* Construct an instance of AddressValidationClient.
*
* @param {object} [options] - The configuration object.
* The options accepted by the constructor are described in detail
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
* The common options are:
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
* @param {string} [options.credentials.private_key]
* @param {string} [options.email] - Account email address. Required when
* using a .pem or .p12 keyFilename.
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
* .p12 key downloaded from the Google Developers Console. If you provide
* a path to a JSON file, the projectId option below is not necessary.
* NOTE: .pem and .p12 require you to specify options.email as well.
* @param {number} [options.port] - The port on which to connect to
* the remote host.
* @param {string} [options.projectId] - The project ID from the Google
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
* need to avoid loading the default gRPC version and want to use the fallback
* HTTP implementation. Load only fallback version and pass it to the constructor:
* ```
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
* const client = new AddressValidationClient({fallback: true}, gax);
* ```
*/
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.
* @deprecated Use the apiEndpoint method of the client instance.
* @returns {string} The DNS address for this service.
*/
static get servicePath(): string;
/**
* The DNS address for this API service - same as servicePath.
* @deprecated Use the apiEndpoint method of the client instance.
* @returns {string} The DNS address for this service.
*/
static get apiEndpoint(): string;
/**
* The DNS address for this API service.
* @returns {string} The DNS address for this service.
*/
get apiEndpoint(): string;
get universeDomain(): string;
/**
* The port for this API service.
* @returns {number} The default port for this service.
*/
static get port(): number;
/**
* The scopes needed to make gRPC calls for every method defined
* in this service.
* @returns {string[]} List of default scopes.
*/
static get scopes(): never[];
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
/**
* Validates an address.
*
* @param {Object} request
* The request object that will be sent.
* @param {google.type.PostalAddress} request.address
* Required. The address being validated. Unformatted addresses should be
* submitted via {@link protos.google.type.PostalAddress.address_lines|`address_lines`}.
*
* The total length of the fields in this input must not exceed 280
* characters.
*
* Supported regions can be found
* [here](https://developers.google.com/maps/documentation/address-validation/coverage).
*
* The {@link protos.google.type.PostalAddress.language_code|language_code} value in the
* input address is reserved for future uses and is ignored today. The
* validated address result will be populated based on the preferred language
* for the given address, as identified by the system.
*
* The Address Validation API ignores the values in
* {@link protos.google.type.PostalAddress.recipients|recipients} and
* {@link protos.google.type.PostalAddress.organization|organization}. Any values in those
* fields will be discarded and not returned. Please do not set them.
* @param {string} request.previousResponseId
* This field must be empty for the first address validation request. If
* more requests are necessary to fully validate a single address (for
* example if the changes the user makes after the initial validation need to
* be re-validated), then each followup request must populate this field with
* the
* {@link protos.google.maps.addressvalidation.v1.ValidateAddressResponse.response_id|response_id}
* from the very first response in the validation sequence.
* @param {boolean} request.enableUspsCass
* Enables USPS CASS compatible mode. This affects _only_ the
* [google.maps.addressvalidation.v1.ValidationResult.usps_data] field of
* [google.maps.addressvalidation.v1.ValidationResult]. Note: for USPS CASS
* enabled requests for addresses in Puerto Rico, a
* [google.type.PostalAddress.region_code] of the `address` must be provided
* as "PR", or an [google.type.PostalAddress.administrative_area] of the
* `address` must be provided as "Puerto Rico" (case-insensitive) or "PR".
*
* It's recommended to use a componentized `address`, or alternatively specify
* at least two [google.type.PostalAddress.address_lines] where the first line
* contains the street number and name and the second line contains the city,
* state, and zip code.
* @param {string} [request.sessionToken]
* Optional. A string which identifies an Autocomplete session for billing
* purposes. Must be a URL and filename safe base64 string with at most 36
* ASCII characters in length. Otherwise an INVALID_ARGUMENT error is
* returned.
*
* The session begins when the user starts typing a query, and concludes when
* they select a place and a call to Place Details or Address Validation is
* made. Each session can have multiple autocomplete queries, followed by one
* Place Details or Address Validation request. The credentials used for each
* request within a session must belong to the same Google Cloud Console
* project. Once a session has concluded, the token is no longer valid; your
* app must generate a fresh token for each session. If the `session_token`
* parameter is omitted, or if you reuse a session token, the session is
* charged as if no session token was provided (each request is billed
* separately).
*
* Note: Address Validation can only be used in sessions with the
* Autocomplete (New) API, not the old Autocomplete API. See
* https://developers.google.com/maps/documentation/places/web-service/session-pricing
* for more details.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing {@link protos.google.maps.addressvalidation.v1.ValidateAddressResponse|ValidateAddressResponse}.
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
* for more details and examples.
* @example <caption>include:samples/generated/v1/address_validation.validate_address.js</caption>
* region_tag:addressvalidation_v1_generated_AddressValidation_ValidateAddress_async
*/
validateAddress(request?: protos.google.maps.addressvalidation.v1.IValidateAddressRequest, options?: CallOptions): Promise<[
protos.google.maps.addressvalidation.v1.IValidateAddressResponse,
(protos.google.maps.addressvalidation.v1.IValidateAddressRequest | undefined),
{} | undefined
]>;
validateAddress(request: protos.google.maps.addressvalidation.v1.IValidateAddressRequest, options: CallOptions, callback: Callback<protos.google.maps.addressvalidation.v1.IValidateAddressResponse, protos.google.maps.addressvalidation.v1.IValidateAddressRequest | null | undefined, {} | null | undefined>): void;
validateAddress(request: protos.google.maps.addressvalidation.v1.IValidateAddressRequest, callback: Callback<protos.google.maps.addressvalidation.v1.IValidateAddressResponse, protos.google.maps.addressvalidation.v1.IValidateAddressRequest | null | undefined, {} | null | undefined>): void;
/**
* Feedback about the outcome of the sequence of validation attempts. This
* should be the last call made after a sequence of validation calls for the
* same address, and should be called once the transaction is concluded. This
* should only be sent once for the sequence of `ValidateAddress` requests
* needed to validate an address fully.
*
* @param {Object} request
* The request object that will be sent.
* @param {google.maps.addressvalidation.v1.ProvideValidationFeedbackRequest.ValidationConclusion} request.conclusion
* Required. The outcome of the sequence of validation attempts.
*
* If this field is set to `VALIDATION_CONCLUSION_UNSPECIFIED`, an
* `INVALID_ARGUMENT` error will be returned.
* @param {string} request.responseId
* Required. The ID of the response that this feedback is for. This should be
* the
* {@link protos.google.maps.addressvalidation.v1.ValidateAddressRequest.response_id|response_id}
* from the first response in a series of address validation attempts.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing {@link protos.google.maps.addressvalidation.v1.ProvideValidationFeedbackResponse|ProvideValidationFeedbackResponse}.
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
* for more details and examples.
* @example <caption>include:samples/generated/v1/address_validation.provide_validation_feedback.js</caption>
* region_tag:addressvalidation_v1_generated_AddressValidation_ProvideValidationFeedback_async
*/
provideValidationFeedback(request?: protos.google.maps.addressvalidation.v1.IProvideValidationFeedbackRequest, options?: CallOptions): Promise<[
protos.google.maps.addressvalidation.v1.IProvideValidationFeedbackResponse,
(protos.google.maps.addressvalidation.v1.IProvideValidationFeedbackRequest | undefined),
{} | undefined
]>;
provideValidationFeedback(request: protos.google.maps.addressvalidation.v1.IProvideValidationFeedbackRequest, options: CallOptions, callback: Callback<protos.google.maps.addressvalidation.v1.IProvideValidationFeedbackResponse, protos.google.maps.addressvalidation.v1.IProvideValidationFeedbackRequest | null | undefined, {} | null | undefined>): void;
provideValidationFeedback(request: protos.google.maps.addressvalidation.v1.IProvideValidationFeedbackRequest, callback: Callback<protos.google.maps.addressvalidation.v1.IProvideValidationFeedbackResponse, protos.google.maps.addressvalidation.v1.IProvideValidationFeedbackRequest | null | undefined, {} | null | undefined>): void;
/**
* Terminate the gRPC channel and close the client.
*
* The client will no longer be usable and all future behavior is undefined.
* @returns {Promise} A promise that resolves when the client is closed.
*/
close(): Promise<void>;
}