@dotdev/apparel21-sdk
Advanced tools
Comparing version 0.0.60 to 0.0.61
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.0.61](https://gitlab.com/dotdevv/packages/apparel21-sdk/compare/v0.0.60...v0.0.61) (2023-09-06) | ||
### Features | ||
* support person custom data ([df05c1a](https://gitlab.com/dotdevv/packages/apparel21-sdk/commit/df05c1a192232a3cda0233ebb4005001dca3607a)) | ||
### [0.0.60](https://gitlab.com/dotdevv/packages/apparel21-sdk/compare/v0.0.59...v0.0.60) (2023-09-06) | ||
@@ -7,0 +14,0 @@ |
@@ -45,2 +45,7 @@ import currency from 'currency.js'; | ||
} | ||
export interface CustomData { | ||
[key: string]: { | ||
[key: string]: string | [string]; | ||
}; | ||
} | ||
export interface PersonReference { | ||
@@ -69,7 +74,2 @@ referenceTypeId: number; | ||
} | ||
export interface CustomData { | ||
[key: string]: { | ||
[key: string]: string | [string]; | ||
}; | ||
} | ||
export interface ProductSize { | ||
@@ -181,2 +181,3 @@ id: number; | ||
rewardsAccounts: PersonRewardsAccount[]; | ||
customData: CustomData; | ||
} | ||
@@ -200,2 +201,3 @@ export interface CreatePersonInput extends Partial<Omit<Person, 'contacts'>> { | ||
password?: string; | ||
customData?: boolean; | ||
} | ||
@@ -202,0 +204,0 @@ export interface GetPersonQuery { |
@@ -27,2 +27,24 @@ "use strict"; | ||
})); | ||
const formatCustomData = (customData) => { | ||
if (!customData) | ||
return {}; | ||
return customData.Cards[0].Card.reduce((cards, card) => { | ||
const cardName = card.$.Name; | ||
const cardFields = card.Fields[0].Field.reduce((fields, field) => { | ||
const fieldName = field.$.Name; | ||
const fieldValue = field.ListValues | ||
? field.ListValues[0].Value | ||
: field._; | ||
return fieldName ? { ...fields, [fieldName]: fieldValue } : fields; | ||
}, {}); | ||
return cardName | ||
? { | ||
...cards, | ||
[cardName]: !!cards[cardName] | ||
? { ...cards[cardName], ...cardFields } | ||
: cardFields, | ||
} | ||
: cards; | ||
}, {}); | ||
}; | ||
exports.formatPersons = (persons = []) => persons.map((person) => ({ | ||
@@ -43,6 +65,8 @@ id: parseInt(person.Id[0], 10), | ||
isAgent: person.IsAgent[0]?.toLowerCase() === 'true' ? true : false, | ||
currency: person.Currency?.[0] ? { | ||
code: person.Currency[0].Code[0], | ||
format: person.Currency[0].Format[0], | ||
} : undefined, | ||
currency: person.Currency?.[0] | ||
? { | ||
code: person.Currency[0].Code[0], | ||
format: person.Currency[0].Format[0], | ||
} | ||
: undefined, | ||
contacts: person.Contacts.map((contact) => ({ | ||
@@ -86,2 +110,5 @@ email: contact.Email?.[0], | ||
: [], | ||
customData: person.CustomData | ||
? formatCustomData(person.CustomData[0]) | ||
: {}, | ||
})); | ||
@@ -88,0 +115,0 @@ exports.formatRetailTransactions = (transactions) => transactions?.map((transaction) => ({ |
{ | ||
"name": "@dotdev/apparel21-sdk", | ||
"version": "0.0.60", | ||
"version": "0.0.61", | ||
"license": "UNLICENSED", | ||
@@ -5,0 +5,0 @@ "description": "Apparel21 Interface Library", |
Sorry, the diff of this file is not supported yet
237116
3574