floralvikings / jira-connector

NodeJS Wrapper for the Jira REST API
http://floralvikings.github.io/jira-connector/
MIT License
373 stars 180 forks source link

Cannot get licensing information for addon #243

Open dasheck0 opened 4 years ago

dasheck0 commented 4 years ago

Hi,

I try to get my head around how to retrieve licensing information for a jira cloud plugin. In the atlassian reference I see that I can GET /rest/atlassian-connect/1/addons/{appKey} (see https://developer.atlassian.com/platform/marketplace/license-api-for-cloud-apps/).

However, I cannot find a suitable class or client for that request. Am I missing something? Thanks in advance for a reply.

Best regards!

dasheck0 commented 4 years ago

Fixed it myself. See the following code:

async getLicense(key: string): Promise<any> {
    // client is the jira client, which is initialized earlies with a valid jwt and secret
    return new Promise((resolve, reject) => {
      const uri = this.client.buildAbstractURL(`atlassian-connect/1/addons/${key}`);

      this.client.makeRequest({
        uri,
        method: 'GET',
        json: true,
        followAllRedirects: true
      }, (error, response) => {
        if (error) {
          reject(error);
        } else {
          resolve(response);
        }
      });
    });
  }

Should be easy to add it to the code. Do you accept pull requests?