encode<V> static method

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

Implementation

static V encode<V>(
  ProductCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.active != null) {
    container.encodeBool(
      'active',
      instance.active!,
    );
  }
  if (instance.defaultPriceData != null) {
    ProductDefaultPriceData.encode(
      instance.defaultPriceData!,
      container.nestedSingleValueContainer('default_price_data').encoder,
    );
  }
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.features != null) {
    container.encodeList(
      'features',
      (container) =>
          instance.features!.forEach((el) => ProductFeaturesItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.id != null) {
    container.encodeString(
      'id',
      instance.id!,
    );
  }
  if (instance.images != null) {
    container.encodeList(
      'images',
      (container) =>
          instance.images!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  container.encodeString(
    'name',
    instance.name,
  );
  if (instance.packageDimensions != null) {
    PackageDimensions.encode(
      instance.packageDimensions!,
      container.nestedSingleValueContainer('package_dimensions').encoder,
    );
  }
  if (instance.shippable != null) {
    container.encodeBool(
      'shippable',
      instance.shippable!,
    );
  }
  if (instance.statementDescriptor != null) {
    container.encodeString(
      'statement_descriptor',
      instance.statementDescriptor!,
    );
  }
  if (instance.taxCode != null) {
    container.encodeString(
      'tax_code',
      instance.taxCode!,
    );
  }
  if (instance.type != null) {
    ProductType.encode(
      instance.type!,
      container.nestedSingleValueContainer('type').encoder,
    );
  }
  if (instance.unitLabel != null) {
    container.encodeString(
      'unit_label',
      instance.unitLabel!,
    );
  }
  if (instance.url != null) {
    container.encodeString(
      'url',
      instance.url!,
    );
  }
  return container.value;
}