def get_despatch_methods(self): """Retrieves despatch method information for this Performance. Returns the list of DespatchMethod objects, called internally by some methods, it calls the 'despatch_options' API method. The 'despatch_methods' property should be used to get this information, but this method can be called explicitly if required. Returns: list: List of DespatchMethod objects """ crypto_block = self._get_date_time_options_crypto() resp_dict = self.get_core_api().despatch_options( crypto_block=crypto_block, upfront_data_token=self.settings['upfront_data_token'], perf_token=self._perf_token, usage_date=date_to_yyyymmdd_or_none(self.usage_date), departure_date=date_to_yyyymmdd_or_none(self.departure_date), self_print_mode='html' ) despatch_methods = [] for dm in resp_dict['despatch_options']['despatch_method']: despatch_method = availability.DespatchMethod( despatch_id=dm.despatch_token, core_despatch_method=dm, core_currency=resp_dict.get('currency', None), **self._internal_settings() ) despatch_methods.append(despatch_method) self.despatch_methods = despatch_methods self._core_performance = resp_dict.get('performance') event = None if 'event' in resp_dict: event = event_objs.Event( event_id=resp_dict['event'].event_id, core_event=resp_dict['event'], **self._internal_settings() ) self.event = event return despatch_methods
def valid_ticket_quantities(self): """List of valid ticket quantities for this Performance.""" if self._valid_ticket_quantities is None: crypto_block = self._get_date_time_options_crypto() resp_dict = self.get_core_api().availability_options( crypto_block=crypto_block, upfront_data_token=self.settings['upfront_data_token'], perf_token=self._perf_token, usage_date=date_to_yyyymmdd_or_none(self.usage_date), departure_date=date_to_yyyymmdd_or_none(self.departure_date), quantity_options_only=True ) self._set_ticket_quantities_from_dict( resp_dict.get('quantity_options', None) ) return self._valid_ticket_quantities
def get_performances(self, earliest_date=None, latest_date=None, **kwargs): """Retrieves the Performances for this Event. Returns the list of Performances for the Event, called internally by several other methods, it calls the 'date_time_options' API method. The 'performances' property should be used to get this information unless a specific date range is required. Args: earliest_date (datetime.date): restrict the list of Performances to be later than this date. latest_date (datetime.date): restrict the list of Performances to be earlier than this date. Returns: list: List of Performance objects """ crypto_block = self._get_search_crypto() resp_dict = self.get_core_api().date_time_options( crypto_block=crypto_block, upfront_data_token=self.settings['upfront_data_token'], event_token=self.event_id, earliest_date=date_to_yyyymmdd_or_none(earliest_date), latest_date=date_to_yyyymmdd_or_none(latest_date), request_cost_range=True, **kwargs ) performances = [] self.need_departure_date = resolve_boolean( resp_dict['need_departure_date'] ) if 'using_perf_list' in resp_dict: self.perfs_have_required_info = resolve_boolean( resp_dict['has_perf_names'] ) self.perfs_have_usage_date = False self.has_single_false_perf = False for p in resp_dict['using_perf_list']['performances']: if self.need_departure_date: departure_date = p.date else: departure_date = None performances.append( perf_objs.Performance.from_event_and_perf_token( event=self, perf_token=p.perf_token, core_performance=p, departure_date=departure_date, **self._internal_settings() ) ) elif 'using_usage_date' in resp_dict: self.perfs_have_usage_date = True self.has_single_false_perf = False self.perfs_have_required_info = False performances = self._build_performances_from_usage( usage_date_dict=resp_dict['using_usage_date'], need_departure_date=self.need_departure_date, latest_date=latest_date ) else: self.perfs_have_usage_date = False self.has_single_false_perf = True self.perfs_have_required_info = False performances.append(perf_objs.Performance.from_event_only( event=self, **self._internal_settings() )) self.performances = performances self._set_crypto_for_object( crypto_block=resp_dict['crypto_block'], method_name='date_time_options', interface_object=self ) return performances
def get_availability( self, include_possible_concessions=None, no_of_tickets=None, include_available_seat_blocks=None, include_user_commission=None, ): """Retrieves ticket availability information for this Performance. Returns the list of TicketType objects, called internally by several methods, it calls the 'availability_options' API method. The 'ticket_types' property should be used to get this information, but this method can be called explicitly if required. Args: include_possible_concessions (boolean): Optional, flag to indicate whether to request possible_concession information. no_of_tickets (int): Optional, set the number of tickets to request, allows actual seats to be returned if possible. include_available_seat_blocks (boolean): Optional, flag to indicate whether to request the available seat blocks, allowing specific seats to be selected. include_user_commission (boolean): Optional, flag to indicate whether to request the user's commission information. Returns: list: List of TicketType objects """ crypto_block = self._get_date_time_options_crypto() resp_dict = self.get_core_api().availability_options( crypto_block=crypto_block, upfront_data_token=self.settings['upfront_data_token'], perf_token=self._perf_token, usage_date=date_to_yyyymmdd_or_none(self.usage_date), departure_date=date_to_yyyymmdd_or_none(self.departure_date), self_print_mode='html', add_discounts=include_possible_concessions, no_of_tickets=no_of_tickets, add_free_seat_blocks=include_available_seat_blocks, add_user_commission=include_user_commission ) self._set_crypto_block( crypto_block=resp_dict['crypto_block'], method_name='availability_options' ) ticket_types = [] if 'ticket_type' in resp_dict: for tt in resp_dict['ticket_type']: for pb in tt.price_bands: ticket_type = availability.TicketType( ticket_type_id=pb.band_token, core_ticket_type=tt, core_price_band=pb, core_currency=resp_dict.get('currency', None), **self._internal_settings() ) ticket_type.set_valid_quantities( valid_quantities=resp_dict['quantity_options'][ 'valid_quantity' ] ) ticket_types.append(ticket_type) self.ticket_types = ticket_types self._set_crypto_for_objects( crypto_block=resp_dict['crypto_block'], method_name='availability_options', interface_objects=ticket_types ) self._set_ticket_quantities_from_dict( resp_dict.get('quantity_options', None) ) despatch_methods = [] if 'despatch_options' in resp_dict: for dm in resp_dict['despatch_options']['despatch_method']: despatch_method = availability.DespatchMethod( despatch_id=dm.despatch_token, core_despatch_method=dm, core_currency=resp_dict.get('currency', None), **self._internal_settings() ) despatch_methods.append(despatch_method) self.despatch_methods = despatch_methods self._core_performance = resp_dict.get('performance') if 'event' in resp_dict: event = event_objs.Event( event_id=resp_dict['event'].event_id, core_event=resp_dict['event'], **self._internal_settings() ) self.event = event return ticket_types