@atomixdesign/nodepay-ezidebit
Version:
Nodepay strategy for the Ezidebit payment gateway.
173 lines (172 loc) • 8.77 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomerDTO = void 0;
var class_validator_1 = require("class-validator");
var validation_1 = require("@atomixdesign/nodepay-core/build/validation");
var debug_1 = __importDefault(require("debug"));
var IsOptionalIfEmpty_1 = require("./IsOptionalIfEmpty");
var log = debug_1.default('nodepay:ezidebit');
/** @internal */
var CustomerDTO = /** @class */ (function () {
function CustomerDTO(customer) {
log("building " + this.constructor.name);
log({ customer: customer });
this.YourSystemReference = customer.YourSystemReference;
this.YourGeneralReference = customer.YourGeneralReference;
this.LastName = customer.LastName;
this.FirstName = customer.FirstName;
this.AddressLine1 = customer.AddressLine1;
this.AddressLine2 = customer.AddressLine2;
this.AddressSuburb = customer.AddressSuburb;
this.AddressState = customer.AddressState;
this.AddressPostCode = customer.AddressPostCode;
this.EmailAddress = customer.EmailAddress;
this.MobilePhoneNumber = customer.MobilePhoneNumber;
this.ContractStartDate = customer.ContractStartDate;
this.SmsPaymentReminder = customer.SmsPaymentReminder;
this.SmsFailedNotification = customer.SmsFailedNotification;
this.SmsExpiredCard = customer.SmsExpiredCard;
this.Username = customer.Username;
}
__decorate([
class_validator_1.MaxLength(50, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'YourSystemReference'),
}),
__metadata("design:type", String)
], CustomerDTO.prototype, "YourSystemReference", void 0);
__decorate([
class_validator_1.IsOptional(),
class_validator_1.MaxLength(50, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'YourGeneralReference'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "YourGeneralReference", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'LastName'),
}),
class_validator_1.MaxLength(60, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'LastName'),
}),
__metadata("design:type", String)
], CustomerDTO.prototype, "LastName", void 0);
__decorate([
IsOptionalIfEmpty_1.IsOptionalIfEmpty(),
class_validator_1.MaxLength(30, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'FirstName'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "FirstName", void 0);
__decorate([
IsOptionalIfEmpty_1.IsOptionalIfEmpty(),
class_validator_1.MaxLength(30, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'AddressLine1'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "AddressLine1", void 0);
__decorate([
IsOptionalIfEmpty_1.IsOptionalIfEmpty(),
class_validator_1.MaxLength(30, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'AddressLine2'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "AddressLine2", void 0);
__decorate([
IsOptionalIfEmpty_1.IsOptionalIfEmpty(),
class_validator_1.MaxLength(20, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'AddressSuburb'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "AddressSuburb", void 0);
__decorate([
IsOptionalIfEmpty_1.IsOptionalIfEmpty(),
class_validator_1.MaxLength(3, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'AddressState'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "AddressState", void 0);
__decorate([
IsOptionalIfEmpty_1.IsOptionalIfEmpty(),
class_validator_1.IsNumberString(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'AddressPostCode'),
}),
class_validator_1.MaxLength(4, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'AddressPostCode'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "AddressPostCode", void 0);
__decorate([
IsOptionalIfEmpty_1.IsOptionalIfEmpty(),
class_validator_1.MaxLength(255, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'EmailAddress'),
}),
class_validator_1.IsEmail(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotAnEmail, 'EmailAddress'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "EmailAddress", void 0);
__decorate([
IsOptionalIfEmpty_1.IsOptionalIfEmpty(),
class_validator_1.MaxLength(10, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'MobilePhoneNumber'),
}),
class_validator_1.IsMobilePhone('en-AU', undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotAMobilePhone, 'MobilePhoneNumber'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "MobilePhoneNumber", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'ContractStartDate'),
}),
__metadata("design:type", String)
], CustomerDTO.prototype, "ContractStartDate", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'SmsPaymentReminder'),
}),
class_validator_1.IsIn(['YES', 'NO'], {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotInAllowedSet, 'SmsPaymentReminder'),
}),
__metadata("design:type", String)
], CustomerDTO.prototype, "SmsPaymentReminder", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'SmsFailedNotification'),
}),
class_validator_1.IsIn(['YES', 'NO'], {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotInAllowedSet, 'SmsFailedNotification'),
}),
__metadata("design:type", String)
], CustomerDTO.prototype, "SmsFailedNotification", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'SmsExpiredCard'),
}),
class_validator_1.IsIn(['YES', 'NO'], {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotInAllowedSet, 'SmsExpiredCard'),
}),
__metadata("design:type", String)
], CustomerDTO.prototype, "SmsExpiredCard", void 0);
__decorate([
class_validator_1.IsOptional(),
class_validator_1.MaxLength(50, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'Username'),
}),
__metadata("design:type", Object)
], CustomerDTO.prototype, "Username", void 0);
return CustomerDTO;
}());
exports.CustomerDTO = CustomerDTO;