Skip to content
Snippets Groups Projects
Unverified Commit a2f02077 authored by Ajay Nishad's avatar Ajay Nishad Committed by GitHub
Browse files

Merge pull request #17 from beckn/update-api

Added: update-api
parents 35edc6b4 13bbc5b7
No related branches found
No related tags found
No related merge requests found
{
"data":$.responses.{
"context":context,
"message":{
"orderId":message.order.id,
"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
}[]
},
"items":message.order.items.{
"id":id,
"name":descriptor.name,
"code":descriptor.code,
"short_desc":descriptor.short_desc,
"long_desc":descriptor.long_desc,
"price": price,
"rating": rating,
"rateable": rateable,
"time": time,
"quantity": quantity,
"categories": $map(
$filter(%.provider.categories, function($category) { $boolean($category.id in category_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
}
}[]
}
$.data.{
"context":$context(context, $action),
"message":{
"order":{
"order_id":orderId,
"fulfillments":updateDetails.fulfillments,
"billing":updateDetails.billing
},
"update_target":updateDetails.updateTarget
}
}[]
......@@ -48,4 +48,10 @@ export class GCLController {
const statusResult = await this.service.cancel(body);
return statusResult;
}
@httpPost('update')
public async update(@requestBody() body: any): Promise<any> {
const updateResult = await this.service.update(body);
return updateResult;
}
}
import { inject, injectable } from "inversify";
import { TLService } from "../tl/tl.service";
import { PSClientService } from "../psclient/psclient.service";
import data from '../../data.json';
@injectable()
export class GCLService {
......@@ -67,4 +66,12 @@ export class GCLService {
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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment