Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressValidationSvc ¶
type AddressValidationSvc interface {
AutocompleteAddress(ctx context.Context, req *AutocompleteAddressRequest) (*apiresource.List[apiresource.AddressSuggestion], *apierror.APIError)
GetAddressDetails(ctx context.Context, req *RetrieveAddressDetailsRequest) (*apiresource.AddressDetailsResult, *apierror.APIError)
ValidateAddress(ctx context.Context, req *ValidateAddressRequest) (*apiresource.ValidatedAddress, *apierror.APIError)
}
func NewAddressValidationSvc ¶
func NewAddressValidationSvc(config *AddressValidationSvcConfig) AddressValidationSvc
type AddressValidationSvcConfig ¶
type AddressValidationSvcConfig struct {
// CoreClient (required) is the core-service gRPC client.
CoreClient pb.CoreServiceClient
}
type AutocompleteAddressEndpoint ¶
type AutocompleteAddressEndpoint struct{}
Returns address suggestions for partial address text, for use in type-ahead address entry.
Only street addresses are suggested; cities, regions, and business listings are not returned. Suggestions are lookup results, not saved addresses in your account. Pass a suggestion's `id` to the address details endpoint to get the full parsed address.
func (*AutocompleteAddressEndpoint) Materialize ¶
func (e *AutocompleteAddressEndpoint) Materialize() *apiendpoint.APIEndpoint[*AutocompleteAddressRequest, *apiresource.List[apiresource.AddressSuggestion]]
type AutocompleteAddressRequest ¶
type AutocompleteAddressRequest struct {
// Partial address text to generate suggestions for.
Input string `query:"input" validate:"required"`
// Opaque token that groups a series of related autocomplete requests into a single session.
//
// Reuse the same token for each keystroke of one address entry, and again when you retrieve the details of the suggestion the user picks, so the whole entry is treated as one lookup.
SessionToken *string `query:"session_token"` // #nosec G117 -- not a secret, Google Maps session correlation token
}
Request for address autocomplete.
type RetrieveAddressDetailsEndpoint ¶
type RetrieveAddressDetailsEndpoint struct{}
Returns the full parsed address for a suggestion returned by address autocomplete.
Use this after the user picks a suggestion to get the street, city, state, postal code, and country to prefill an address form. Nothing is saved by this lookup; create an address separately to keep it.
func (*RetrieveAddressDetailsEndpoint) Materialize ¶
func (e *RetrieveAddressDetailsEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveAddressDetailsRequest, *apiresource.AddressDetailsResult]
type RetrieveAddressDetailsRequest ¶
type RetrieveAddressDetailsRequest struct {
// The place ID to look up, as returned in the `id` field of an address suggestion.
PlaceID string `path:"id" validate:"required"`
// Opaque token that ties this lookup to the autocomplete requests the suggestion came from.
//
// Pass the same token used for those autocomplete requests so the whole address entry is treated as one lookup.
SessionToken *string `query:"session_token"` // #nosec G117 -- not a secret, Google Maps session correlation token
}
Request to get details for a place.
type ValidateAddressEndpoint ¶
type ValidateAddressEndpoint struct{}
Checks an address against an address validation service and returns a standardized version of it.
Nothing is created or modified. Use this before creating or updating an address to confirm it is complete and to pick up corrected values. When the service can standardize the address, `formatted_address` and `components` carry the corrected values, and `validation_messages` explains anything that was inferred, replaced, or could not be confirmed.
func (*ValidateAddressEndpoint) Materialize ¶
func (e *ValidateAddressEndpoint) Materialize() *apiendpoint.APIEndpoint[*ValidateAddressRequest, *apiresource.ValidatedAddress]
type ValidateAddressRequest ¶
type ValidateAddressRequest struct {
// First line of the street address.
AddressLine1 string `json:"address_line_1" validate:"required"`
// Second line of the street address.
AddressLine2 field.Optional[string] `json:"address_line_2,omitzero"`
// City or locality.
City string `json:"city" validate:"required"`
// State or administrative area.
State string `json:"state" validate:"required"`
// Postal or ZIP code.
PostalCode string `json:"postal_code" validate:"required"`
// Two-letter country code, such as `US`.
//
// A full country name such as `United States` is recognized for a handful of common countries; send the two-letter code for anywhere else.
Country string `json:"country" validate:"required"`
}
Request to validate an address.
func (*ValidateAddressRequest) SchemaExample ¶
func (*ValidateAddressRequest) SchemaExample() any