encode<V> static method

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

Implementation

static V encode<V>(
  ClimateOrder instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount_fees',
    instance.amountFees,
  );
  container.encodeInt(
    'amount_subtotal',
    instance.amountSubtotal,
  );
  container.encodeInt(
    'amount_total',
    instance.amountTotal,
  );
  if (instance.beneficiary != null) {
    ClimateRemovalsBeneficiary.encode(
      instance.beneficiary!,
      container.nestedSingleValueContainer('beneficiary').encoder,
    );
  }
  if (instance.canceledAt != null) {
    container.encodeDateTime(
      'canceled_at',
      instance.canceledAt!,
    );
  }
  if (instance.cancellationReason != null) {
    container.encodeString(
      'cancellation_reason',
      instance.cancellationReason!,
    );
  }
  if (instance.certificate != null) {
    container.encodeString(
      'certificate',
      instance.certificate!,
    );
  }
  if (instance.confirmedAt != null) {
    container.encodeDateTime(
      'confirmed_at',
      instance.confirmedAt!,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.delayedAt != null) {
    container.encodeDateTime(
      'delayed_at',
      instance.delayedAt!,
    );
  }
  if (instance.deliveredAt != null) {
    container.encodeDateTime(
      'delivered_at',
      instance.deliveredAt!,
    );
  }
  container.encodeList(
    'delivery_details',
    (container) => instance.deliveryDetails
        .forEach((el) => ClimateRemovalsOrderDeliveries.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  container.encodeInt(
    'expected_delivery_year',
    instance.expectedDeliveryYear,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeMap(
    'metadata',
    (container) => instance.metadata.forEach((
      key,
      value,
    ) =>
        container.encodeString(
          key,
          value,
        )),
  );
  container.encodeString(
    'metric_tons',
    instance.metricTons,
  );
  container.encodeString(
    'object',
    'climate.order',
  );
  ClimateProductOrId.encode(
    instance.product,
    container.nestedSingleValueContainer('product').encoder,
  );
  if (instance.productSubstitutedAt != null) {
    container.encodeDateTime(
      'product_substituted_at',
      instance.productSubstitutedAt!,
    );
  }
  container.encodeString(
    'status',
    instance.status,
  );
  return container.value;
}