Skip to content

Commit

Permalink
fix: added interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sahilsharma9 committed May 9, 2023
1 parent e40eef9 commit c70d9c0
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Binary file added controller/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions controller/bugzilla/bugzilla.service.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
21 changes: 14 additions & 7 deletions controller/issue/bpp.issue.service.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down Expand Up @@ -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: {
Expand All @@ -84,6 +90,7 @@ class BppIssueService {
rating: issue.rating,
created_at: issue?.created_at,
updated_at: issue?.updated_at,
issue_type: issue?.issue_type,
},
},
};
Expand Down
121 changes: 121 additions & 0 deletions interfaces/bpp_issue.ts
Original file line number Diff line number Diff line change
@@ -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;
}
16 changes: 11 additions & 5 deletions interfaces/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export interface IssueRequest {
}

export interface Context {
bpp_id: any;
bpp_uri: any;
transaction_id: string;
city: string;
state: string;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
3 changes: 2 additions & 1 deletion utils/protocolApis.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import HttpRequest from "./httpRequest";
import PROTOCOL_API_URLS from "../shared/protocolRoutes";
import { IssueRequest } from "../interfaces/bpp_issue";

/**
* on Issue
Expand All @@ -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,
Expand Down

0 comments on commit c70d9c0

Please sign in to comment.