def create_update_response( imsi, charging_key, total_quota, is_final=False, success=True, ): """ Create a CreditUpdateResponse with some useful defaults Args: imsi (string): subscriber id charging_key (int): rating group quota (int): number of bytes to return is_final (bool): True if these are the last credits to return success (bool): True if the update was successful """ return CreditUpdateResponse( success=success, sid=imsi, charging_key=charging_key, credit=ChargingCredit( granted_units=GrantedUnits(total=CreditUnit(is_valid=True, volume=total_quota), ), is_final=is_final, ), )
def _get_max_charging_credit(self) -> ChargingCredit: return ChargingCredit( type=ChargingCredit.UnitType.Value('SECONDS'), validity_time=86400, # One day is_final=False, final_action=ChargingCredit.FinalAction.Value('TERMINATE'), granted_units=self._get_max_granted_units(), )