-
Notifications
You must be signed in to change notification settings - Fork 395
/
manageAudienceBlobClient.ts
160 lines (147 loc) · 6.17 KB
/
manageAudienceBlobClient.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/**
* LINE Messaging API
* This document describes LINE Messaging API.
*
* The version of the OpenAPI document: 0.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-locals */
import { CreateAudienceGroupResponse } from "../model/createAudienceGroupResponse.js";
import * as Types from "../../types.js";
import { ensureJSON } from "../../utils.js";
import { Readable } from "node:stream";
import HTTPFetchClient, {
convertResponseToReadable,
} from "../../http-fetch.js";
// ===============================================
// This file is autogenerated - Please do not edit
// ===============================================
interface httpClientConfig {
baseURL?: string;
channelAccessToken: string;
// TODO support defaultHeaders?
}
export class ManageAudienceBlobClient {
private httpClient: HTTPFetchClient;
constructor(config: httpClientConfig) {
const baseURL = config.baseURL || "https://api-data.line.me";
this.httpClient = new HTTPFetchClient({
defaultHeaders: {
Authorization: "Bearer " + config.channelAccessToken,
},
baseURL: baseURL,
});
}
private async parseHTTPResponse(response: Response) {
const { LINE_REQUEST_ID_HTTP_HEADER_NAME } = Types;
let resBody: Record<string, any> = {
...(await response.json()),
};
if (response.headers.get(LINE_REQUEST_ID_HTTP_HEADER_NAME)) {
resBody[LINE_REQUEST_ID_HTTP_HEADER_NAME] = response.headers.get(
LINE_REQUEST_ID_HTTP_HEADER_NAME,
);
}
return resBody;
}
/**
* Add user IDs or Identifiers for Advertisers (IFAs) to an audience for uploading user IDs (by file).
* @param file A text file with one user ID or IFA entered per line. Specify text/plain as Content-Type. Max file number: 1 Max number: 1,500,000
* @param audienceGroupId The audience ID.
* @param uploadDescription The description to register with the job
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group-by-file"> Documentation</a>
*/
public async addUserIdsToAudience(
file: Blob,
audienceGroupId?: number,
uploadDescription?: string,
): Promise<Types.MessageAPIResponseBase> {
return (
await this.addUserIdsToAudienceWithHttpInfo(
file,
audienceGroupId,
uploadDescription,
)
).body;
}
/**
* Add user IDs or Identifiers for Advertisers (IFAs) to an audience for uploading user IDs (by file)..
* This method includes HttpInfo object to return additional information.
* @param file A text file with one user ID or IFA entered per line. Specify text/plain as Content-Type. Max file number: 1 Max number: 1,500,000
* @param audienceGroupId The audience ID.
* @param uploadDescription The description to register with the job
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group-by-file"> Documentation</a>
*/
public async addUserIdsToAudienceWithHttpInfo(
file: Blob,
audienceGroupId?: number,
uploadDescription?: string,
): Promise<Types.ApiResponseType<Types.MessageAPIResponseBase>> {
const form = new FormData();
form.append("audienceGroupId", String(audienceGroupId));
form.append("uploadDescription", String(uploadDescription));
form.append("file", file); // file
const res = await this.httpClient.putFormMultipart(
"/v2/bot/audienceGroup/upload/byFile",
form,
);
return { httpResponse: res, body: await res.json() };
}
/**
* Create audience for uploading user IDs (by file).
* @param file A text file with one user ID or IFA entered per line. Specify text/plain as Content-Type. Max file number: 1 Max number: 1,500,000
* @param description The audience\\\'s name. This is case-insensitive, meaning AUDIENCE and audience are considered identical. Max character limit: 120
* @param isIfaAudience To specify recipients by IFAs: set `true`. To specify recipients by user IDs: set `false` or omit isIfaAudience property.
* @param uploadDescription The description to register for the job (in `jobs[].description`).
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group-by-file"> Documentation</a>
*/
public async createAudienceForUploadingUserIds(
file: Blob,
description?: string,
isIfaAudience?: boolean,
uploadDescription?: string,
): Promise<CreateAudienceGroupResponse> {
return (
await this.createAudienceForUploadingUserIdsWithHttpInfo(
file,
description,
isIfaAudience,
uploadDescription,
)
).body;
}
/**
* Create audience for uploading user IDs (by file)..
* This method includes HttpInfo object to return additional information.
* @param file A text file with one user ID or IFA entered per line. Specify text/plain as Content-Type. Max file number: 1 Max number: 1,500,000
* @param description The audience\\\'s name. This is case-insensitive, meaning AUDIENCE and audience are considered identical. Max character limit: 120
* @param isIfaAudience To specify recipients by IFAs: set `true`. To specify recipients by user IDs: set `false` or omit isIfaAudience property.
* @param uploadDescription The description to register for the job (in `jobs[].description`).
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group-by-file"> Documentation</a>
*/
public async createAudienceForUploadingUserIdsWithHttpInfo(
file: Blob,
description?: string,
isIfaAudience?: boolean,
uploadDescription?: string,
): Promise<Types.ApiResponseType<CreateAudienceGroupResponse>> {
const form = new FormData();
form.append("description", String(description));
form.append("isIfaAudience", String(isIfaAudience));
form.append("uploadDescription", String(uploadDescription));
form.append("file", file); // file
const res = await this.httpClient.postFormMultipart(
"/v2/bot/audienceGroup/upload/byFile",
form,
);
return { httpResponse: res, body: await res.json() };
}
}