def _get_team_json(self) -> Tuple: """Get team info from JSON api. :returns: JSON values for fundraising goal, Captain's name, total value of donations, and the # of donations. """ team_json = donor_drive_comms.get_json(self.team_url) if team_json: return team_json.get("fundraisingGoal"), team_json.get("captainDisplayName"), \ team_json.get("sumDonations"), team_json.get("numDonations"), team_json.get("avatarImageURL") team_log.warning("[bold magenta]Could not get team JSON[/bold magenta]") return self.team_goal, self.team_captain, self.total_raised, self.num_donations, self.team_avatar_image
def _get_participants(self, top5: bool) -> List[TeamParticipant]: """Get team participant info from api. Passes the JSON to the TeamParticipant class for parsing to create a team participant. :param top5: If true, get the list sorted by top sum of donations. :returns: A list of TeamParticipant objects. """ team_participant_json = donor_drive_comms.get_json(self.team_participant_url, top5) if team_participant_json: return [TeamParticipant(participant) for participant in team_participant_json] team_log.warning("[bold magenta]Couldn't get to URL or possibly no participants.[/bold magenta]") if top5: return self._top_5_participant_list else: return self._participant_list
def _get_participant_info(self): """Get JSON data for participant information. :returns: JSON data for self.total_raised, self.number_of_donations, and self.goal. """ participant_json = donor_drive_comms.get_json(self.participant_url) if not participant_json: participant_log.warning("[bold red]Couldn't access participant JSON.[/bold red]") return self.total_raised, self.number_of_donations, self.goal, self.avatar_image_url, self.event_name, \ self.donation_link_url, self.stream_url, self.extra_life_page_url, self.created_date_utc,\ self.stream_is_live, self.sum_pledges, self.team_name, self.is_team_captain, self.display_name else: if self.my_team: team_name = participant_json.get('teamName') is_team_captain = participant_json.get('isTeamCaptain') else: team_name = '' is_team_captain = False return participant_json.get('sumDonations'), participant_json.get('numDonations'), \ participant_json.get('fundraisingGoal'), participant_json.get('avatarImageURL'), \ participant_json.get('eventName'), participant_json.get('links').get("donate"), \ participant_json.get('links').get('stream'), participant_json.get('links').get('page'), \ participant_json.get('createdDateUTC'), participant_json.get("streamIsLive"), \ participant_json.get('sumPledges'), team_name, is_team_captain, participant_json.get('displayName')
def _update_activities(self) -> None: """Add Participant Activities to list""" json_response = donor_drive_comms.get_json(self._activity_url) print(json_response) self._activities = [activity.create_activity(item) for item in json_response]
def _update_incentives(self) -> None: """Add all incentives to list""" json_response = donor_drive_comms.get_json(self.incentive_url) self._incentives = [Incentive.create_incentive(incentive) for incentive in json_response]
def _update_milestones(self) -> None: """Add all milestones to the list""" json_response = donor_drive_comms.get_json(self.milestone_url) self._milestones = [Milestone.create_milestone(milestone_item) for milestone_item in json_response]