encode<V> static method

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

Implementation

static V encode<V>(
  Discount instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.checkoutSession != null) {
    container.encodeString(
      'checkout_session',
      instance.checkoutSession!,
    );
  }
  Coupon.encode(
    instance.coupon,
    container.nestedSingleValueContainer('coupon').encoder,
  );
  if (instance.customer != null) {
    BankAccountCustomerOrId.encode(
      instance.customer!,
      container.nestedSingleValueContainer('customer').encoder,
    );
  }
  if (instance.end != null) {
    container.encodeDateTime(
      'end',
      instance.end!,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.invoice != null) {
    container.encodeString(
      'invoice',
      instance.invoice!,
    );
  }
  if (instance.invoiceItem != null) {
    container.encodeString(
      'invoice_item',
      instance.invoiceItem!,
    );
  }
  container.encodeString(
    'object',
    'discount',
  );
  if (instance.promotionCode != null) {
    PromotionCodeOrId.encode(
      instance.promotionCode!,
      container.nestedSingleValueContainer('promotion_code').encoder,
    );
  }
  container.encodeDateTime(
    'start',
    instance.start,
  );
  if (instance.subscription != null) {
    container.encodeString(
      'subscription',
      instance.subscription!,
    );
  }
  return container.value;
}