in partnercenter/azext_partnercenter/clients/offer_client.py [0:0]
def get_listing(self, offer_external_id):
offer = self.get(offer_external_id)
if offer is None:
return None
branch_listings = get_combined_paged_results(lambda: self._sdk.branches_client.products_product_id_branches_get_by_module_modulemodule_get(
offer.resource.durable_id, "Listing", self._api_client.configuration.access_token))
# TODO: circle back on this as not sure what to do when multiple offer listings exist
current_draft_module = next((b for b in branch_listings if not hasattr(b, 'variant_id')), None)
if current_draft_module is None:
return None
instance_id = current_draft_module.current_draft_instance_id
listings = get_combined_paged_results(
lambda: self._sdk.listing_client.products_product_id_listings_get_by_instance_id_instance_i_dinstance_id_get(
offer.resource.durable_id, instance_id, self._get_access_token()))
# TODO: there should only be 1 active listing (that we can confirm as of now)
if len(listings) == 0:
return None
listing = listings[0]
return Listing(
title=listing.title if hasattr(listing, 'title') else '',
summary=listing.summary if hasattr(listing, 'summary') else '',
description=listing.description if hasattr(listing, 'description') else '',
language_code=listing.language_code if hasattr(listing, 'language_code') else '',
short_description=listing.short_description if hasattr(listing, 'short_description') else '',
getting_started_instructions=listing.getting_started_instructions if hasattr(listing, 'getting_started_instructions') else '',
# keywords=listing.keywords,
offer_id=offer_external_id,
odata_etag=listing.odata_etag,
contacts=list(map(lambda c: ListingContact(**c.to_dict()), listing.listing_contacts)),
uris=list(map(lambda c: ListingUri(**c.to_dict()), listing.listing_uris)),
resource=Resource(durable_id=listing.id, type=listing.resource_type)
)