encode<V> static method

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

Implementation

static V encode<V>(
  CardSpendingControls instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.allowedCategories != null) {
    container.encodeList(
      'allowed_categories',
      (container) => instance.allowedCategories!.forEach((el) =>
          IssuingCardholderSpendingControlsAllowedCategoriesItem.encode(
            el,
            container.nestedSingleValueContainer().encoder,
          )),
    );
  }
  if (instance.blockedCategories != null) {
    container.encodeList(
      'blocked_categories',
      (container) => instance.blockedCategories!.forEach((el) =>
          IssuingCardholderSpendingControlsAllowedCategoriesItem.encode(
            el,
            container.nestedSingleValueContainer().encoder,
          )),
    );
  }
  if (instance.spendingLimits != null) {
    container.encodeList(
      'spending_limits',
      (container) => instance.spendingLimits!
          .forEach((el) => CardholderSpendingLimitsItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  return container.value;
}