-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a47617b
commit 0522591
Showing
6 changed files
with
120 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import IDictionary from "../types/dictionary" | ||
|
||
export const typeMapping: IDictionary = { | ||
group: "Gruppe/Verein", | ||
therapist: "Therapeut*in/Psychiater*in", | ||
surveyor: "Gutachter*in", | ||
endocrinologist: "Endokrinologische Praxis", | ||
surgeon: "Operateur*in", | ||
logopedics: "Logopäd*in", | ||
hairremoval: "Haarentfernung" | ||
} | ||
|
||
export const reportTypeMapping = { | ||
edit: "Änderungsvorschlag", | ||
report: "Nicht empfehlenswert", | ||
other: "Sonstiges" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import axios from "axios"; | ||
import { DatabaseEntry } from "../models/database/entry.model"; | ||
import { reportTypeMapping } from "../models/entryMapping"; | ||
import IDictionary from "../types/dictionary"; | ||
import { config } from "./config.service.js"; | ||
|
||
export async function createReportTicket(entry: DatabaseEntry<"out">, type: keyof typeof reportTypeMapping, message: string) { | ||
const customFields = new Map<string, unknown>(); | ||
customFields.set(config.atlassian.customFieldReportType, { id: config.atlassian.customfieldReportTypeMapping[type] }); | ||
customFields.set(config.atlassian.customfieldURL, config.reportEntryURL + entry._id); | ||
|
||
const body: IDictionary = { | ||
fields: { | ||
issuetype: { | ||
id: config.atlassian.issueTypes.report | ||
}, | ||
summary: entry.name, | ||
project: { | ||
id: config.atlassian.projectId, | ||
}, | ||
description: { | ||
content: [ | ||
{ | ||
content: [ | ||
{ | ||
text: message, | ||
type: "text" | ||
} | ||
], | ||
type: "paragraph" | ||
} | ||
], | ||
type: "doc", | ||
version: 1 | ||
}, | ||
...Object.fromEntries(customFields.entries()) | ||
} | ||
} | ||
|
||
try { | ||
await axios.post(config.atlassian.apiURL, body, { | ||
auth: { | ||
username: config.atlassian.username, | ||
password: config.atlassian.key, | ||
} | ||
}); | ||
return true; | ||
} catch (e: any) { | ||
console.error(`Error while creating atlassian jira ticket! Status Code: ${e.message}`); | ||
return false; | ||
} | ||
} | ||
|
||
export async function newEntryTicket(name: string) { | ||
const body: IDictionary = { | ||
fields: { | ||
issuetype: { | ||
id: config.atlassian.issueTypes.newEntry | ||
}, | ||
summary: name, | ||
project: { | ||
id: config.atlassian.projectId, | ||
} | ||
} | ||
} | ||
|
||
try { | ||
await axios.post(config.atlassian.apiURL, body, { | ||
auth: { | ||
username: config.atlassian.username, | ||
password: config.atlassian.key, | ||
} | ||
}); | ||
return true; | ||
} catch (e: any) { | ||
console.error(`Error while creating atlassian jira ticket! Status Code: ${e.message}`); | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters