"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
import dataclasses
import dateutil.parser
from .addressvalidationresults import AddressValidationResults
from dataclasses_json import Undefined, dataclass_json
from datetime import datetime
from shippo import utils
from typing import Optional, Union


@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclasses.dataclass
class Address:
    r"""Address represents the address as retrieved from the database"""
    country: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('country') }})
    r"""ISO 3166-1 alpha-2 country codes and country names can be used. For most consistent results, we reccomend using country codes like `US` or `DE`.
    If using country names, please ensure they are spelled correctly and in English. Country names are converted to country codes.
    Refer to this <a href=\"https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements\" target=\"_blank\">guide</a> for a list of country codes.
    Sending a country is always required.
    """
    name: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name'), 'exclude': lambda f: f is None }})
    r"""**required for purchase**<br>
    First and Last Name of the addressee
    """
    company: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('company'), 'exclude': lambda f: f is None }})
    r"""Company Name"""
    street1: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('street1'), 'exclude': lambda f: f is None }})
    r"""**required for purchase**<br>
    First street line, 35 character limit. Usually street number and street name (except for DHL Germany, see street_no).
    """
    street2: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('street2'), 'exclude': lambda f: f is None }})
    r"""Second street line, 35 character limit."""
    street3: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('street3'), 'exclude': lambda f: f is None }})
    r"""Third street line, 35 character limit.
    Only accepted for USPS international shipments, UPS domestic and UPS international shipments.
    """
    street_no: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('street_no'), 'exclude': lambda f: f is None }})
    r"""Street number of the addressed building.
    This field can be included in street1 for all carriers except for DHL Germany.
    """
    city: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('city'), 'exclude': lambda f: f is None }})
    r"""**required for purchase**<br>
    Name of a city. When creating a Quote Address, sending a city is optional but will yield more accurate Rates. 
    Please bear in mind that city names may be ambiguous (there are 34 Springfields in the US). Pass in a state 
    or a ZIP code (see below), if known, it will yield more accurate results.
    """
    state: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('state'), 'exclude': lambda f: f is None }})
    r"""**required for purchase for some countries**<br>
    State/Province values are required for shipments from/to the US, AU, and CA. UPS requires province for some 
    countries (i.e Ireland). To receive more accurate quotes, passing this field is recommended. Most carriers 
    only accept two or three character state abbreviations.
    """
    zip: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('zip'), 'exclude': lambda f: f is None }})
    r"""**required for purchase**<br>
    Postal code of an Address. When creating a Quote Addresses, sending a ZIP is optional but will yield more 
    accurate Rates.
    """
    phone: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('phone'), 'exclude': lambda f: f is None }})
    r"""Addresses containing a phone number allow carriers to call the recipient when delivering the Parcel. This
    increases the probability of delivery and helps to avoid accessorial charges after a Parcel has been shipped.
    """
    email: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('email'), 'exclude': lambda f: f is None }})
    r"""E-mail address of the contact person, RFC3696/5321-compliant."""
    is_residential: Optional[bool] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('is_residential'), 'exclude': lambda f: f is None }})
    metadata: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('metadata'), 'exclude': lambda f: f is None }})
    r"""A string of up to 100 characters that can be filled with any additional information you want
    to attach to the object.
    """
    is_complete: Optional[bool] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('is_complete'), 'exclude': lambda f: f is None }})
    r"""Complete addresses contain all required values.<br><br>Incomplete addresses have failed one or multiple
    validations.<br>Incomplete Addresses are eligible for requesting rates but lack at least one required 
    value for purchasing labels.
    """
    latitude: Optional[Latitude] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('latitude'), 'exclude': lambda f: f is None }})
    r"""Latitude of address"""
    longitude: Optional[Longitude] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('longitude'), 'exclude': lambda f: f is None }})
    r"""Longitude of address"""
    object_created: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('object_created'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'exclude': lambda f: f is None }})
    r"""Date and time of Address creation."""
    object_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('object_id'), 'exclude': lambda f: f is None }})
    r"""Unique identifier of the given Address object.
    This ID is required to create a Shipment object.
    """
    object_owner: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('object_owner'), 'exclude': lambda f: f is None }})
    r"""Username of the user who created the Address object."""
    object_updated: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('object_updated'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'exclude': lambda f: f is None }})
    r"""Date and time of last Address update. Since you cannot update Addresses after they were created, this time
    stamp reflects the time when the Address was changed by Shippo's systems for the last time, e.g., during the 
    approximation of one or more values.
    """
    validation_results: Optional[AddressValidationResults] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('validation_results'), 'exclude': lambda f: f is None }})
    r"""Object that contains information regarding if an address had been validated or not. Also contains any messages
    generated during validation. Children keys are <code>is_valid</code>(boolean) and <code>messages</code>(array).
    """
    test: Optional[bool] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('test'), 'exclude': lambda f: f is None }})
    r"""Indicates whether the object has been created in test mode."""
    


Latitude = Union[float, str]

Longitude = Union[float, str]
