def _find_accounts(self) -> List[Mapping[str, Any]]: try: instagram_business_accounts = [] accounts = fb_user.User(fbid="me").get_accounts() for account in accounts: page = Page(account.get_id()).api_get( fields=["instagram_business_account"]) if page.get("instagram_business_account"): instagram_business_accounts.append({ "page_id": account.get_id(), "instagram_business_account": IGUser( page.get("instagram_business_account").get("id")), }) except FacebookRequestError as exc: raise InstagramAPIException( f"Error: {exc.api_error_code()}, {exc.api_error_message()}" ) from exc if not instagram_business_accounts: raise InstagramAPIException( "Couldn't find an Instagram business account for current Access Token" ) return instagram_business_accounts
def _get_stories(self, instagram_user: IGUser, params: dict, fields: Sequence[str] = None) -> Iterator[Any]: """ This is necessary because the functions that call this endpoint return a generator, whose calls need decorated with a backoff. """ return instagram_user.get_stories(params=params, fields=fields)
def _get_instagram_user(self, page: Page) -> IGUser: return IGUser(page.get("instagram_business_account").get("id"))
def _get_insight_records(self, instagram_user: IGUser, params: dict = None) -> List: return instagram_user.get_insights(params=params)._queue
def _get_insight_records(self, instagram_user: IGUser, params: dict = None) -> Iterator[Any]: return instagram_user.get_insights(params=params)
def _extend_record(self, ig_user: IGUser, fields: Sequence[str] = None) -> Dict: return ig_user.api_get(fields=fields).export_all_data()