🔍 Code Extractor

class PhysicalAddress

Maturity: 46

A data class representing the physical address of a contact with fields for city, country/region, postal code, state, and street.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/physical_address.py
Lines:
9 - 33
Complexity:
simple

Purpose

PhysicalAddress is a value object that encapsulates physical address information for contacts in the Office 365 API. It inherits from ClientValue, making it serializable for API communication. This class is used to represent and transfer address data when working with contact information in Microsoft Graph or Office 365 services. All fields are optional, allowing for partial address information.

Source Code

class PhysicalAddress(ClientValue):
    """The physical address of a contact."""

    def __init__(
        self,
        city=None,
        country_or_region=None,
        postal_code=None,
        state=None,
        street=None,
    ):
        # type: (Optional[str], Optional[str], Optional[str], Optional[str], Optional[str]) -> None
        """
        :param city: The city.
        :param country_or_region: The country or region. It's a free-format string value, for example, "United States".
        :param postal_code: The postal code.
        :param state:
        :param street:
        """
        super(PhysicalAddress, self).__init__()
        self.city = city
        self.countryOrRegion = country_or_region
        self.postalCode = postal_code
        self.state = state
        self.street = street

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

city: The city name of the physical address. Optional string value. Can be None if city information is not available.

country_or_region: The country or region name as a free-format string (e.g., 'United States', 'Canada'). Optional string value. Can be None if country/region information is not available.

postal_code: The postal code or ZIP code of the address. Optional string value. Can be None if postal code is not available.

state: The state or province of the address. Optional string value. Can be None if state information is not available.

street: The street address including street number and name. Optional string value. Can be None if street information is not available.

Return Value

Instantiation returns a PhysicalAddress object with all provided address components stored as instance attributes. The class does not define any methods that return values beyond the inherited ClientValue methods. The object can be serialized for API communication through its parent class.

Class Interface

Methods

__init__(self, city=None, country_or_region=None, postal_code=None, state=None, street=None) -> None

Purpose: Initializes a new PhysicalAddress instance with optional address components

Parameters:

  • city: Optional string for the city name
  • country_or_region: Optional string for the country or region name
  • postal_code: Optional string for the postal/ZIP code
  • state: Optional string for the state or province
  • street: Optional string for the street address

Returns: None - constructor initializes the instance

Attributes

Name Type Description Scope
city Optional[str] The city component of the physical address instance
countryOrRegion Optional[str] The country or region component of the physical address in camelCase format for API compatibility instance
postalCode Optional[str] The postal code or ZIP code component of the physical address in camelCase format for API compatibility instance
state Optional[str] The state or province component of the physical address instance
street Optional[str] The street address component including street number and name instance

Dependencies

  • office365
  • typing

Required Imports

from office365.runtime.client_value import ClientValue
from typing import Optional

Usage Example

from office365.runtime.client_value import ClientValue
from typing import Optional

class PhysicalAddress(ClientValue):
    def __init__(self, city=None, country_or_region=None, postal_code=None, state=None, street=None):
        super(PhysicalAddress, self).__init__()
        self.city = city
        self.countryOrRegion = country_or_region
        self.postalCode = postal_code
        self.state = state
        self.street = street

# Create a complete address
address = PhysicalAddress(
    city='Seattle',
    country_or_region='United States',
    postal_code='98101',
    state='Washington',
    street='123 Main Street'
)

# Create a partial address with only some fields
partial_address = PhysicalAddress(
    city='New York',
    country_or_region='United States'
)

# Access address components
print(address.city)  # Output: Seattle
print(address.countryOrRegion)  # Output: United States
print(address.postalCode)  # Output: 98101

Best Practices

  • All address fields are optional, so always check for None values before using them in string operations or display logic.
  • Note the naming convention: constructor parameters use snake_case (country_or_region) but instance attributes use camelCase (countryOrRegion) to match Office 365 API conventions.
  • This class is immutable by convention - set all values during instantiation rather than modifying them later.
  • The class inherits from ClientValue, which provides serialization capabilities for Office 365 API communication. Do not override serialization methods unless necessary.
  • When creating address objects for API requests, ensure the data format matches the expected Office 365/Microsoft Graph API schema.
  • Use this class as a data transfer object (DTO) - it has no business logic, only data storage.
  • The free-format nature of country_or_region means validation should be performed at a higher level if needed.

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class EmailAddress 70.6% similar

    A data class representing an email address with an associated display name, inheriting from ClientValue for use in Office 365 API operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/email_address.py
  • class Place 61.3% similar

    Represents a physical location with basic attributes including name, address, and phone number. Serves as a base class for more specialized location types like rooms and room lists.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/place.py
  • class OutlookGeoCoordinates 59.7% similar

    A data class representing geographic coordinates, elevation, and their accuracy for a physical location in Microsoft Outlook/Office 365 context.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/geo_coordinates.py
  • class Location 56.5% similar

    Represents location information for calendar events in Microsoft Outlook/Office 365, supporting various location types including physical addresses, coordinates, and email-based locations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/location.py
  • class Recipient 55.8% similar

    A class representing information about a user in the sending or receiving end of an event, message or group post in Microsoft Office 365 Outlook.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/recipient.py
← Back to Browse