poserver
Version:
Server for JD Bot
67 lines (58 loc) • 3.21 kB
JavaScript
/**
* Created by tomdaley on 10/9/16.
*/
"use strict";
var ParsedAddress = function (addressObject)
{
addressObject = addressObject || {};
this.__type = "ParsedAddress";
if (addressObject.hasOwnProperty("city")) this.city = addressObject.city;
if (addressObject.hasOwnProperty("country")) this.country = addressObject.country;
if (addressObject.hasOwnProperty("countryCode")) this.countryCode = addressObject.countryCode;
if (addressObject.hasOwnProperty("county")) this.county = addressObject.county;
if (addressObject.hasOwnProperty("csz")) this.csz = addressObject.csz;
if (addressObject.hasOwnProperty("fullAddress")) this.fullAddress = addressObject.fullAddress;
if (addressObject.hasOwnProperty("neighborhood")) this.neighborhood = addressObject.neighborhood;
if (addressObject.hasOwnProperty("postalCode")) this.postalCode = addressObject.postalCode;
if (addressObject.hasOwnProperty("postalCodeSuffix")) this.postalCodeSuffix = addressObject.postalCodeSuffix;
if (addressObject.hasOwnProperty("state")) this.state = addressObject.state;
if (addressObject.hasOwnProperty("street")) this.street = addressObject.street;
if (addressObject.hasOwnProperty("street1")) this.street1 = addressObject.street1;
if (addressObject.hasOwnProperty("streetNumber")) this.street = addressObject.streetNumber;
if (addressObject.hasOwnProperty("unit")) this.unit = addressObject.unit;
if (addressObject.hasOwnProperty("userString")) this.userString = addressObject.userString;
};
ParsedAddress.prototype.hasCompleteCsz = function ()
{
return (this.hasOwnProperty("city") && this.hasOwnProperty("state") && this.hasOwnProperty("postalCode"));
};
ParsedAddress.prototype.hasCompleteStreet = function ()
{
return (this.hasOwnProperty("streetNumber") && this.hasOwnProperty("street"));
};
ParsedAddress.prototype.hasCompleteAddress = function ()
{
return (this.hasCompleteCsz && this.hasCompleteStreet);
};
ParsedAddress.prototype.toDocument = function ()
{
var doc = {};
doc.className = this.__type;
if (this.hasOwnProperty("city")) doc.city = this.city;
if (this.hasOwnProperty("country")) doc.country = this.country;
if (this.hasOwnProperty("countryCode")) doc.countryCode = this.countryCode;
if (this.hasOwnProperty("county")) doc.county = this.county;
if (this.hasOwnProperty("csz")) doc.csz = this.csz;
if (this.hasOwnProperty("fullAddress")) doc.fullAddress = this.fullAddress;
if (this.hasOwnProperty("neighborhood")) doc.neighborhood = this.neighborhood;
if (this.hasOwnProperty("postalCode")) doc.postalCode = this.postalCode;
if (this.hasOwnProperty("postalCodeSuffix")) doc.postalCodeSuffix = this.postalCodeSuffix;
if (this.hasOwnProperty("state")) doc.state = this.state;
if (this.hasOwnProperty("street")) doc.street = this.street;
if (this.hasOwnProperty("street1")) doc.street1 = this.street1;
if (this.hasOwnProperty("streetNumber")) doc.street = this.streetNumber;
if (this.hasOwnProperty("unit")) doc.unit = this.unit;
if (this.hasOwnProperty("userString")) doc.userString = this.userString;
return doc;
};
module.exports = ParsedAddress;