diff --git a/mappings/on_status.jsonata b/mappings/on_status.jsonata new file mode 100644 index 0000000000000000000000000000000000000000..fad160a9abed81a0bbec84e4722e1ee6123341b4 --- /dev/null +++ b/mappings/on_status.jsonata @@ -0,0 +1,74 @@ +{ + "data":$.responses.{ + "context": context, + "message":{ + "order":{ + "id": message.order.id, + "status": message.order.status, + "provider":{ + "id": message.order.provider.id, + "name": message.order.provider.descriptor.name, + "short_desc": message.order.provider.descriptor.short_desc, + "long_desc": message.order.provider.descriptor.long_desc, + "rating": message.order.provider.rating, + "images": message.order.provider.descriptor.images. + { + "url": url, + "size_type": size_type + }, + "media": message.order.provider.descriptor.media. + { + "url": url + }, + "rateable": message.order.provider.rateable + }, + "items": message.order.items.{ + "id": id, + "name": descriptor.name, + "short_desc": descriptor.short_desc, + "long_desc": descriptor.long_desc, + "price": price, + "rating": rating, + "xinput": xinput, + "rateable": rateable, + "time": time, + "quantity": quantity, + "categories": $map( + $filter(%.provider.categories, function($categories){$boolean($category.id in categories_ids)}), + function($category) { + { "id": $category.id, "name": $category.descriptor.name, "code": $category.descriptor.code } + } + )[], + "locations": $map( + $filter(%.provider.locations, function($location) { $boolean($location.id in location_ids)}), + function($location) { + { + "id": $location.id, + "city": $location.city.name, + "state": $location.state.name, + "country": $location.country.name + } + } + )[], + "tags": tags.{ + "code": descriptor.code, + "name": descriptor.name, + "display": display, + "list": list.{ + "code": descriptor.code, + "name": descriptor.name, + "value": value }[] + }[] + }, + "fulfillments": message.order.fulfillments, + "quote": message.order.quote, + "billing": message.order.billing, + "payments": message.order.payments, + "cancellation_terms": message.order.cancellation_terms, + "type": message.order.type + } + } + }[] +} + + diff --git a/mappings/status.jsonata b/mappings/status.jsonata new file mode 100644 index 0000000000000000000000000000000000000000..358ec27bb3b292ce37e709a8a4717fc671d9cb08 --- /dev/null +++ b/mappings/status.jsonata @@ -0,0 +1,6 @@ +$.data.{ + "context": $context(context, $action), + "message": { + "order_id": orderId + } +}[] diff --git a/src/gcl/gcl.service.ts b/src/gcl/gcl.service.ts index 45e263a7948c3945fc66012a8406b88c771c878b..d99515ce3cfc7899a0f85d37be0a175ed77ff87f 100644 --- a/src/gcl/gcl.service.ts +++ b/src/gcl/gcl.service.ts @@ -4,74 +4,72 @@ import { PSClientService } from "../psclient/psclient.service"; @injectable() export class GCLService { - constructor( - @inject(TLService) private tlService: TLService, - @inject(PSClientService) private psClientService: PSClientService - ) { } - - async search(body: any) { - const payload = await this.tlService.transform(body, "search"); - const psResponse = await this.psClientService.post(payload); - const response = await this.tlService.transform(psResponse, "on_search"); - - return response; - } - - async select(body: any) { - const payload = await this.tlService.transform(body, "select"); - const psResponse = await this.psClientService.postMany(payload); - const response = await this.tlService.transform(psResponse, "on_select"); - - return response; - } - - async init(body: any) { - const payload = await this.tlService.transform(body, "init"); - const psResponse = await this.psClientService.postMany(payload); - const response = await this.tlService.transform(psResponse, "on_init"); - - return response; - } - - async confirm(body: any) { - const payload = await this.tlService.transform(body, "confirm"); - const psResponse = await this.psClientService.postMany(payload); - const response = await this.tlService.transform(psResponse, "on_confirm"); - - return response; - } - - async status(body: any) { - // const payload = await this.tlService.transform(body, "select"); - // const psResponse = await this.psClientService.postMany(payload); - // const response = await this.tlService.transform(psResponse, "on_select"); - - // return response; - - return "In Progress"; - } - - async rating(body: any) { - const payload = await this.tlService.transform(body, "rating"); - const psResponse = await this.psClientService.post(payload); - const response = await this.tlService.transform(psResponse, "on_rating"); - - return response; - } - - async cancel(body: any) { - const payload = await this.tlService.transform(body, "cancel"); - const psResponse = await this.psClientService.post(payload); - const response = await this.tlService.transform(psResponse, "on_cancel"); - - return response; - } - - async update(body: any) { - const payload = await this.tlService.transform(body, "update"); - const psResponse = await this.psClientService.postMany(payload); - const response = await this.tlService.transform(psResponse, "on_update"); - - return response; - } + constructor( + @inject(TLService) private tlService: TLService, + @inject(PSClientService) private psClientService: PSClientService + ) {} + + async search(body: any) { + const payload = await this.tlService.transform(body, "search"); + const psResponse = await this.psClientService.post(payload); + const response = await this.tlService.transform(psResponse, "on_search"); + + return response; + } + + async select(body: any) { + const payload = await this.tlService.transform(body, "select"); + const psResponse = await this.psClientService.postMany(payload); + const response = await this.tlService.transform(psResponse, "on_select"); + + return response; + } + + async init(body: any) { + const payload = await this.tlService.transform(body, "init"); + const psResponse = await this.psClientService.postMany(payload); + const response = await this.tlService.transform(psResponse, "on_init"); + + return response; + } + + async confirm(body: any) { + const payload = await this.tlService.transform(body, "confirm"); + const psResponse = await this.psClientService.postMany(payload); + const response = await this.tlService.transform(psResponse, "on_confirm"); + + return response; + } + + async status(body: any) { + const payload = await this.tlService.transform(body, "select"); + const psResponse = await this.psClientService.postMany(payload); + const response = await this.tlService.transform(psResponse, "on_select"); + + return response; + } + + async rating(body: any) { + const payload = await this.tlService.transform(body, "rating"); + const psResponse = await this.psClientService.post(payload); + const response = await this.tlService.transform(psResponse, "on_rating"); + + return response; + } + + async cancel(body: any) { + const payload = await this.tlService.transform(body, "cancel"); + const psResponse = await this.psClientService.post(payload); + const response = await this.tlService.transform(psResponse, "on_cancel"); + + return response; + } + + async update(body: any) { + const payload = await this.tlService.transform(body, "update"); + const psResponse = await this.psClientService.postMany(payload); + const response = await this.tlService.transform(psResponse, "on_update"); + + return response; + } }