encode<V> static method

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

Implementation

static V encode<V>(
  CountrySpec instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeString(
    'default_currency',
    instance.defaultCurrency,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeString(
    'object',
    'country_spec',
  );
  container.encodeMap(
    'supported_bank_account_currencies',
    (container) => instance.supportedBankAccountCurrencies.forEach((
      key,
      value,
    ) =>
        container.encodeList(
          key,
          (container) => value.forEach((el) => container.encodeString(el)),
        )),
  );
  container.encodeList(
    'supported_payment_currencies',
    (container) => instance.supportedPaymentCurrencies
        .forEach((el) => container.encodeString(el)),
  );
  container.encodeList(
    'supported_payment_methods',
    (container) => instance.supportedPaymentMethods
        .forEach((el) => container.encodeString(el)),
  );
  container.encodeList(
    'supported_transfer_countries',
    (container) => instance.supportedTransferCountries
        .forEach((el) => container.encodeString(el)),
  );
  CountrySpecVerificationFields.encode(
    instance.verificationFields,
    container.nestedSingleValueContainer('verification_fields').encoder,
  );
  return container.value;
}