editHook method

Future<Hook> editHook(
  1. RepositorySlug slug,
  2. Hook hookToEdit, {
  3. String? configUrl,
  4. String? configContentType,
  5. String? configSecret,
  6. bool? configInsecureSsl,
  7. List<String>? events,
  8. List<String>? addEvents,
  9. List<String>? removeEvents,
  10. bool? active,
})

Edits a hook.

  • configUrl: The URL to which the payloads will be delivered.
  • configContentType: The media type used to serialize the payloads. Supported values include json and form. The default is form.
  • configSecret: If provided, the secret will be used as the key to generate the HMAC hex digest value in the X-Hub-Signature header.
  • configInsecureSsl: Determines whether the SSL certificate of the host for url will be verified when delivering payloads. We strongly recommend not setting this to true as you are subject to man-in-the-middle and other attacks.
  • events: Determines what events the hook is triggered for. This replaces the entire array of events. Default: 'push'.
  • addEvents: Determines a list of events to be added to the list of events that the Hook triggers for.
  • removeEvents: Determines a list of events to be removed from the list of events that the Hook triggers for.
  • active: Determines if notifications are sent when the webhook is triggered. Set to true to send notifications.

Leave blank the unedited fields. Returns the edited hook.

https://developer.github.com/v3/repos/hooks/#edit-a-hook

Implementation

Future<Hook> editHook(
  RepositorySlug slug,
  Hook hookToEdit, {
  String? configUrl,
  String? configContentType,
  String? configSecret,
  bool? configInsecureSsl,
  List<String>? events,
  List<String>? addEvents,
  List<String>? removeEvents,
  bool? active,
}) async {
  ArgumentError.checkNotNull(slug);
  ArgumentError.checkNotNull(hookToEdit);
  ArgumentError.checkNotNull(configUrl ?? hookToEdit.config!.url);
  if (configContentType != 'json' && configContentType != 'form') {
    throw ArgumentError.value(configContentType, 'configContentType');
  }
  return github.postJSON<Map<String, dynamic>, Hook>(
    '/repos/${slug.fullName}/hooks/${hookToEdit.id.toString()}',
    statusCode: StatusCodes.OK,
    convert: (i) => Hook.fromJson(i)..repoName = slug.fullName,
    body: GitHubJson.encode(createNonNullMap(<String, dynamic>{
      'active': active ?? hookToEdit.active,
      'events': events ?? hookToEdit.events,
      'add_events': addEvents,
      'remove_events': removeEvents,
      'config': <String, dynamic>{
        'url': configUrl ?? hookToEdit.config!.url,
        'content_type': configContentType ?? hookToEdit.config!.contentType,
        'secret': configSecret ?? hookToEdit.config!.secret,
        'insecure_ssl':
            configInsecureSsl == null || !configInsecureSsl ? '0' : '1',
      },
    })),
  );
}