-
Notifications
You must be signed in to change notification settings - Fork 2
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
064e3f1
commit ccc4fa4
Showing
8 changed files
with
93 additions
and
8 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,34 @@ | ||
import Client, { Authenticator, BasicAuth, TokenAuth } from "./Client"; | ||
import { DefaultPluginSettings } from "./JiraPluginSettings"; | ||
|
||
/** | ||
* Convenience class for getting connected to Jira. | ||
*/ | ||
export class JiraConnection { | ||
/** | ||
* Creates a new Client for making API requests. | ||
* | ||
* @param settings - Connection settings for the client. | ||
* @returns A configured Client. | ||
*/ | ||
public static getClient(settings: DefaultPluginSettings): Client { | ||
const {domain, email: username, token: key, strategy} = settings; | ||
|
||
if (!domain) { | ||
throw new Error('A domain must be set'); | ||
} | ||
|
||
if (!key) { | ||
throw new Error('An API token must be set'); | ||
} | ||
|
||
let authenticator: Authenticator; | ||
if (strategy === 'PAT') { | ||
authenticator = new TokenAuth(key); | ||
} else { | ||
authenticator = new BasicAuth(username, key); | ||
} | ||
|
||
return new Client(`https://${domain}`, authenticator); | ||
} | ||
} |
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
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