class ContactPerson {
  constructor(opt) {
    this.userId = null;
    this.firstName = null;
    this.lastName = null;
    this.email = null;
    this.phoneNumber = null;

    if (opt) {
      this.fillObject(opt);
    }
  }

  fillObject(opt) {
    this.userId = opt.userId || null;
    this.firstName = opt.firstName || null;
    this.lastName = opt.lastName || null;
    this.email = opt.email || null;
    this.phoneNumber = opt.phoneNumber || null;
  }

  static schema() {
    return {
      $schema: 'http://json-schema.org/draft-04/schema#',
      id: 'contact-person.schema.json',
      type: 'object',
      additionalProperties: false,
      properties: {
        userId: { type: 'string' },
        firstName: { type: ['string', 'null'] },
        lastName: { type: ['string', 'null'] },
        email: { type: ['string', 'null'] },
        phoneNumber: { type: ['string', 'null'] },
      },
      required: Object.keys(this),
    };
  }
}

module.exports = ContactPerson;
