encode<V> static method

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

Implementation

static V encode<V>(
  Person instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.account != null) {
    container.encodeString(
      'account',
      instance.account!,
    );
  }
  if (instance.additionalTosAcceptances != null) {
    PersonAdditionalTosAcceptances.encode(
      instance.additionalTosAcceptances!,
      container
          .nestedSingleValueContainer('additional_tos_acceptances')
          .encoder,
    );
  }
  if (instance.address != null) {
    Address.encode(
      instance.address!,
      container.nestedSingleValueContainer('address').encoder,
    );
  }
  if (instance.addressKana != null) {
    LegalEntityJapanAddress.encode(
      instance.addressKana!,
      container.nestedSingleValueContainer('address_kana').encoder,
    );
  }
  if (instance.addressKanji != null) {
    LegalEntityJapanAddress.encode(
      instance.addressKanji!,
      container.nestedSingleValueContainer('address_kanji').encoder,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  if (instance.dob != null) {
    LegalEntityDob.encode(
      instance.dob!,
      container.nestedSingleValueContainer('dob').encoder,
    );
  }
  if (instance.email != null) {
    container.encodeString(
      'email',
      instance.email!,
    );
  }
  if (instance.firstName != null) {
    container.encodeString(
      'first_name',
      instance.firstName!,
    );
  }
  if (instance.firstNameKana != null) {
    container.encodeString(
      'first_name_kana',
      instance.firstNameKana!,
    );
  }
  if (instance.firstNameKanji != null) {
    container.encodeString(
      'first_name_kanji',
      instance.firstNameKanji!,
    );
  }
  if (instance.fullNameAliases != null) {
    container.encodeList(
      'full_name_aliases',
      (container) => instance.fullNameAliases!
          .forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.futureRequirements != null) {
    PersonFutureRequirements.encode(
      instance.futureRequirements!,
      container.nestedSingleValueContainer('future_requirements').encoder,
    );
  }
  if (instance.gender != null) {
    container.encodeString(
      'gender',
      instance.gender!,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.idNumberProvided != null) {
    container.encodeBool(
      'id_number_provided',
      instance.idNumberProvided!,
    );
  }
  if (instance.idNumberSecondaryProvided != null) {
    container.encodeBool(
      'id_number_secondary_provided',
      instance.idNumberSecondaryProvided!,
    );
  }
  if (instance.lastName != null) {
    container.encodeString(
      'last_name',
      instance.lastName!,
    );
  }
  if (instance.lastNameKana != null) {
    container.encodeString(
      'last_name_kana',
      instance.lastNameKana!,
    );
  }
  if (instance.lastNameKanji != null) {
    container.encodeString(
      'last_name_kanji',
      instance.lastNameKanji!,
    );
  }
  if (instance.maidenName != null) {
    container.encodeString(
      'maiden_name',
      instance.maidenName!,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.nationality != null) {
    container.encodeString(
      'nationality',
      instance.nationality!,
    );
  }
  container.encodeString(
    'object',
    'person',
  );
  if (instance.phone != null) {
    container.encodeString(
      'phone',
      instance.phone!,
    );
  }
  if (instance.politicalExposure != null) {
    container.encodeString(
      'political_exposure',
      instance.politicalExposure!,
    );
  }
  if (instance.registeredAddress != null) {
    Address.encode(
      instance.registeredAddress!,
      container.nestedSingleValueContainer('registered_address').encoder,
    );
  }
  if (instance.relationship != null) {
    PersonRelationship.encode(
      instance.relationship!,
      container.nestedSingleValueContainer('relationship').encoder,
    );
  }
  if (instance.requirements != null) {
    PersonFutureRequirements.encode(
      instance.requirements!,
      container.nestedSingleValueContainer('requirements').encoder,
    );
  }
  if (instance.ssnLast4Provided != null) {
    container.encodeBool(
      'ssn_last_4_provided',
      instance.ssnLast4Provided!,
    );
  }
  if (instance.verification != null) {
    LegalEntityPersonVerification.encode(
      instance.verification!,
      container.nestedSingleValueContainer('verification').encoder,
    );
  }
  return container.value;
}