From c70d9c0759e391d2104e17bce5ab4e71413367d7 Mon Sep 17 00:00:00 2001 From: Sahil Sharma <123928721+sahilsharma9@users.noreply.github.com> Date: Tue, 9 May 2023 14:06:48 +0530 Subject: [PATCH] fix: added interfaces --- .env.development | 4 +- controller/.DS_Store | Bin 0 -> 6148 bytes controller/bugzilla/bugzilla.service.ts | 4 +- controller/issue/bpp.issue.service.ts | 21 ++-- interfaces/bpp_issue.ts | 121 ++++++++++++++++++++++++ interfaces/issue.ts | 16 +++- utils/protocolApis.ts | 3 +- 7 files changed, 152 insertions(+), 17 deletions(-) create mode 100644 controller/.DS_Store create mode 100644 interfaces/bpp_issue.ts diff --git a/.env.development b/.env.development index 69e2382..84d000c 100644 --- a/.env.development +++ b/.env.development @@ -7,7 +7,7 @@ BAP_ID=ondc-dev.thewitslab.com EXPECTED_RESPONSE_TIME=PT1H EXPECTED_RESOLUTION_TIME=P1D BUGZILLA_API_KEY=6HA3DtWYC7bS6qKF2UfQeS7sLIY9L9DRRL0CASPA -BAP_URL=https://1dd5-101-0-41-79.ngrok-free.app/protocol/v1 -PROTOCOL_BASE_URL=https://1dd5-101-0-41-79.ngrok-free.app +BAP_URL=https://6be5-115-240-127-98.ngrok-free.app/protocol/v1 +PROTOCOL_BASE_URL=https://6be5-115-240-127-98.ngrok-free.app VOLUME_IMAGES_BASE_URL=http://localhost:6969/uploads/ BUGZILLA_SERVICE_URI=http://localhost/bugzilla/admin/ \ No newline at end of file diff --git a/controller/.DS_Store b/controller/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..bca7348391d3ce1ed794ac98546a0bf0bf2bd414 GIT binary patch literal 6148 zcmeHKI|>3p3{CuiU}I@HSMUad=n3`$7K#X>plH37=kjR2e41sk(?WS!GH)i6H_N_a zvJnwo-nI*onTSl_hVrnXZ?Ga_g%oaV>!qb&#l9^9U2v& z0#twsPys6NX$7*vPNttenCDReD)93P*!@u8hBdJb^s57dw*bHq!fu#*F99qT0M^7d z5D}OL6&O^_7DI!Mc*(q)*aik&G@B32H*0n%>Tk#S#nVM=AV(@d1-c3hV>z?>zlOi* z|GOlvr~noCD+P44YF0~pQr6bq$62i{@D1E@o^UhFor1y3G0@8~7FLeuo)me-=Gd=^ UZJ^T;cRG+i1Evd&3Vd6E7yd*P)Bpeg literal 0 HcmV?d00001 diff --git a/controller/bugzilla/bugzilla.service.ts b/controller/bugzilla/bugzilla.service.ts index b408468..f5b98b2 100644 --- a/controller/bugzilla/bugzilla.service.ts +++ b/controller/bugzilla/bugzilla.service.ts @@ -1,9 +1,9 @@ import { logger } from "../../shared/logger"; -import { IssueProps } from "../../interfaces/issue"; +import { Context, IssueProps } from "../../interfaces/issue"; import HttpRequest from "../../utils/httpRequest"; class BugzillaService { - async createIssueInBugzilla(issue: IssueProps, requestContext: any) { + async createIssueInBugzilla(issue: IssueProps, requestContext: Context) { try { const payload = { product: issue?.order_details?.items?.[0]?.product?.descriptor?.name, diff --git a/controller/issue/bpp.issue.service.ts b/controller/issue/bpp.issue.service.ts index cc95521..841a8f4 100644 --- a/controller/issue/bpp.issue.service.ts +++ b/controller/issue/bpp.issue.service.ts @@ -1,17 +1,23 @@ import { protocolIssue } from "../../utils/protocolApis"; import { PROTOCOL_CONTEXT } from "../../shared/constants"; -import { Fulfillment, IssueProps, Item } from "../../interfaces/issue"; +import { + Fulfillment, + IssueProps, + Item, + Response, +} from "../../interfaces/issue"; +import { Context, IssueRequest } from "../../interfaces/bpp_issue"; class BppIssueService { /** * bpp issue * @param {Object} context * @param {Object} issue */ - async issue(context: object, issue: IssueProps) { + async issue(context: Context, issue: IssueProps) { try { const { issue_actions, order_details, description } = issue; - const issueRequest = { + const issueRequest: IssueRequest = { context: context, message: { issue: { @@ -64,17 +70,17 @@ class BppIssueService { }, }; - const response: any = await protocolIssue(issueRequest); - return { context: context, message: response?.message }; + const response: Response = await protocolIssue(issueRequest); + return { context: context, message: response.message }; } catch (err) { throw err; } } - async closeOrEscalateIssue(context: object, issue: IssueProps) { + async closeOrEscalateIssue(context: Context, issue: IssueProps) { try { const { issue_actions } = issue; - const issueRequest = { + const issueRequest: any = { context: context, message: { issue: { @@ -84,6 +90,7 @@ class BppIssueService { rating: issue.rating, created_at: issue?.created_at, updated_at: issue?.updated_at, + issue_type: issue?.issue_type, }, }, }; diff --git a/interfaces/bpp_issue.ts b/interfaces/bpp_issue.ts new file mode 100644 index 0000000..39bb382 --- /dev/null +++ b/interfaces/bpp_issue.ts @@ -0,0 +1,121 @@ +export interface IssueRequest { + context: Context; + message: Message; +} + +export interface Context { + domain: string; + country: string; + city: string; + action: string; + core_version: string; + bap_id: string; + bap_uri: string; + bpp_uri: string; + transaction_id: string; + message_id: string; + timestamp: Date; + bpp_id: string; + ttl: string; +} + +export interface Message { + issue: Issue; +} + +export interface Issue { + id?: string; + category: string; + sub_category: string; + complainant_info: ComplainantInfo; + order_details: OrderDetails; + description: Description; + source: Source; + expected_response_time: ExpectedResTime; + expected_resolution_time: ExpectedResTime; + status: string; + issue_type: string; + issue_actions: IssueActions; + created_at: Date; + updated_at: Date; +} + +export interface ComplainantInfo { + person: Person; + contact: ComplainantInfoContact; +} + +export interface ComplainantInfoContact { + phone: string; +} + +export interface Person { + name: string; + email?: string; +} + +export interface Description { + short_desc: string; + long_desc: string; + additional_desc: AdditionalDesc; + images: any[]; +} + +export interface AdditionalDesc { + url: string; + content_type: string; +} + +export interface ExpectedResTime { + duration?: string; +} + +export interface IssueActions { + complainant_actions?: ComplainantAction[]; + respondent_actions?: any[]; +} + +export interface ComplainantAction { + complainant_action: string; + remarks: string; + updated_at: Date; + updated_by: UpdatedBy; +} + +export interface UpdatedBy { + org: Org; + contact: UpdatedByContact; + person: Org; +} + +export interface UpdatedByContact { + phone: string; + email?: string; +} + +export interface Org { + name: string; +} + +export interface OrderDetails { + id: string; + state: string; + items: Item[]; + fulfillments: Fulfillment[]; + provider_id: string; +} + +export interface Fulfillment { + id: string; + state: string; +} + +export interface Item { + id: string; + quantity: number; +} + +export interface Source { + network_participant_id?: string; + issue_source_type: string; +} diff --git a/interfaces/issue.ts b/interfaces/issue.ts index 240541f..c291817 100644 --- a/interfaces/issue.ts +++ b/interfaces/issue.ts @@ -4,6 +4,8 @@ export interface IssueRequest { } export interface Context { + bpp_id: any; + bpp_uri: any; transaction_id: string; city: string; state: string; @@ -245,12 +247,12 @@ export interface IParamProps { pageNumber: number; } -export interface BppResponse { +export interface IssueRequestPayload { context: Context; - message: any; + message: Message; } -export interface Context { +export interface RequestContext { domain: string; country: string; city: string; @@ -267,9 +269,13 @@ export interface Context { } export interface Message { - ack: ACK; + ack?: ACK; } export interface ACK { - status: string; + status?: string; +} + +export interface Response { + message?: Message; } diff --git a/utils/protocolApis.ts b/utils/protocolApis.ts index e84e8c0..864b299 100644 --- a/utils/protocolApis.ts +++ b/utils/protocolApis.ts @@ -1,5 +1,6 @@ import HttpRequest from "./httpRequest"; import PROTOCOL_API_URLS from "../shared/protocolRoutes"; +import { IssueRequest } from "../interfaces/bpp_issue"; /** * on Issue @@ -21,7 +22,7 @@ const onIssue = async (messageId: string) => { * @param {Object} data * @returns */ -const protocolIssue = async (data: any) => { +const protocolIssue = async (data: IssueRequest) => { const apiCall = new HttpRequest( process.env.PROTOCOL_BASE_URL, PROTOCOL_API_URLS.ISSUE,