Skip to content

Commit

Permalink
Merge branch 'master' into compile-example-project
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang-33 authored Mar 4, 2024
2 parents e268fb4 + 2e59cad commit cba6526
Show file tree
Hide file tree
Showing 14 changed files with 339 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class {{operations.classname}} {
{% endif -%}
*/
public async {{op.nickname}}({% for param in op.allParams %}{{param.paramName}}{% if not param.required %}?{% endif %}: {{param.dataType}}, {% endfor %}) : Promise<{% if op.returnType %}{{ op.returnType }}{% else %}Types.MessageAPIResponseBase{% endif %}> {
return (await this.{{op.nickname}}WithHttpInfo({% for param in op.allParams %}{{param.paramName}}, {% endfor %}))[1];
return (await this.{{op.nickname}}WithHttpInfo({% for param in op.allParams %}{{param.paramName}}, {% endfor %})).body;
}

/**
Expand All @@ -93,7 +93,7 @@ export class {{operations.classname}} {
* @see <a href="{{op.externalDocs.url}}">{{op.summary}} Documentation</a>
{% endif -%}
*/
public async {{op.nickname}}WithHttpInfo({% for param in op.allParams %}{{param.paramName}}{% if not param.required %}?{% endif %}: {{param.dataType}}, {% endfor %}) : Promise<[Response, {% if op.returnType %}{{ op.returnType }}{% else %}Types.MessageAPIResponseBase{% endif %}]> {
public async {{op.nickname}}WithHttpInfo({% for param in op.allParams %}{{param.paramName}}{% if not param.required %}?{% endif %}: {{param.dataType}}, {% endfor %}) : Promise<Types.ApiResponseType<{% if op.returnType %}{{ op.returnType }}{% else %}Types.MessageAPIResponseBase{% endif %}>> {
{% if op.isMultipart %}
{% include "./apiBody/multipart.pebble" %}
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
{% endfor %},
form,
);
return [res, await res.json()];
return {httpResponse: res, body: await res.json()};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.replace('{' + "{{param.baseName}}" + '}', String({{param.paramName}}))
{% endfor %}
);
return [response, convertResponseToReadable(response)];
return {httpResponse: response, body: convertResponseToReadable(response)};
{% else %}
{% if op.hasBodyParam %}const params = {{op.bodyParam.paramName}};
{% elseif op.hasFormParams %}const formParams = {
Expand Down Expand Up @@ -43,5 +43,5 @@
{% elseif op.hasQueryParams %}queryParams,{% endif %}
{% if op.hasHeaderParams %}{headers: headerParams},{% endif %}
);
return [res, await res.json()];
return {httpResponse: res, body: await res.json()};
{% endif %}
48 changes: 24 additions & 24 deletions lib/channel-access-token/api/channelAccessTokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class ChannelAccessTokenClient {
clientAssertionType,
clientAssertion,
)
)[1];
).body;
}

/**
Expand All @@ -89,7 +89,7 @@ export class ChannelAccessTokenClient {
public async getsAllValidChannelAccessTokenKeyIdsWithHttpInfo(
clientAssertionType: string,
clientAssertion: string,
): Promise<[Response, ChannelAccessTokenKeyIdsResponse]> {
): Promise<Types.ApiResponseType<ChannelAccessTokenKeyIdsResponse>> {
const queryParams = {
clientAssertionType: clientAssertionType,
clientAssertion: clientAssertion,
Expand All @@ -99,7 +99,7 @@ export class ChannelAccessTokenClient {
"/oauth2/v2.1/tokens/kid",
queryParams,
);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* Issue short-lived channel access token
Expand All @@ -120,7 +120,7 @@ export class ChannelAccessTokenClient {
clientId,
clientSecret,
)
)[1];
).body;
}

/**
Expand All @@ -136,7 +136,7 @@ export class ChannelAccessTokenClient {
grantType?: string,
clientId?: string,
clientSecret?: string,
): Promise<[Response, IssueShortLivedChannelAccessTokenResponse]> {
): Promise<Types.ApiResponseType<IssueShortLivedChannelAccessTokenResponse>> {
const formParams = {
grant_type: grantType,
client_id: clientId,
Expand All @@ -152,7 +152,7 @@ export class ChannelAccessTokenClient {
"/v2/oauth/accessToken",
formParams,
);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* Issues a channel access token that allows you to specify a desired expiration date. This method lets you use JWT assertion for authentication.
Expand All @@ -173,7 +173,7 @@ export class ChannelAccessTokenClient {
clientAssertionType,
clientAssertion,
)
)[1];
).body;
}

/**
Expand All @@ -189,7 +189,7 @@ export class ChannelAccessTokenClient {
grantType?: string,
clientAssertionType?: string,
clientAssertion?: string,
): Promise<[Response, IssueChannelAccessTokenResponse]> {
): Promise<Types.ApiResponseType<IssueChannelAccessTokenResponse>> {
const formParams = {
grant_type: grantType,
client_assertion_type: clientAssertionType,
Expand All @@ -205,7 +205,7 @@ export class ChannelAccessTokenClient {
"/oauth2/v2.1/token",
formParams,
);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* Issues a new stateless channel access token, which doesn\'t have max active token limit unlike the other token types. The newly issued token is only valid for 15 minutes but can not be revoked until it naturally expires.
Expand All @@ -232,7 +232,7 @@ export class ChannelAccessTokenClient {
clientId,
clientSecret,
)
)[1];
).body;
}

/**
Expand All @@ -252,7 +252,7 @@ export class ChannelAccessTokenClient {
clientAssertion?: string,
clientId?: string,
clientSecret?: string,
): Promise<[Response, IssueStatelessChannelAccessTokenResponse]> {
): Promise<Types.ApiResponseType<IssueStatelessChannelAccessTokenResponse>> {
const formParams = {
grant_type: grantType,
client_assertion_type: clientAssertionType,
Expand All @@ -267,7 +267,7 @@ export class ChannelAccessTokenClient {
});

const res = await this.httpClient.postForm("/oauth2/v3/token", formParams);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* Revoke short-lived or long-lived channel access token
Expand All @@ -278,7 +278,7 @@ export class ChannelAccessTokenClient {
public async revokeChannelToken(
accessToken?: string,
): Promise<Types.MessageAPIResponseBase> {
return (await this.revokeChannelTokenWithHttpInfo(accessToken))[1];
return (await this.revokeChannelTokenWithHttpInfo(accessToken)).body;
}

/**
Expand All @@ -290,7 +290,7 @@ export class ChannelAccessTokenClient {
*/
public async revokeChannelTokenWithHttpInfo(
accessToken?: string,
): Promise<[Response, Types.MessageAPIResponseBase]> {
): Promise<Types.ApiResponseType<Types.MessageAPIResponseBase>> {
const formParams = {
access_token: accessToken,
};
Expand All @@ -301,7 +301,7 @@ export class ChannelAccessTokenClient {
});

const res = await this.httpClient.postForm("/v2/oauth/revoke", formParams);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* Revoke channel access token v2.1
Expand All @@ -322,7 +322,7 @@ export class ChannelAccessTokenClient {
clientSecret,
accessToken,
)
)[1];
).body;
}

/**
Expand All @@ -338,7 +338,7 @@ export class ChannelAccessTokenClient {
clientId?: string,
clientSecret?: string,
accessToken?: string,
): Promise<[Response, Types.MessageAPIResponseBase]> {
): Promise<Types.ApiResponseType<Types.MessageAPIResponseBase>> {
const formParams = {
client_id: clientId,
client_secret: clientSecret,
Expand All @@ -354,7 +354,7 @@ export class ChannelAccessTokenClient {
"/oauth2/v2.1/revoke",
formParams,
);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* Verify the validity of short-lived and long-lived channel access tokens
Expand All @@ -365,7 +365,7 @@ export class ChannelAccessTokenClient {
public async verifyChannelToken(
accessToken?: string,
): Promise<VerifyChannelAccessTokenResponse> {
return (await this.verifyChannelTokenWithHttpInfo(accessToken))[1];
return (await this.verifyChannelTokenWithHttpInfo(accessToken)).body;
}

/**
Expand All @@ -377,7 +377,7 @@ export class ChannelAccessTokenClient {
*/
public async verifyChannelTokenWithHttpInfo(
accessToken?: string,
): Promise<[Response, VerifyChannelAccessTokenResponse]> {
): Promise<Types.ApiResponseType<VerifyChannelAccessTokenResponse>> {
const formParams = {
access_token: accessToken,
};
Expand All @@ -388,7 +388,7 @@ export class ChannelAccessTokenClient {
});

const res = await this.httpClient.postForm("/v2/oauth/verify", formParams);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* You can verify whether a Channel access token with a user-specified expiration (Channel Access Token v2.1) is valid.
Expand All @@ -399,7 +399,7 @@ export class ChannelAccessTokenClient {
public async verifyChannelTokenByJWT(
accessToken: string,
): Promise<VerifyChannelAccessTokenResponse> {
return (await this.verifyChannelTokenByJWTWithHttpInfo(accessToken))[1];
return (await this.verifyChannelTokenByJWTWithHttpInfo(accessToken)).body;
}

/**
Expand All @@ -411,12 +411,12 @@ export class ChannelAccessTokenClient {
*/
public async verifyChannelTokenByJWTWithHttpInfo(
accessToken: string,
): Promise<[Response, VerifyChannelAccessTokenResponse]> {
): Promise<Types.ApiResponseType<VerifyChannelAccessTokenResponse>> {
const queryParams = {
accessToken: accessToken,
};

const res = await this.httpClient.get("/oauth2/v2.1/verify", queryParams);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
}
30 changes: 15 additions & 15 deletions lib/insight/api/insightClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class InsightClient {
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-demographic"> Documentation</a>
*/
public async getFriendsDemographics(): Promise<GetFriendsDemographicsResponse> {
return (await this.getFriendsDemographicsWithHttpInfo())[1];
return (await this.getFriendsDemographicsWithHttpInfo()).body;
}

/**
Expand All @@ -77,10 +77,10 @@ export class InsightClient {
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-demographic"> Documentation</a>
*/
public async getFriendsDemographicsWithHttpInfo(): Promise<
[Response, GetFriendsDemographicsResponse]
Types.ApiResponseType<GetFriendsDemographicsResponse>
> {
const res = await this.httpClient.get("/v2/bot/insight/demographic");
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* Returns statistics about how users interact with narrowcast messages or broadcast messages sent from your LINE Official Account.
Expand All @@ -92,7 +92,7 @@ export class InsightClient {
public async getMessageEvent(
requestId: string,
): Promise<GetMessageEventResponse> {
return (await this.getMessageEventWithHttpInfo(requestId))[1];
return (await this.getMessageEventWithHttpInfo(requestId)).body;
}

/**
Expand All @@ -105,7 +105,7 @@ export class InsightClient {
*/
public async getMessageEventWithHttpInfo(
requestId: string,
): Promise<[Response, GetMessageEventResponse]> {
): Promise<Types.ApiResponseType<GetMessageEventResponse>> {
const queryParams = {
requestId: requestId,
};
Expand All @@ -114,7 +114,7 @@ export class InsightClient {
"/v2/bot/insight/message/event",
queryParams,
);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* Returns the number of users who have added the LINE Official Account on or before a specified date.
Expand All @@ -126,7 +126,7 @@ export class InsightClient {
public async getNumberOfFollowers(
date?: string,
): Promise<GetNumberOfFollowersResponse> {
return (await this.getNumberOfFollowersWithHttpInfo(date))[1];
return (await this.getNumberOfFollowersWithHttpInfo(date)).body;
}

/**
Expand All @@ -139,7 +139,7 @@ export class InsightClient {
*/
public async getNumberOfFollowersWithHttpInfo(
date?: string,
): Promise<[Response, GetNumberOfFollowersResponse]> {
): Promise<Types.ApiResponseType<GetNumberOfFollowersResponse>> {
const queryParams = {
date: date,
};
Expand All @@ -148,7 +148,7 @@ export class InsightClient {
"/v2/bot/insight/followers",
queryParams,
);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* Returns the number of messages sent from LINE Official Account on a specified day.
Expand All @@ -160,7 +160,7 @@ export class InsightClient {
public async getNumberOfMessageDeliveries(
date: string,
): Promise<GetNumberOfMessageDeliveriesResponse> {
return (await this.getNumberOfMessageDeliveriesWithHttpInfo(date))[1];
return (await this.getNumberOfMessageDeliveriesWithHttpInfo(date)).body;
}

/**
Expand All @@ -173,7 +173,7 @@ export class InsightClient {
*/
public async getNumberOfMessageDeliveriesWithHttpInfo(
date: string,
): Promise<[Response, GetNumberOfMessageDeliveriesResponse]> {
): Promise<Types.ApiResponseType<GetNumberOfMessageDeliveriesResponse>> {
const queryParams = {
date: date,
};
Expand All @@ -182,7 +182,7 @@ export class InsightClient {
"/v2/bot/insight/message/delivery",
queryParams,
);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
/**
* You can check the per-unit statistics of how users interact with push messages and multicast messages sent from your LINE Official Account.
Expand All @@ -203,7 +203,7 @@ export class InsightClient {
from,
to,
)
)[1];
).body;
}

/**
Expand All @@ -219,7 +219,7 @@ export class InsightClient {
customAggregationUnit: string,
from: string,
to: string,
): Promise<[Response, GetStatisticsPerUnitResponse]> {
): Promise<Types.ApiResponseType<GetStatisticsPerUnitResponse>> {
const queryParams = {
customAggregationUnit: customAggregationUnit,
from: from,
Expand All @@ -230,6 +230,6 @@ export class InsightClient {
"/v2/bot/insight/message/event/aggregation",
queryParams,
);
return [res, await res.json()];
return { httpResponse: res, body: await res.json() };
}
}
Loading

0 comments on commit cba6526

Please sign in to comment.