encode<V> static method

V encode<V>(
  1. WebhookEndpoint instance,
  2. Encoder<V> encoder
)

Implementation

static V encode<V>(
  WebhookEndpoint instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.apiVersion != null) {
    container.encodeString(
      'api_version',
      instance.apiVersion!,
    );
  }
  if (instance.application != null) {
    container.encodeString(
      'application',
      instance.application!,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  container.encodeList(
    'enabled_events',
    (container) =>
        instance.enabledEvents.forEach((el) => container.encodeString(el)),
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeMap(
    'metadata',
    (container) => instance.metadata.forEach((
      key,
      value,
    ) =>
        container.encodeString(
          key,
          value,
        )),
  );
  container.encodeString(
    'object',
    'webhook_endpoint',
  );
  if (instance.secret != null) {
    container.encodeString(
      'secret',
      instance.secret!,
    );
  }
  container.encodeString(
    'status',
    instance.status,
  );
  container.encodeString(
    'url',
    instance.url,
  );
  return container.value;
}