Skip to content

Standalone MediaClient queries

MediaClient remains exported from wfrmls, but WFRMLSClient has no media attribute. Instantiate the class directly to use this compatibility interface. Its methods and mocked tests establish request construction; current provider availability and account permissions have not been verified.

Construct the client and query a page

MediaClient(bearer_token=None, base_url=None) resolves an explicit token or WFRMLS_BEARER_TOKEN immediately. Missing credentials raise AuthenticationError. See BaseClient for HTTP handling and the default service root.

get_media(top=None, skip=None, filter_query=None, select=None, orderby=None, expand=None, count=None) requests one Media page:

Parameter Type Default Request behavior
top int \| None None $top; values above 200 are clamped
skip int \| None None $skip, unchanged
filter_query str \| None None Raw $filter expression
select list[str] \| str \| None None $select; lists are joined with commas
orderby str \| None None Raw $orderby expression
expand list[str] \| str \| None None $expand; lists are joined with commas
count bool \| None None $count as lowercase true or false

None omits a parameter. The response is handled provider JSON, commonly a dictionary with value. This method does not paginate, validate field names, or download files.

This complete example uses a fake token and a mock, so it makes no provider request:

from unittest.mock import patch
from wfrmls import MediaClient

with patch.object(MediaClient, "get", return_value={"value": []}) as request:
    media = MediaClient(bearer_token="example-token")
    response = media.get_photos_for_property("12345", top=5)
    assert response == {"value": []}
    request.assert_called_once_with(
        "Media",
        params={
            "$top": 5,
            "$filter": "ResourceRecordKeyNumeric eq 12345 and MediaType eq 'Photo'",
        },
    )

Property filters and extraction helpers

Method Parameters Result or request behavior
get_media_item media_key: str Requests Media('<key>'); returns provider JSON without single-record normalization
get_media_for_property listing_key: str \| int, **kwargs Filters unquoted ResourceRecordKeyNumeric
get_photos_for_property listing_key: str \| int, **kwargs Adds MediaType eq 'Photo'
get_media_by_category listing_key: str \| int, category: str, **kwargs Adds a quoted MediaCategory condition
get_primary_photo listing_key: str \| int Queries photos with Order eq 1, top=1; returns the first object or None
get_media_urls_for_property listing_key: str \| int, media_type=None Returns MediaURL values from one page of at most 200 records, requested in Order asc order
get_media_with_property **kwargs Sets $expand=Property
get_modified_media since: str \| date \| datetime, **kwargs Sets a quoted ModificationTimestamp gt '<cutoff>' filter

Use numeric strings or integers for property keys: the helpers interpolate them without quotes or numeric validation. Text keys, categories, and media types are inserted without escaping. The property/category helpers combine an existing filter_query using and without extra parentheses.

URL extraction skips records lacking a MediaURL key; it does not validate the values or fetch additional pages. MediaType and MediaCategory are package constants, not a current provider lookup list. Pass their .value strings where a helper expects text.

Timestamp and keyword limitations

For get_modified_media(), strings are sent unchanged; dates become midnight with Z; datetimes use isoformat() plus Z without timezone conversion. An aware datetime can therefore produce ...+00:00Z. Prefer an already-normalized UTC string and verify that the provider accepts the quoted filter.

Do not pass filter_query to get_modified_media() or expand to get_media_with_property(): those helpers supply the keyword themselves and duplicate keywords raise TypeError. Other **kwargs must match get_media().

For media through the facade, property media expansion requests $expand=Media; server acceptance still requires verification. See compatibility clients and provider verification.

Generated signatures and constants

Media client for WFRMLS API.

Classes

MediaCategory

Bases: Enum

Media category options.

MediaClient

MediaClient(bearer_token: Optional[str] = None, base_url: Optional[str] = None)

Bases: BaseClient

Standalone compatibility interface for Media request construction.

WFRMLSClient has no media attribute. This exported class requires credentials; its existence and mocked tests do not verify current provider availability.

Parameters:

Name Type Description Default
bearer_token Optional[str]

Explicit token, or None to use WFRMLS_BEARER_TOKEN.

None
base_url Optional[str]

OData service root, or None for the package default.

None

Raises:

Type Description
AuthenticationError

If neither an explicit nor environment token exists.

Methods:

get_media
get_media(
    top: Optional[int] = None,
    skip: Optional[int] = None,
    filter_query: Optional[str] = None,
    select: Optional[Union[List[str], str]] = None,
    orderby: Optional[str] = None,
    expand: Optional[Union[List[str], str]] = None,
    count: Optional[bool] = None,
) -> Dict[str, Any]

Request one Media collection page with named OData parameters.

Parameters:

Name Type Description Default
top Optional[int]

Optional $top; values above 200 are clamped to 200.

None
skip Optional[int]

Optional $skip offset, passed unchanged.

None
filter_query Optional[str]

Optional raw $filter expression.

None
select Optional[Union[List[str], str]]

Optional field list or comma-separated $select string.

None
orderby Optional[str]

Optional raw $orderby expression.

None
expand Optional[Union[List[str], str]]

Optional relationship list or comma-separated $expand string.

None
count Optional[bool]

Optional $count, converted to lowercase true or false.

None

Returns:

Type Description
Dict[str, Any]

Parsed JSON dictionary from one request, commonly containing value.

Dict[str, Any]

Counts, next links, and individual fields are server-provided and optional.

Raises:

Type Description
WFRMLSError

For shared HTTP or transport failures.

get_media_by_category
get_media_by_category(
    listing_key: Union[str, int], category: str, **kwargs: Any
) -> Dict[str, Any]

Query a numeric property key with an additional MediaCategory condition.

Parameters:

Name Type Description Default
listing_key Union[str, int]

Numeric string or integer, interpolated without quotes.

required
category str

Category text inserted without escaping into a quoted literal.

required
**kwargs Any

get_media parameters, including optional filter_query.

{}

Returns:

Type Description
Dict[str, Any]

Provider collection JSON; an existing filter is joined with and.

get_media_for_property
get_media_for_property(
    listing_key: Union[str, int], **kwargs: Any
) -> Dict[str, Any]

Query ResourceRecordKeyNumeric for one property.

Parameters:

Name Type Description Default
listing_key Union[str, int]

Numeric string or integer inserted without quotes.

required
**kwargs Any

get_media parameters, including optional filter_query.

{}

Returns:

Type Description
Dict[str, Any]

Provider collection JSON from one request; an existing filter is joined with and.

get_media_item
get_media_item(media_key: str) -> Dict[str, Any]

Request Media('') and return the handled provider JSON.

Parameters:

Name Type Description Default
media_key str

String key inserted without escaping into a quoted key path.

required

Returns:

Type Description
Dict[str, Any]

Parsed provider JSON; no single-record normalization is performed.

get_media_urls_for_property
get_media_urls_for_property(
    listing_key: Union[str, int], media_type: Optional[str] = None
) -> List[str]

Extract MediaURL strings from one page of at most 200 media records.

Parameters:

Name Type Description Default
listing_key Union[str, int]

Numeric property key inserted into ResourceRecordKeyNumeric.

required
media_type Optional[str]

Optional MediaType string, default None for all types.

None

Returns:

Type Description
List[str]

List of MediaURL values from a page requested in Order asc order;

List[str]

records missing that key are skipped. Values are not validated.

List[str]

This does not paginate or download media.

get_media_with_property
get_media_with_property(**kwargs: Any) -> Dict[str, Any]

Query Media with $expand=Property.

Parameters:

Name Type Description Default
**kwargs Any

get_media parameters, excluding expand.

{}

Returns:

Type Description
Dict[str, Any]

Provider collection JSON if the relationship is accepted by the server.

get_modified_media
get_modified_media(
    since: Union[str, date, datetime], **kwargs: Any
) -> Dict[str, Any]

Query ModificationTimestamp after a quoted cutoff.

Parameters:

Name Type Description Default
since Union[str, date, datetime]

String sent unchanged, date expanded to midnight Z, or datetime serialized with isoformat() plus Z without timezone conversion.

required
**kwargs Any

get_media parameters, excluding filter_query.

{}

Returns:

Type Description
Dict[str, Any]

Provider collection JSON. Prefer an already-normalized UTC string.

get_photos_for_property
get_photos_for_property(
    listing_key: Union[str, int], **kwargs: Any
) -> Dict[str, Any]

Query ResourceRecordKeyNumeric for one property and MediaType eq 'Photo'.

Parameters:

Name Type Description Default
listing_key Union[str, int]

Numeric string or integer inserted without quotes.

required
**kwargs Any

get_media parameters, including optional filter_query.

{}

Returns:

Type Description
Dict[str, Any]

Provider collection JSON from one request; an existing filter is joined with and.

get_primary_photo
get_primary_photo(listing_key: Union[str, int]) -> Optional[Dict[str, Any]]

Return the first photo with Order eq 1, or None if value is empty.

Parameters:

Name Type Description Default
listing_key Union[str, int]

Numeric property key inserted into ResourceRecordKeyNumeric.

required

Returns:

Type Description
Optional[Dict[str, Any]]

First object from the one-page photo response, or None.

MediaType

Bases: Enum

Media type options.