encode<V> static method

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

Implementation

static V encode<V>(
  BillingPortalConfiguration instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeBool(
    'active',
    instance.active,
  );
  if (instance.application != null) {
    BillingPortalConfigurationApplicationOrId.encode(
      instance.application!,
      container.nestedSingleValueContainer('application').encoder,
    );
  }
  PortalBusinessProfile.encode(
    instance.businessProfile,
    container.nestedSingleValueContainer('business_profile').encoder,
  );
  container.encodeDateTime(
    'created',
    instance.created,
  );
  if (instance.defaultReturnUrl != null) {
    container.encodeString(
      'default_return_url',
      instance.defaultReturnUrl!,
    );
  }
  PortalFeatures.encode(
    instance.features,
    container.nestedSingleValueContainer('features').encoder,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'is_default',
    instance.isDefault,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  PortalLoginPage.encode(
    instance.loginPage,
    container.nestedSingleValueContainer('login_page').encoder,
  );
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  container.encodeString(
    'object',
    'billing_portal.configuration',
  );
  container.encodeDateTime(
    'updated',
    instance.updated,
  );
  return container.value;
}