Skip to content

Instantly share code, notes, and snippets.

@nialdarbey
Created September 6, 2015 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nialdarbey/94e0dd89f5d90f951062 to your computer and use it in GitHub Desktop.
Save nialdarbey/94e0dd89f5d90f951062 to your computer and use it in GitHub Desktop.
%dw 1.0
%namespace mes http://www.alainn.com/SOA/message/1.0
%namespace mod http://www.alainn.com/SOA/model/1.0
%output application/xml
---
mes#getItemsResponse: {
  mes#PageInfo: {
    pageIndex: inboundProperties."http.query.params".pageIndex,
    pageSize: sizeOf payload distinctBy $.item_id 
  },
  (payload groupBy $.item_id map {
    mod#Item: {
      id: $[0].item_id,
      type: $[0].item_type_name,
      name: $[0].item_name,
      (summary: $[0].item_summary) when $[0].item_summary != null,
      brand: $[0].item_brand,
      images: {
        ($ map {
          image@(type:$.image_type_name): $.url
        })
      }
    }
  })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment