encode<V> static method

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

Implementation

static V encode<V>(
  Event instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.account != null) {
    container.encodeString(
      'account',
      instance.account!,
    );
  }
  if (instance.apiVersion != null) {
    container.encodeString(
      'api_version',
      instance.apiVersion!,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  NotificationEventData.encode(
    instance.data,
    container.nestedSingleValueContainer('data').encoder,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeString(
    'object',
    'event',
  );
  container.encodeInt(
    'pending_webhooks',
    instance.pendingWebhooks,
  );
  if (instance.request != null) {
    EventRequest.encode(
      instance.request!,
      container.nestedSingleValueContainer('request').encoder,
    );
  }
  container.encodeString(
    'type',
    instance.type,
  );
  return container.value;
}