encode<V> static method

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

Implementation

static V encode<V>(
  PromotionCodeRestrictions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.currencyOptions != null) {
    container.encodeMap(
      'currency_options',
      (container) => instance.currencyOptions!.forEach((
        key,
        value,
      ) =>
          PromotionCodeCurrencyOptionsValue.encode(
            value,
            container.nestedSingleValueContainer(key).encoder,
          )),
    );
  }
  if (instance.firstTimeTransaction != null) {
    container.encodeBool(
      'first_time_transaction',
      instance.firstTimeTransaction!,
    );
  }
  if (instance.minimumAmount != null) {
    container.encodeInt(
      'minimum_amount',
      instance.minimumAmount!,
    );
  }
  if (instance.minimumAmountCurrency != null) {
    container.encodeString(
      'minimum_amount_currency',
      instance.minimumAmountCurrency!,
    );
  }
  return container.value;
}