Invoice.deserialize constructor

Invoice.deserialize(
  1. BinaryReader reader
)

Deserialize.

Implementation

factory Invoice.deserialize(BinaryReader reader) {
  // Read [Invoice] fields.
  final flags = reader.readInt32();
  final test = (flags & 1) != 0;
  final nameRequested = (flags & 2) != 0;
  final phoneRequested = (flags & 4) != 0;
  final emailRequested = (flags & 8) != 0;
  final shippingAddressRequested = (flags & 16) != 0;
  final flexible = (flags & 32) != 0;
  final phoneToProvider = (flags & 64) != 0;
  final emailToProvider = (flags & 128) != 0;
  final recurring = (flags & 512) != 0;
  final currency = reader.readString();
  final prices = reader.readVectorObject<LabeledPriceBase>();
  final hasMaxTipAmountField = (flags & 256) != 0;
  final maxTipAmount = hasMaxTipAmountField ? reader.readInt64() : null;
  final hasSuggestedTipAmountsField = (flags & 256) != 0;
  final suggestedTipAmounts =
      hasSuggestedTipAmountsField ? reader.readVectorInt64() : null;
  final hasTermsUrlField = (flags & 1024) != 0;
  final termsUrl = hasTermsUrlField ? reader.readString() : null;

  // Construct [Invoice] object.
  final returnValue = Invoice(
    test: test,
    nameRequested: nameRequested,
    phoneRequested: phoneRequested,
    emailRequested: emailRequested,
    shippingAddressRequested: shippingAddressRequested,
    flexible: flexible,
    phoneToProvider: phoneToProvider,
    emailToProvider: emailToProvider,
    recurring: recurring,
    currency: currency,
    prices: prices,
    maxTipAmount: maxTipAmount,
    suggestedTipAmounts: suggestedTipAmounts,
    termsUrl: termsUrl,
  );

  // Now return the deserialized [Invoice].
  return returnValue;
}