Skip to content

Commit

Permalink
NO-ISSUE Allow to get x-line-request-id header from all response type
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang-33 committed Dec 28, 2023
1 parent e9fab8b commit 2f10129
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class {{operations.classname}} {
* @see <a href="{{op.externalDocs.url}}">{{op.summary}} Documentation</a>
{% 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 %}> {
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 }}&{% endif %}Types.MessageAPIResponseBase> {
{% if op.isMultipart %}
{% include "./apiBody/multipart.pebble" %}
{% else %}
Expand Down
16 changes: 10 additions & 6 deletions lib/channel-access-token/api/channelAccessTokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ChannelAccessTokenClient {
public async getsAllValidChannelAccessTokenKeyIds(
clientAssertionType: string,
clientAssertion: string,
): Promise<ChannelAccessTokenKeyIdsResponse> {
): Promise<ChannelAccessTokenKeyIdsResponse & Types.MessageAPIResponseBase> {
const queryParams = {
clientAssertionType: clientAssertionType,
clientAssertion: clientAssertion,
Expand All @@ -94,7 +94,9 @@ export class ChannelAccessTokenClient {
grantType?: string,
clientId?: string,
clientSecret?: string,
): Promise<IssueShortLivedChannelAccessTokenResponse> {
): Promise<
IssueShortLivedChannelAccessTokenResponse & Types.MessageAPIResponseBase
> {
const formParams = {
grant_type: grantType,
client_id: clientId,
Expand Down Expand Up @@ -125,7 +127,7 @@ export class ChannelAccessTokenClient {
grantType?: string,
clientAssertionType?: string,
clientAssertion?: string,
): Promise<IssueChannelAccessTokenResponse> {
): Promise<IssueChannelAccessTokenResponse & Types.MessageAPIResponseBase> {
const formParams = {
grant_type: grantType,
client_assertion_type: clientAssertionType,
Expand Down Expand Up @@ -159,7 +161,9 @@ export class ChannelAccessTokenClient {
clientAssertion?: string,
clientId?: string,
clientSecret?: string,
): Promise<IssueStatelessChannelAccessTokenResponse> {
): Promise<
IssueStatelessChannelAccessTokenResponse & Types.MessageAPIResponseBase
> {
const formParams = {
grant_type: grantType,
client_assertion_type: clientAssertionType,
Expand Down Expand Up @@ -236,7 +240,7 @@ export class ChannelAccessTokenClient {
*/
public async verifyChannelToken(
accessToken?: string,
): Promise<VerifyChannelAccessTokenResponse> {
): Promise<VerifyChannelAccessTokenResponse & Types.MessageAPIResponseBase> {
const formParams = {
access_token: accessToken,
};
Expand All @@ -260,7 +264,7 @@ export class ChannelAccessTokenClient {
*/
public async verifyChannelTokenByJWT(
accessToken: string,
): Promise<VerifyChannelAccessTokenResponse> {
): Promise<VerifyChannelAccessTokenResponse & Types.MessageAPIResponseBase> {
const queryParams = {
accessToken: accessToken,
};
Expand Down
14 changes: 9 additions & 5 deletions lib/insight/api/insightClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export class InsightClient {
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-demographic"> Documentation</a>
*/
public async getFriendsDemographics(): Promise<GetFriendsDemographicsResponse> {
public async getFriendsDemographics(): Promise<
GetFriendsDemographicsResponse & Types.MessageAPIResponseBase
> {
const res = this.httpClient.get<GetFriendsDemographicsResponse>(
"/v2/bot/insight/demographic",
);
Expand All @@ -82,7 +84,7 @@ export class InsightClient {
*/
public async getMessageEvent(
requestId: string,
): Promise<GetMessageEventResponse> {
): Promise<GetMessageEventResponse & Types.MessageAPIResponseBase> {
const queryParams = {
requestId: requestId,
};
Expand All @@ -102,7 +104,7 @@ export class InsightClient {
*/
public async getNumberOfFollowers(
date?: string,
): Promise<GetNumberOfFollowersResponse> {
): Promise<GetNumberOfFollowersResponse & Types.MessageAPIResponseBase> {
const queryParams = {
date: date,
};
Expand All @@ -122,7 +124,9 @@ export class InsightClient {
*/
public async getNumberOfMessageDeliveries(
date: string,
): Promise<GetNumberOfMessageDeliveriesResponse> {
): Promise<
GetNumberOfMessageDeliveriesResponse & Types.MessageAPIResponseBase
> {
const queryParams = {
date: date,
};
Expand All @@ -145,7 +149,7 @@ export class InsightClient {
customAggregationUnit: string,
from: string,
to: string,
): Promise<GetStatisticsPerUnitResponse> {
): Promise<GetStatisticsPerUnitResponse & Types.MessageAPIResponseBase> {
const queryParams = {
customAggregationUnit: customAggregationUnit,
from: from,
Expand Down
6 changes: 4 additions & 2 deletions lib/liff/api/liffClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class LiffClient {
*/
public async addLIFFApp(
addLiffAppRequest: AddLiffAppRequest,
): Promise<AddLiffAppResponse> {
): Promise<AddLiffAppResponse & Types.MessageAPIResponseBase> {
const params = addLiffAppRequest;

const res = this.httpClient.post<AddLiffAppResponse>(
Expand Down Expand Up @@ -99,7 +99,9 @@ export class LiffClient {
*
* @see <a href="https://developers.line.biz/en/reference/liff-server/#get-all-liff-apps">Get all LIFF apps Documentation</a>
*/
public async getAllLIFFApps(): Promise<GetAllLiffAppsResponse> {
public async getAllLIFFApps(): Promise<
GetAllLiffAppsResponse & Types.MessageAPIResponseBase
> {
const res = this.httpClient.get<GetAllLiffAppsResponse>("/liff/v1/apps");
return ensureJSON(res);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/manage-audience/api/manageAudienceBlobClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class ManageAudienceBlobClient {
description?: string,
isIfaAudience?: boolean,
uploadDescription?: string,
): Promise<CreateAudienceGroupResponse> {
): Promise<CreateAudienceGroupResponse & Types.MessageAPIResponseBase> {
const form = new FormData();
form.append("description", String(description));
form.append("isIfaAudience", String(isIfaAudience));
Expand Down
18 changes: 12 additions & 6 deletions lib/manage-audience/api/manageAudienceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class ManageAudienceClient {
*/
public async createAudienceGroup(
createAudienceGroupRequest: CreateAudienceGroupRequest,
): Promise<CreateAudienceGroupResponse> {
): Promise<CreateAudienceGroupResponse & Types.MessageAPIResponseBase> {
const params = createAudienceGroupRequest;

const res = this.httpClient.post<CreateAudienceGroupResponse>(
Expand All @@ -128,7 +128,9 @@ export class ManageAudienceClient {
*/
public async createClickBasedAudienceGroup(
createClickBasedAudienceGroupRequest: CreateClickBasedAudienceGroupRequest,
): Promise<CreateClickBasedAudienceGroupResponse> {
): Promise<
CreateClickBasedAudienceGroupResponse & Types.MessageAPIResponseBase
> {
const params = createClickBasedAudienceGroupRequest;

const res = this.httpClient.post<CreateClickBasedAudienceGroupResponse>(
Expand All @@ -145,7 +147,9 @@ export class ManageAudienceClient {
*/
public async createImpBasedAudienceGroup(
createImpBasedAudienceGroupRequest: CreateImpBasedAudienceGroupRequest,
): Promise<CreateImpBasedAudienceGroupResponse> {
): Promise<
CreateImpBasedAudienceGroupResponse & Types.MessageAPIResponseBase
> {
const params = createImpBasedAudienceGroupRequest;

const res = this.httpClient.post<CreateImpBasedAudienceGroupResponse>(
Expand Down Expand Up @@ -179,7 +183,7 @@ export class ManageAudienceClient {
*/
public async getAudienceData(
audienceGroupId: number,
): Promise<GetAudienceDataResponse> {
): Promise<GetAudienceDataResponse & Types.MessageAPIResponseBase> {
const res = this.httpClient.get<GetAudienceDataResponse>(
"/v2/bot/audienceGroup/{audienceGroupId}".replace(
"{audienceGroupId}",
Expand All @@ -193,7 +197,9 @@ export class ManageAudienceClient {
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-authority-level"> Documentation</a>
*/
public async getAudienceGroupAuthorityLevel(): Promise<GetAudienceGroupAuthorityLevelResponse> {
public async getAudienceGroupAuthorityLevel(): Promise<
GetAudienceGroupAuthorityLevelResponse & Types.MessageAPIResponseBase
> {
const res = this.httpClient.get<GetAudienceGroupAuthorityLevelResponse>(
"/v2/bot/audienceGroup/authorityLevel",
);
Expand All @@ -217,7 +223,7 @@ export class ManageAudienceClient {
size?: number,
includesExternalPublicGroups?: boolean,
createRoute?: AudienceGroupCreateRoute,
): Promise<GetAudienceGroupsResponse> {
): Promise<GetAudienceGroupsResponse & Types.MessageAPIResponseBase> {
const queryParams = {
page: page,
description: description,
Expand Down
16 changes: 12 additions & 4 deletions lib/messaging-api/api/messagingApiBlobClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export class MessagingApiBlobClient {
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-content"> Documentation</a>
*/
public async getMessageContent(messageId: string): Promise<Readable> {
public async getMessageContent(
messageId: string,
): Promise<Readable & Types.MessageAPIResponseBase> {
return this.httpClient.getStream(
"/v2/bot/message/{messageId}/content".replace(
"{" + "messageId" + "}",
Expand All @@ -78,7 +80,9 @@ export class MessagingApiBlobClient {
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-image-or-video-preview"> Documentation</a>
*/
public async getMessageContentPreview(messageId: string): Promise<Readable> {
public async getMessageContentPreview(
messageId: string,
): Promise<Readable & Types.MessageAPIResponseBase> {
return this.httpClient.getStream(
"/v2/bot/message/{messageId}/content/preview".replace(
"{" + "messageId" + "}",
Expand All @@ -94,7 +98,9 @@ export class MessagingApiBlobClient {
*/
public async getMessageContentTranscodingByMessageId(
messageId: string,
): Promise<GetMessageContentTranscodingResponse> {
): Promise<
GetMessageContentTranscodingResponse & Types.MessageAPIResponseBase
> {
const res = this.httpClient.get<GetMessageContentTranscodingResponse>(
"/v2/bot/message/{messageId}/content/transcoding".replace(
"{messageId}",
Expand All @@ -109,7 +115,9 @@ export class MessagingApiBlobClient {
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#download-rich-menu-image"> Documentation</a>
*/
public async getRichMenuImage(richMenuId: string): Promise<Readable> {
public async getRichMenuImage(
richMenuId: string,
): Promise<Readable & Types.MessageAPIResponseBase> {
return this.httpClient.getStream(
"/v2/bot/richmenu/{richMenuId}/content".replace(
"{" + "richMenuId" + "}",
Expand Down
Loading

0 comments on commit 2f10129

Please sign in to comment.