Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix request data type. #81

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/controllers/serviceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default class ServiceController {
return await 'information of service';
}

async calculateCost(serviceName: string, requestData: string): Promise<number> {
// FIXME(yoojin): Temporary deprecated. Need new pricing rules.
private async calculateCost(serviceName: string, requestData: string): Promise<number> {
const billingConfig = await this.ain.getValue(Path.app(serviceName).billingConfig());
const token = requestData.split(' ').length;
let cost = token * billingConfig.costPerToken;
Expand Down Expand Up @@ -71,7 +72,7 @@ export default class ServiceController {
return await this.ain.getValue(creditHistoryPath) as creditHistories;
}

async request(serviceName: string, requestData: string) : Promise<string> {
async request(serviceName: string, requestData: any) : Promise<any> {
this.isRunning(serviceName);
const result = await new Promise(async (resolve, reject) => {
const requestKey = Date.now();
Expand Down
6 changes: 4 additions & 2 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export default class Service {
* @returns {number} Estimated cost.
*/
async calculateCost (requestData: string) {
return await this.serviceController.calculateCost(this.serviceName, requestData);
// FIXME(yoojin): Temporary deprecated. Need new pricing rules.
// return await this.serviceController.calculateCost(this.serviceName, requestData);
return 0;
}

/**
Expand Down Expand Up @@ -76,7 +78,7 @@ export default class Service {
* @param {string} requestData String data for request to service.
* @returns {string} Response data from service.
*/
async request(requestData: string) {
async request(requestData: any) {
this.isLoggedIn();
return await this.serviceController.request(this.serviceName, requestData);
}
Expand Down