searchSubscription method

Future<TicketResponse> searchSubscription({
  1. required String subscriptionNumber,
  2. required String name,
})

searches for a subscription

The provided name is the last name of the passenger The provided subscriptionNumber is the order number issued by the carrier

Implementation

Future<TicketResponse> searchSubscription({
  required String subscriptionNumber,
  required String name,
}) async {
  final response = await client.get(
    prodApi.resolveUri(
      Uri(
        path: '/aboticket',
        queryParameters: {
          // subscription number
          'abonummer': subscriptionNumber,
          // last name
          'nachname': name,
        },
      ),
    ),
    headers: _makeHeaders(),
  );
  switch (response.statusCode) {
    case 404:
      throw SubscriptionNotFoundError();
    case 401:
      throw SubscriptionAlreadyClaimedError();
    case 200:
      return TicketResponse.fromJson(jsonDecode(response.body));
    default:
      throw ApiHttpError(response.statusCode);
  }
}