mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Minor improvements to Jira-Node
This commit is contained in:
parent
e4cc3a4bc9
commit
79a09c98a7
|
@ -16,23 +16,28 @@ import {
|
||||||
|
|
||||||
export async function jiraSoftwareCloudApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
export async function jiraSoftwareCloudApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
||||||
let data; let domain;
|
let data; let domain;
|
||||||
let jiraCloudCredentials: ICredentialDataDecryptedObject | undefined;
|
|
||||||
try {
|
|
||||||
jiraCloudCredentials = this.getCredentials('jiraSoftwareCloudApi');
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
|
const jiraVersion = this.getNodeParameter('jiraVersion', 0) as string;
|
||||||
|
|
||||||
|
let jiraCredentials: ICredentialDataDecryptedObject | undefined;
|
||||||
|
if (jiraVersion === 'server') {
|
||||||
|
jiraCredentials = this.getCredentials('jiraSoftwareServerApi');
|
||||||
|
} else {
|
||||||
|
jiraCredentials = this.getCredentials('jiraSoftwareCloudApi');
|
||||||
}
|
}
|
||||||
const jiraServerCredentials = this.getCredentials('jiraSoftwareServerApi');
|
|
||||||
if (jiraCloudCredentials === undefined && jiraServerCredentials === undefined) {
|
if (jiraCredentials === undefined) {
|
||||||
throw new Error('No credentials got returned!');
|
throw new Error('No credentials got returned!');
|
||||||
}
|
}
|
||||||
if (jiraCloudCredentials !== undefined) {
|
|
||||||
domain = jiraCloudCredentials!.domain;
|
if (jiraVersion === 'server') {
|
||||||
data = Buffer.from(`${jiraCloudCredentials!.email}:${jiraCloudCredentials!.apiToken}`).toString('base64');
|
domain = jiraCredentials!.domain;
|
||||||
|
data = Buffer.from(`${jiraCredentials!.email}:${jiraCredentials!.password}`).toString('base64');
|
||||||
} else {
|
} else {
|
||||||
domain = jiraServerCredentials!.domain;
|
domain = jiraCredentials!.domain;
|
||||||
data = Buffer.from(`${jiraServerCredentials!.email}:${jiraServerCredentials!.password}`).toString('base64');
|
data = Buffer.from(`${jiraCredentials!.email}:${jiraCredentials!.apiToken}`).toString('base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${data}`,
|
Authorization: `Basic ${data}`,
|
||||||
|
|
|
@ -141,7 +141,7 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
|
|
||||||
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/issuetype', 'GET');
|
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/issuetype', 'GET');
|
||||||
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
|
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
|
||||||
if (jiraVersion === "server") {
|
if (jiraVersion === 'server') {
|
||||||
for (const issueType of issueTypes) {
|
for (const issueType of issueTypes) {
|
||||||
const issueTypeName = issueType.name;
|
const issueTypeName = issueType.name;
|
||||||
const issueTypeId = issueType.id;
|
const issueTypeId = issueType.id;
|
||||||
|
@ -210,10 +210,10 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
// select them easily
|
// select them easily
|
||||||
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
const jiraVersion = this.getCurrentNodeParameter("jiraVersion") as string;
|
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
|
||||||
if (jiraVersion === "server") {
|
if (jiraVersion === 'server') {
|
||||||
// the interface call must bring username
|
// the interface call must bring username
|
||||||
const users = await jiraSoftwareCloudApiRequest.call(this, "/user/search", "GET", {},
|
const users = await jiraSoftwareCloudApiRequest.call(this, '/user/search', 'GET', {},
|
||||||
{
|
{
|
||||||
username: "'",
|
username: "'",
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (additionalFields.assignee) {
|
if (additionalFields.assignee) {
|
||||||
if (jiraVersion === "server") {
|
if (jiraVersion === 'server') {
|
||||||
fields.assignee = {
|
fields.assignee = {
|
||||||
name: additionalFields.assignee as string,
|
name: additionalFields.assignee as string,
|
||||||
};
|
};
|
||||||
|
@ -386,7 +386,7 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (updateFields.assignee) {
|
if (updateFields.assignee) {
|
||||||
if (jiraVersion === "server") {
|
if (jiraVersion === 'server') {
|
||||||
fields.assignee = {
|
fields.assignee = {
|
||||||
name: updateFields.assignee as string,
|
name: updateFields.assignee as string,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue