apigee-x-module
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -10,3 +10,6 @@ import { ApiProducts, Developers, Developer, Apps, App } from "./apigee-types"; | ||
getApps(email: string): Promise<Apps>; | ||
getApp(email: string, appName: string): Promise<App>; | ||
createApp(email: string, appName: string, apiProducts: string[]): Promise<App>; | ||
updateApp(email: string, appName: string, app: App): Promise<App>; | ||
deleteApp(email: string, appName: string): Promise<App>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Function interfaces | ||
// interface GetRatePlansFunc { | ||
// (token: string, org: string): Promise<Rate[]>; | ||
// } |
@@ -15,3 +15,6 @@ import { ApiProducts, App, Developers, Developer, Apps } from "./apigee-types"; | ||
createApp(email: string, appName: string, apiProducts: string[]): Promise<App>; | ||
getApp(email: string, appName: string): Promise<App>; | ||
updateApp(email: string, appName: string, app: App): Promise<App>; | ||
deleteApp(email: string, appName: string): Promise<App>; | ||
getToken(): Promise<string>; | ||
} |
@@ -264,2 +264,51 @@ "use strict"; | ||
} | ||
getApp(email, appName) { | ||
return new Promise((resolve, reject) => { | ||
this.getToken().then((token) => { | ||
axios({ | ||
"url": `https://apigee.googleapis.com/v1/organizations/${this.apigeeOrganization}/developers/${email}/apps/${appName}`, | ||
"method": "get", | ||
"headers": { | ||
"Content-Type": "application/json", | ||
"Authorization": "Bearer " + token | ||
} | ||
}).then((response) => { | ||
let apigeeApp = response.data; | ||
let app = { | ||
appId: apigeeApp.appId, | ||
name: apigeeApp.name, | ||
createdAt: apigeeApp.createdAt, | ||
credentials: [], | ||
apiProducts: apigeeApp.apiProducts | ||
}; | ||
apigeeApp.credentials.forEach((apigeeCredential) => { | ||
let appCredential = { | ||
key: apigeeCredential.consumerKey, | ||
secret: apigeeCredential.consumerSecret, | ||
issuedAt: apigeeCredential.issuedAt, | ||
expiresAt: apigeeCredential.expiresAt, | ||
scopes: apigeeCredential.scopes, | ||
status: apigeeCredential.status | ||
}; | ||
app.credentials.push(appCredential); | ||
}); | ||
resolve(app); | ||
}).catch((error) => { | ||
if (error.response && error.response.data) | ||
resolve(error.response.data); | ||
else | ||
reject(error); | ||
}); | ||
}).catch((error) => { | ||
console.error(error); | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
updateApp(email, appName, app) { | ||
throw new Error("Method not implemented."); | ||
} | ||
deleteApp(email, appName) { | ||
throw new Error("Method not implemented."); | ||
} | ||
getToken() { | ||
@@ -266,0 +315,0 @@ return new Promise((resolve, reject) => { |
{ | ||
"name": "apigee-x-module", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Module for integrating with the Apigee X platform for TS/JS developer portal integrations.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/tyayers/apigee-x-module", |
33359
499