Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions services/graphql/src/definitions/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ input RapidCustomerIdentificationBehaviorInput {
id: Int!
"The date the behavior occurred."
date: DateTime
"An optional promo code to associate with this specific behavior. Falls back to the top-level promoCode if not set."
behaviorPromoCode: String
"An array of pre-defined key-values to send with the behavior."
attributes: [RapidCustomerIdentificationBehaviorAttributeInput!]! = []
}
Expand Down
10 changes: 9 additions & 1 deletion services/graphql/src/resolvers/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,17 @@ module.exports = {
})),
}),
...(behaviors.length && {
CustomerBehaviors: behaviors.map(({ id, date, attributes }) => ({
CustomerBehaviors: behaviors.map(({
id,
date,
behaviorPromoCode,
attributes,
}) => ({
BehaviorId: id,
BehaviorDate: dayjs(date || new Date()).format('YYYY-MM-DD HH:mm:ss'),
...((behaviorPromoCode || promoCode) && {
BehaviorPromoCode: behaviorPromoCode || promoCode,
}),
...(attributes.length && {
BehaviorAttributes: attributes.map((attr) => {
if (!attr.valueId && !attr.value) throw new UserInputError('One of `valueId` or `value` must be specified for behavior attribute!');
Expand Down
Loading