subscribeWebhookWithHttpInfo method

Future<Response> subscribeWebhookWithHttpInfo(
  1. SubscriptionSubjectType subjectType,
  2. String subjectId, {
  3. CreateWebHookSubscription? createWebHookSubscription,
})

Create web-hook subscription TIER 4

This endpoitns is a part of Flight alert PUSH API currently powered by webhooks. If you are running your own web service, you can subscribe to flights by number or airport code. After that, your HTTP endpoint will be called (notified) whenever the flight information gets updated. Creates a web-hook subscription on a subject (e.g., flight alerts by number or by airport code). Returns information about created subscription. Subscription ID contained in it can be used to refresh or remove it. If subscription contains an expiration date-time, it will auto-expire automatically on this time. If you want to prevent expiration, use webhook/{subscriptionId}/refresh endpoint to refresh the subscription. Every time a subject gets updated, a HTTP request will be sent to the URL specified in url parameter. Request will be of a POST type and contain JSON-formatted FlightNotificationContract object containing subscription and flights information in the body (see example response for status code 199 of this endpoint documentation). All flight alerts / notifications are delivered in best-effort manner. They might be missing or delayed. If there was an error delivering a notification for any reason, there will be 2 more retries after 5 and 15 minutes (precise numbers might change). If subscribed to a specific flight or to flights operated in a specific airport: * Ensure that the flight is within the live updates / ADS-B data coverage. There is no sense in subscribing to a flight which operates in airports having poor or no live updates or ADS-B coverage: there simply will be no updates. To check if an airport is tracked and on which level, use /health/services/airports/{icao}/feeds endpoint. You can also use /health/services/feeds/{service}/airports to get the list of covered airports. Read more about coverage here: https://www.aerodatabox.com/data-coverage. * Notifications will cover updates for flights commencing from 6 hours ago up to 72 hours in future. * Among these, notifications will contain only those flight items which were actually updated this time.

Note: This method returns the HTTP Response.

Parameters:

  • SubscriptionSubjectType subjectType (required): Subject type

  • String subjectId (required): Subject ID. If subjectType is: * FlightByNumber, then this field must be a flight number (with or without spaces, IATA or ICAO, any case formats are acceptable, e.g. KL1395, Klm 1395); * FlightByAirportIcao, then this field must be a 4-character ICAO-code of the airport where flights are operated (e.g.: EHAM, KLAX, UUEE, etc.);

  • CreateWebHookSubscription createWebHookSubscription: Command containing parameters for web-hook subscription creation

Implementation

Future<Response> subscribeWebhookWithHttpInfo(
  SubscriptionSubjectType subjectType,
  String subjectId, {
  CreateWebHookSubscription? createWebHookSubscription,
}) async {
  // ignore: prefer_const_declarations
  final path = r'/subscriptions/webhook/{subjectType}/{subjectId}'
      .replaceAll('{subjectType}', subjectType.toString())
      .replaceAll('{subjectId}', subjectId);

  // ignore: prefer_final_locals
  Object? postBody = createWebHookSubscription;

  final queryParams = <QueryParam>[];
  final headerParams = <String, String>{};
  final formParams = <String, String>{};

  const contentTypes = <String>['application/json'];

  return apiClient.invokeAPI(
    path,
    'POST',
    queryParams,
    postBody,
    headerParams,
    formParams,
    contentTypes.isEmpty ? null : contentTypes.first,
  );
}