From ea62b2c5e54e13695ba012d05d765635c16fc861 Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Mon, 6 Nov 2023 15:05:42 +0900 Subject: [PATCH 1/5] Add WithResult methods to take HTTP headers, if needed. --- .../line-bot-sdk-go-generator/api.pebble | 71 +- .../api_channel_access_token.go | 339 ++- linebot/insight/api_insight.go | 182 +- linebot/liff/api_liff.go | 141 +- .../manage_audience/api_manage_audience.go | 420 +++- .../api_manage_audience_blob.go | 103 +- linebot/messaging_api/api_messaging_api.go | 2215 ++++++++++++++--- .../messaging_api/api_messaging_api_blob.go | 174 +- .../handwritten/api_WithHttpInfo_test.go | 43 + linebot/module/api_line_module.go | 152 +- .../module_attach/api_line_module_attach.go | 81 +- linebot/shop/api_shop.go | 36 +- 12 files changed, 3320 insertions(+), 637 deletions(-) create mode 100644 linebot/messaging_api/tests/handwritten/api_WithHttpInfo_test.go diff --git a/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble b/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble index 135f4e4d..66c9bd3d 100644 --- a/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble +++ b/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble @@ -142,6 +142,47 @@ func (client *{{ classname }}) {{ op.operationId }}( {% endif %} {% endfor %} ) ({% if op.isResponseFile %}*http.Response{% elseif op.returnType %}*{{ op.returnType }}{% else %}struct{}{% endif %}, error) { + {% if op.isResponseFile %}_{% else %}response{% endif %}, body, error := client.{{ op.operationId }}WithHttpInfo( + {% for param in op.allParams %} + {% if param.isBodyParam and param.isFile %} + {{ param.paramName }}ContentType, + {{ param.paramName }}Reader, + {% else %} + {{ param.paramName }}, + {% endif %} + {% endfor %} + ) + {% if not op.isResponseFile %} + defer response.Body.Close() + {% endif %} + return body, error +} + +// {{ op.operationId | capitalize }} +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// {{ op.summary }} +// {{ op.notes }} +// Parameters: +{% for param in op.allParams %} + {%- if param.isBodyParam and param.isFile -%} +// {{ param.paramName }}ContentType {{ param.description }} content-type +// {{ param.paramName }}Reader {{ param.description }} file content + {%- else -%} +// {{ param.paramName }} {{ param.description }} + {%- endif %} +{% endfor %} +// You must close the response body when finished with it. +{% if op.externalDocs != null -%}// {{op.externalDocs.url}}{% endif %} +func (client *{{ classname }}) {{ op.operationId }}WithHttpInfo( +{% for param in op.allParams %} + {% if param.isBodyParam and param.isFile %} + {{ param.paramName }}ContentType string, + {{ param.paramName }}Reader io.Reader, + {% else %} + {{ param.paramName }} {% if not (param.isPrimitiveType or param.isEnumRef) %}*{% endif %}{{ param.dataType }}, + {% endif %} +{% endfor %} +) (*http.Response, {% if op.isResponseFile %}*http.Response{% elseif op.returnType %}*{{ op.returnType }}{% else %}struct{}{% endif %}, error) { path := "{{ op.path }}" {% for pp in op.pathParams %} path = strings.Replace(path, "{{ "{" }}{{ pp.paramName }}{{ "}" }}", {% if pp.isInteger or pp.isLong %}strconv.FormatInt({{ pp.paramName }}, 10){% else %}{{ pp.paramName }}{% endif %}, -1) @@ -150,19 +191,19 @@ func (client *{{ classname }}) {{ op.operationId }}( log.Printf("Sending request: method={{ op.httpMethod }} path=%s bodyContentType=%s\n", path, {{ op.bodyParam.paramName }}ContentType) req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), {{ op.bodyParam.paramName }}Reader) if err != nil { - return {{ nilval }}, err + return nil, {{ nilval }}, err } req.Header.Set("Content-Type", {{ op.bodyParam.paramName }}ContentType) {% elseif op.bodyParam != null %} var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode({{ op.bodyParam.paramName }}); err != nil { - return {{ nilval }}, err + return nil, {{ nilval }}, err } log.Printf("Sending request: method={{ op.httpMethod }} path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), &buf) if err != nil { - return {{ nilval }}, err + return nil, {{ nilval }}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") {% elseif op.hasFormParams and op.isMultipart %} @@ -172,7 +213,7 @@ func (client *{{ classname }}) {{ op.operationId }}( {% if fp.isFile %} fileWriter, err := writer.CreateFormFile("{{ fp.baseName }}", {{ fp.paramName }}.Name()) if err != nil { - return {{ nilval }}, err + return nil, {{ nilval }}, err } io.Copy(fileWriter, {{ fp.paramName }}) {% else %} @@ -181,13 +222,13 @@ func (client *{{ classname }}) {{ op.operationId }}( {% endfor %} err = writer.Close() if err != nil { - return {{ nilval }}, err + return nil, {{ nilval }}, err } log.Printf("Sending request: method={{ op.httpMethod }} path=%s\n", path) req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), body) if err != nil { - return {{ nilval }}, err + return nil, {{ nilval }}, err } req.Header.Set("Content-Type", writer.FormDataContentType()) {% elseif op.hasFormParams %} @@ -202,14 +243,14 @@ func (client *{{ classname }}) {{ op.operationId }}( log.Printf("Sending request: method={{ op.httpMethod }} path=%s body=%s\n", path, buf) req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), body) if err != nil { - return {{ nilval }}, err + return nil, {{ nilval }}, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") {% else %} log.Printf("Sending request: method={{ op.httpMethod }} path=%s\n", path) req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), nil) if err != nil { - return {{ nilval }}, err + return nil, {{ nilval }}, err } {% endif %} @@ -229,19 +270,19 @@ func (client *{{ classname }}) {{ op.operationId }}( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return {{ nilval }}, err + return res, {{ nilval }}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return {{ nilval }}, fmt.Errorf("failed to read response body: %w", err) + return res, {{ nilval }}, fmt.Errorf("failed to read response body: %w", err) } - return {{ nilval }}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, {{ nilval }}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } {% if op.isResponseFile %} - return res, nil + return res, res, nil {% else %} defer res.Body.Close() @@ -249,11 +290,11 @@ func (client *{{ classname }}) {{ op.operationId }}( decoder := json.NewDecoder(res.Body) result := {{ op.returnType }}{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil {% else %} - return struct{}{}, nil + return res, struct{}{}, nil {% endif %} {% endif %} } diff --git a/linebot/channel_access_token/api_channel_access_token.go b/linebot/channel_access_token/api_channel_access_token.go index edbfc12e..5507e0b8 100644 --- a/linebot/channel_access_token/api_channel_access_token.go +++ b/linebot/channel_access_token/api_channel_access_token.go @@ -129,12 +129,41 @@ func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIds( clientAssertion string, ) (*ChannelAccessTokenKeyIdsResponse, error) { + response, body, error := client.GetsAllValidChannelAccessTokenKeyIdsWithHttpInfo( + + clientAssertionType, + + clientAssertion, + ) + + defer response.Body.Close() + + return body, error +} + +// GetsAllValidChannelAccessTokenKeyIds +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Gets all valid channel access token key IDs. +// Parameters: +// clientAssertionType `urn:ietf:params:oauth:client-assertion-type:jwt-bearer` +// clientAssertion A JSON Web Token (JWT) (opens new window)the client needs to create and sign with the private key. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-all-valid-channel-access-token-key-ids-v2-1 +func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIdsWithHttpInfo( + + clientAssertionType string, + + clientAssertion string, + +) (*http.Response, *ChannelAccessTokenKeyIdsResponse, error) { path := "/oauth2/v2.1/tokens/kid" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -147,15 +176,15 @@ func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIds( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -163,9 +192,9 @@ func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIds( decoder := json.NewDecoder(res.Body) result := ChannelAccessTokenKeyIdsResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -187,6 +216,40 @@ func (client *ChannelAccessTokenAPI) IssueChannelToken( clientSecret string, ) (*IssueShortLivedChannelAccessTokenResponse, error) { + response, body, error := client.IssueChannelTokenWithHttpInfo( + + grantType, + + clientId, + + clientSecret, + ) + + defer response.Body.Close() + + return body, error +} + +// IssueChannelToken +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Issue short-lived channel access token +// Parameters: +// grantType `client_credentials` +// clientId Channel ID. +// clientSecret Channel secret. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#issue-shortlived-channel-access-token +func (client *ChannelAccessTokenAPI) IssueChannelTokenWithHttpInfo( + + grantType string, + + clientId string, + + clientSecret string, + +) (*http.Response, *IssueShortLivedChannelAccessTokenResponse, error) { path := "/v2/oauth/accessToken" vs := url.Values{ @@ -200,7 +263,7 @@ func (client *ChannelAccessTokenAPI) IssueChannelToken( log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf) req, err := http.NewRequest(http.MethodPost, client.Url(path), body) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") @@ -208,15 +271,15 @@ func (client *ChannelAccessTokenAPI) IssueChannelToken( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -224,9 +287,9 @@ func (client *ChannelAccessTokenAPI) IssueChannelToken( decoder := json.NewDecoder(res.Body) result := IssueShortLivedChannelAccessTokenResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -248,6 +311,40 @@ func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWT( clientAssertion string, ) (*IssueChannelAccessTokenResponse, error) { + response, body, error := client.IssueChannelTokenByJWTWithHttpInfo( + + grantType, + + clientAssertionType, + + clientAssertion, + ) + + defer response.Body.Close() + + return body, error +} + +// IssueChannelTokenByJWT +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Issues a channel access token that allows you to specify a desired expiration date. This method lets you use JWT assertion for authentication. +// Parameters: +// grantType client_credentials +// clientAssertionType urn:ietf:params:oauth:client-assertion-type:jwt-bearer +// clientAssertion A JSON Web Token the client needs to create and sign with the private key of the Assertion Signing Key. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#issue-channel-access-token-v2-1 +func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWTWithHttpInfo( + + grantType string, + + clientAssertionType string, + + clientAssertion string, + +) (*http.Response, *IssueChannelAccessTokenResponse, error) { path := "/oauth2/v2.1/token" vs := url.Values{ @@ -261,7 +358,7 @@ func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWT( log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf) req, err := http.NewRequest(http.MethodPost, client.Url(path), body) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") @@ -269,15 +366,15 @@ func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWT( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -285,9 +382,9 @@ func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWT( decoder := json.NewDecoder(res.Body) result := IssueChannelAccessTokenResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -315,6 +412,50 @@ func (client *ChannelAccessTokenAPI) IssueStatelessChannelToken( clientSecret string, ) (*IssueStatelessChannelAccessTokenResponse, error) { + response, body, error := client.IssueStatelessChannelTokenWithHttpInfo( + + grantType, + + clientAssertionType, + + clientAssertion, + + clientId, + + clientSecret, + ) + + defer response.Body.Close() + + return body, error +} + +// IssueStatelessChannelToken +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// 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. +// Parameters: +// grantType `client_credentials` +// clientAssertionType URL-encoded value of `urn:ietf:params:oauth:client-assertion-type:jwt-bearer` +// clientAssertion A JSON Web Token the client needs to create and sign with the private key of the Assertion Signing Key. +// clientId Channel ID. +// clientSecret Channel secret. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#issue-stateless-channel-access-token +func (client *ChannelAccessTokenAPI) IssueStatelessChannelTokenWithHttpInfo( + + grantType string, + + clientAssertionType string, + + clientAssertion string, + + clientId string, + + clientSecret string, + +) (*http.Response, *IssueStatelessChannelAccessTokenResponse, error) { path := "/oauth2/v3/token" vs := url.Values{ @@ -330,7 +471,7 @@ func (client *ChannelAccessTokenAPI) IssueStatelessChannelToken( log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf) req, err := http.NewRequest(http.MethodPost, client.Url(path), body) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") @@ -338,15 +479,15 @@ func (client *ChannelAccessTokenAPI) IssueStatelessChannelToken( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -354,9 +495,9 @@ func (client *ChannelAccessTokenAPI) IssueStatelessChannelToken( decoder := json.NewDecoder(res.Body) result := IssueStatelessChannelAccessTokenResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -372,6 +513,30 @@ func (client *ChannelAccessTokenAPI) RevokeChannelToken( accessToken string, ) (struct{}, error) { + response, body, error := client.RevokeChannelTokenWithHttpInfo( + + accessToken, + ) + + defer response.Body.Close() + + return body, error +} + +// RevokeChannelToken +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Revoke short-lived or long-lived channel access token +// Parameters: +// accessToken Channel access token + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#revoke-longlived-or-shortlived-channel-access-token +func (client *ChannelAccessTokenAPI) RevokeChannelTokenWithHttpInfo( + + accessToken string, + +) (*http.Response, struct{}, error) { path := "/v2/oauth/revoke" vs := url.Values{ @@ -383,7 +548,7 @@ func (client *ChannelAccessTokenAPI) RevokeChannelToken( log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf) req, err := http.NewRequest(http.MethodPost, client.Url(path), body) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") @@ -391,20 +556,20 @@ func (client *ChannelAccessTokenAPI) RevokeChannelToken( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -426,6 +591,40 @@ func (client *ChannelAccessTokenAPI) RevokeChannelTokenByJWT( accessToken string, ) (struct{}, error) { + response, body, error := client.RevokeChannelTokenByJWTWithHttpInfo( + + clientId, + + clientSecret, + + accessToken, + ) + + defer response.Body.Close() + + return body, error +} + +// RevokeChannelTokenByJWT +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Revoke channel access token v2.1 +// Parameters: +// clientId Channel ID +// clientSecret Channel Secret +// accessToken Channel access token + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#revoke-channel-access-token-v2-1 +func (client *ChannelAccessTokenAPI) RevokeChannelTokenByJWTWithHttpInfo( + + clientId string, + + clientSecret string, + + accessToken string, + +) (*http.Response, struct{}, error) { path := "/oauth2/v2.1/revoke" vs := url.Values{ @@ -439,7 +638,7 @@ func (client *ChannelAccessTokenAPI) RevokeChannelTokenByJWT( log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf) req, err := http.NewRequest(http.MethodPost, client.Url(path), body) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") @@ -447,20 +646,20 @@ func (client *ChannelAccessTokenAPI) RevokeChannelTokenByJWT( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -476,6 +675,30 @@ func (client *ChannelAccessTokenAPI) VerifyChannelToken( accessToken string, ) (*VerifyChannelAccessTokenResponse, error) { + response, body, error := client.VerifyChannelTokenWithHttpInfo( + + accessToken, + ) + + defer response.Body.Close() + + return body, error +} + +// VerifyChannelToken +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Verify the validity of short-lived and long-lived channel access tokens +// Parameters: +// accessToken A short-lived or long-lived channel access token. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#verfiy-channel-access-token +func (client *ChannelAccessTokenAPI) VerifyChannelTokenWithHttpInfo( + + accessToken string, + +) (*http.Response, *VerifyChannelAccessTokenResponse, error) { path := "/v2/oauth/verify" vs := url.Values{ @@ -487,7 +710,7 @@ func (client *ChannelAccessTokenAPI) VerifyChannelToken( log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf) req, err := http.NewRequest(http.MethodPost, client.Url(path), body) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") @@ -495,15 +718,15 @@ func (client *ChannelAccessTokenAPI) VerifyChannelToken( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -511,9 +734,9 @@ func (client *ChannelAccessTokenAPI) VerifyChannelToken( decoder := json.NewDecoder(res.Body) result := VerifyChannelAccessTokenResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -529,12 +752,36 @@ func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWT( accessToken string, ) (*VerifyChannelAccessTokenResponse, error) { + response, body, error := client.VerifyChannelTokenByJWTWithHttpInfo( + + accessToken, + ) + + defer response.Body.Close() + + return body, error +} + +// VerifyChannelTokenByJWT +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// You can verify whether a Channel access token with a user-specified expiration (Channel Access Token v2.1) is valid. +// Parameters: +// accessToken Channel access token with a user-specified expiration (Channel Access Token v2.1). + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#verfiy-channel-access-token-v2-1 +func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWTWithHttpInfo( + + accessToken string, + +) (*http.Response, *VerifyChannelAccessTokenResponse, error) { path := "/oauth2/v2.1/verify" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -546,15 +793,15 @@ func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWT( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -562,8 +809,8 @@ func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWT( decoder := json.NewDecoder(res.Body) result := VerifyChannelAccessTokenResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } diff --git a/linebot/insight/api_insight.go b/linebot/insight/api_insight.go index 00ad3c54..2348024c 100644 --- a/linebot/insight/api_insight.go +++ b/linebot/insight/api_insight.go @@ -120,27 +120,43 @@ func WithEndpoint(endpoint string) InsightAPIOption { // https://developers.line.biz/en/reference/messaging-api/#get-demographic func (client *InsightAPI) GetFriendsDemographics() (*GetFriendsDemographicsResponse, error) { + response, body, error := client.GetFriendsDemographicsWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetFriendsDemographics +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Retrieves the demographic attributes for a LINE Official Account's friends.You can only retrieve information about friends for LINE Official Accounts created by users in Japan (JP), Thailand (TH), Taiwan (TW) and Indonesia (ID). +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-demographic +func (client *InsightAPI) GetFriendsDemographicsWithHttpInfo() (*http.Response, *GetFriendsDemographicsResponse, error) { path := "/v2/bot/insight/demographic" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -148,9 +164,9 @@ func (client *InsightAPI) GetFriendsDemographics() (*GetFriendsDemographicsRespo decoder := json.NewDecoder(res.Body) result := GetFriendsDemographicsResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -166,12 +182,36 @@ func (client *InsightAPI) GetMessageEvent( requestId string, ) (*GetMessageEventResponse, error) { + response, body, error := client.GetMessageEventWithHttpInfo( + + requestId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetMessageEvent +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// Get user interaction statistics +// Returns statistics about how users interact with narrowcast messages or broadcast messages sent from your LINE Official Account. +// Parameters: +// requestId Request ID of a narrowcast message or broadcast message. Each Messaging API request has a request ID. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-message-event +func (client *InsightAPI) GetMessageEventWithHttpInfo( + + requestId string, + +) (*http.Response, *GetMessageEventResponse, error) { path := "/v2/bot/insight/message/event" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -183,15 +223,15 @@ func (client *InsightAPI) GetMessageEvent( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -199,9 +239,9 @@ func (client *InsightAPI) GetMessageEvent( decoder := json.NewDecoder(res.Body) result := GetMessageEventResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -217,12 +257,36 @@ func (client *InsightAPI) GetNumberOfFollowers( date string, ) (*GetNumberOfFollowersResponse, error) { + response, body, error := client.GetNumberOfFollowersWithHttpInfo( + + date, + ) + + defer response.Body.Close() + + return body, error +} + +// GetNumberOfFollowers +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// Get number of followers +// Returns the number of users who have added the LINE Official Account on or before a specified date. +// Parameters: +// date Date for which to retrieve the number of followers. Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-number-of-followers +func (client *InsightAPI) GetNumberOfFollowersWithHttpInfo( + + date string, + +) (*http.Response, *GetNumberOfFollowersResponse, error) { path := "/v2/bot/insight/followers" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -234,15 +298,15 @@ func (client *InsightAPI) GetNumberOfFollowers( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -250,9 +314,9 @@ func (client *InsightAPI) GetNumberOfFollowers( decoder := json.NewDecoder(res.Body) result := GetNumberOfFollowersResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -268,12 +332,36 @@ func (client *InsightAPI) GetNumberOfMessageDeliveries( date string, ) (*GetNumberOfMessageDeliveriesResponse, error) { + response, body, error := client.GetNumberOfMessageDeliveriesWithHttpInfo( + + date, + ) + + defer response.Body.Close() + + return body, error +} + +// GetNumberOfMessageDeliveries +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// Get number of message deliveries +// Returns the number of messages sent from LINE Official Account on a specified day. +// Parameters: +// date Date for which to retrieve number of sent messages. - Format: yyyyMMdd (e.g. 20191231) - Timezone: UTC+9 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-number-of-delivery-messages +func (client *InsightAPI) GetNumberOfMessageDeliveriesWithHttpInfo( + + date string, + +) (*http.Response, *GetNumberOfMessageDeliveriesResponse, error) { path := "/v2/bot/insight/message/delivery" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -285,15 +373,15 @@ func (client *InsightAPI) GetNumberOfMessageDeliveries( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -301,9 +389,9 @@ func (client *InsightAPI) GetNumberOfMessageDeliveries( decoder := json.NewDecoder(res.Body) result := GetNumberOfMessageDeliveriesResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -325,12 +413,46 @@ func (client *InsightAPI) GetStatisticsPerUnit( to string, ) (*GetStatisticsPerUnitResponse, error) { + response, body, error := client.GetStatisticsPerUnitWithHttpInfo( + + customAggregationUnit, + + from, + + to, + ) + + defer response.Body.Close() + + return body, error +} + +// GetStatisticsPerUnit +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// You can check the per-unit statistics of how users interact with push messages and multicast messages sent from your LINE Official Account. +// Parameters: +// customAggregationUnit Name of aggregation unit specified when sending the message. Case-sensitive. For example, `Promotion_a` and `Promotion_A` are regarded as different unit names. +// from Start date of aggregation period. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9 +// to End date of aggregation period. The end date can be specified for up to 30 days later. For example, if the start date is 20210301, the latest end date is 20210331. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-statistics-per-unit +func (client *InsightAPI) GetStatisticsPerUnitWithHttpInfo( + + customAggregationUnit string, + + from string, + + to string, + +) (*http.Response, *GetStatisticsPerUnitResponse, error) { path := "/v2/bot/insight/message/event/aggregation" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -344,15 +466,15 @@ func (client *InsightAPI) GetStatisticsPerUnit( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -360,8 +482,8 @@ func (client *InsightAPI) GetStatisticsPerUnit( decoder := json.NewDecoder(res.Body) result := GetStatisticsPerUnitResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } diff --git a/linebot/liff/api_liff.go b/linebot/liff/api_liff.go index 9f6b42c8..6235cabe 100644 --- a/linebot/liff/api_liff.go +++ b/linebot/liff/api_liff.go @@ -127,17 +127,41 @@ func (client *LiffAPI) AddLIFFApp( addLiffAppRequest *AddLiffAppRequest, ) (*AddLiffAppResponse, error) { + response, body, error := client.AddLIFFAppWithHttpInfo( + + addLiffAppRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// AddLIFFApp +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Adding the LIFF app to a channel +// Parameters: +// addLiffAppRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/liff-server/#add-liff-app +func (client *LiffAPI) AddLIFFAppWithHttpInfo( + + addLiffAppRequest *AddLiffAppRequest, + +) (*http.Response, *AddLiffAppResponse, error) { path := "/liff/v1/apps" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(addLiffAppRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -145,15 +169,15 @@ func (client *LiffAPI) AddLIFFApp( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -161,9 +185,9 @@ func (client *LiffAPI) AddLIFFApp( decoder := json.NewDecoder(res.Body) result := AddLiffAppResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -179,6 +203,30 @@ func (client *LiffAPI) DeleteLIFFApp( liffId string, ) (struct{}, error) { + response, body, error := client.DeleteLIFFAppWithHttpInfo( + + liffId, + ) + + defer response.Body.Close() + + return body, error +} + +// DeleteLIFFApp +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// Delete LIFF app from a channel +// Deletes a LIFF app from a channel. +// Parameters: +// liffId ID of the LIFF app to be updated + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/liff-server/#delete-liff-app +func (client *LiffAPI) DeleteLIFFAppWithHttpInfo( + + liffId string, + +) (*http.Response, struct{}, error) { path := "/liff/v1/apps/{liffId}" path = strings.Replace(path, "{liffId}", liffId, -1) @@ -186,27 +234,27 @@ func (client *LiffAPI) DeleteLIFFApp( log.Printf("Sending request: method=Delete path=%s\n", path) req, err := http.NewRequest(http.MethodDelete, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -217,27 +265,43 @@ func (client *LiffAPI) DeleteLIFFApp( // https://developers.line.biz/en/reference/liff-server/#get-all-liff-apps func (client *LiffAPI) GetAllLIFFApps() (*GetAllLiffAppsResponse, error) { + response, body, error := client.GetAllLIFFAppsWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetAllLIFFApps +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// Get all LIFF apps +// Gets information on all the LIFF apps added to the channel. +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/liff-server/#get-all-liff-apps +func (client *LiffAPI) GetAllLIFFAppsWithHttpInfo() (*http.Response, *GetAllLiffAppsResponse, error) { path := "/liff/v1/apps" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -245,9 +309,9 @@ func (client *LiffAPI) GetAllLIFFApps() (*GetAllLiffAppsResponse, error) { decoder := json.NewDecoder(res.Body) result := GetAllLiffAppsResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -266,6 +330,35 @@ func (client *LiffAPI) UpdateLIFFApp( updateLiffAppRequest *UpdateLiffAppRequest, ) (struct{}, error) { + response, body, error := client.UpdateLIFFAppWithHttpInfo( + + liffId, + + updateLiffAppRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// UpdateLIFFApp +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Update LIFF app settings +// Parameters: +// liffId ID of the LIFF app to be updated +// updateLiffAppRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/liff-server/#update-liff-app +func (client *LiffAPI) UpdateLIFFAppWithHttpInfo( + + liffId string, + + updateLiffAppRequest *UpdateLiffAppRequest, + +) (*http.Response, struct{}, error) { path := "/liff/v1/apps/{liffId}" path = strings.Replace(path, "{liffId}", liffId, -1) @@ -273,12 +366,12 @@ func (client *LiffAPI) UpdateLIFFApp( var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(updateLiffAppRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Put path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPut, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -286,19 +379,19 @@ func (client *LiffAPI) UpdateLIFFApp( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } diff --git a/linebot/manage_audience/api_manage_audience.go b/linebot/manage_audience/api_manage_audience.go index 815f9ee1..52cd8eda 100644 --- a/linebot/manage_audience/api_manage_audience.go +++ b/linebot/manage_audience/api_manage_audience.go @@ -128,6 +128,30 @@ func (client *ManageAudienceAPI) ActivateAudienceGroup( audienceGroupId int64, ) (struct{}, error) { + response, body, error := client.ActivateAudienceGroupWithHttpInfo( + + audienceGroupId, + ) + + defer response.Body.Close() + + return body, error +} + +// ActivateAudienceGroup +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Activate audience +// Parameters: +// audienceGroupId The audience ID. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#activate-audience-group +func (client *ManageAudienceAPI) ActivateAudienceGroupWithHttpInfo( + + audienceGroupId int64, + +) (*http.Response, struct{}, error) { path := "/v2/bot/audienceGroup/{audienceGroupId}/activate" path = strings.Replace(path, "{audienceGroupId}", strconv.FormatInt(audienceGroupId, 10), -1) @@ -135,27 +159,27 @@ func (client *ManageAudienceAPI) ActivateAudienceGroup( log.Printf("Sending request: method=Put path=%s\n", path) req, err := http.NewRequest(http.MethodPut, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -171,17 +195,41 @@ func (client *ManageAudienceAPI) AddAudienceToAudienceGroup( addAudienceToAudienceGroupRequest *AddAudienceToAudienceGroupRequest, ) (struct{}, error) { + response, body, error := client.AddAudienceToAudienceGroupWithHttpInfo( + + addAudienceToAudienceGroupRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// AddAudienceToAudienceGroup +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Add user IDs or Identifiers for Advertisers (IFAs) to an audience for uploading user IDs (by JSON) +// Parameters: +// addAudienceToAudienceGroupRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group +func (client *ManageAudienceAPI) AddAudienceToAudienceGroupWithHttpInfo( + + addAudienceToAudienceGroupRequest *AddAudienceToAudienceGroupRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/audienceGroup/upload" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(addAudienceToAudienceGroupRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Put path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPut, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -189,20 +237,20 @@ func (client *ManageAudienceAPI) AddAudienceToAudienceGroup( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -218,17 +266,41 @@ func (client *ManageAudienceAPI) CreateAudienceGroup( createAudienceGroupRequest *CreateAudienceGroupRequest, ) (*CreateAudienceGroupResponse, error) { + response, body, error := client.CreateAudienceGroupWithHttpInfo( + + createAudienceGroupRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// CreateAudienceGroup +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Create audience for uploading user IDs (by JSON) +// Parameters: +// createAudienceGroupRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group +func (client *ManageAudienceAPI) CreateAudienceGroupWithHttpInfo( + + createAudienceGroupRequest *CreateAudienceGroupRequest, + +) (*http.Response, *CreateAudienceGroupResponse, error) { path := "/v2/bot/audienceGroup/upload" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(createAudienceGroupRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -236,15 +308,15 @@ func (client *ManageAudienceAPI) CreateAudienceGroup( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -252,9 +324,9 @@ func (client *ManageAudienceAPI) CreateAudienceGroup( decoder := json.NewDecoder(res.Body) result := CreateAudienceGroupResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -270,17 +342,41 @@ func (client *ManageAudienceAPI) CreateClickBasedAudienceGroup( createClickBasedAudienceGroupRequest *CreateClickBasedAudienceGroupRequest, ) (*CreateClickBasedAudienceGroupResponse, error) { + response, body, error := client.CreateClickBasedAudienceGroupWithHttpInfo( + + createClickBasedAudienceGroupRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// CreateClickBasedAudienceGroup +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Create audience for click-based retargeting +// Parameters: +// createClickBasedAudienceGroupRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#create-click-audience-group +func (client *ManageAudienceAPI) CreateClickBasedAudienceGroupWithHttpInfo( + + createClickBasedAudienceGroupRequest *CreateClickBasedAudienceGroupRequest, + +) (*http.Response, *CreateClickBasedAudienceGroupResponse, error) { path := "/v2/bot/audienceGroup/click" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(createClickBasedAudienceGroupRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -288,15 +384,15 @@ func (client *ManageAudienceAPI) CreateClickBasedAudienceGroup( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -304,9 +400,9 @@ func (client *ManageAudienceAPI) CreateClickBasedAudienceGroup( decoder := json.NewDecoder(res.Body) result := CreateClickBasedAudienceGroupResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -322,17 +418,41 @@ func (client *ManageAudienceAPI) CreateImpBasedAudienceGroup( createImpBasedAudienceGroupRequest *CreateImpBasedAudienceGroupRequest, ) (*CreateImpBasedAudienceGroupResponse, error) { + response, body, error := client.CreateImpBasedAudienceGroupWithHttpInfo( + + createImpBasedAudienceGroupRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// CreateImpBasedAudienceGroup +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Create audience for impression-based retargeting +// Parameters: +// createImpBasedAudienceGroupRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#create-imp-audience-group +func (client *ManageAudienceAPI) CreateImpBasedAudienceGroupWithHttpInfo( + + createImpBasedAudienceGroupRequest *CreateImpBasedAudienceGroupRequest, + +) (*http.Response, *CreateImpBasedAudienceGroupResponse, error) { path := "/v2/bot/audienceGroup/imp" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(createImpBasedAudienceGroupRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -340,15 +460,15 @@ func (client *ManageAudienceAPI) CreateImpBasedAudienceGroup( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -356,9 +476,9 @@ func (client *ManageAudienceAPI) CreateImpBasedAudienceGroup( decoder := json.NewDecoder(res.Body) result := CreateImpBasedAudienceGroupResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -374,6 +494,30 @@ func (client *ManageAudienceAPI) DeleteAudienceGroup( audienceGroupId int64, ) (struct{}, error) { + response, body, error := client.DeleteAudienceGroupWithHttpInfo( + + audienceGroupId, + ) + + defer response.Body.Close() + + return body, error +} + +// DeleteAudienceGroup +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Delete audience +// Parameters: +// audienceGroupId The audience ID. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#delete-audience-group +func (client *ManageAudienceAPI) DeleteAudienceGroupWithHttpInfo( + + audienceGroupId int64, + +) (*http.Response, struct{}, error) { path := "/v2/bot/audienceGroup/{audienceGroupId}" path = strings.Replace(path, "{audienceGroupId}", strconv.FormatInt(audienceGroupId, 10), -1) @@ -381,27 +525,27 @@ func (client *ManageAudienceAPI) DeleteAudienceGroup( log.Printf("Sending request: method=Delete path=%s\n", path) req, err := http.NewRequest(http.MethodDelete, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -417,6 +561,30 @@ func (client *ManageAudienceAPI) GetAudienceData( audienceGroupId int64, ) (*GetAudienceDataResponse, error) { + response, body, error := client.GetAudienceDataWithHttpInfo( + + audienceGroupId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetAudienceData +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Gets audience data. +// Parameters: +// audienceGroupId The audience ID. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-audience-group +func (client *ManageAudienceAPI) GetAudienceDataWithHttpInfo( + + audienceGroupId int64, + +) (*http.Response, *GetAudienceDataResponse, error) { path := "/v2/bot/audienceGroup/{audienceGroupId}" path = strings.Replace(path, "{audienceGroupId}", strconv.FormatInt(audienceGroupId, 10), -1) @@ -424,22 +592,22 @@ func (client *ManageAudienceAPI) GetAudienceData( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -447,9 +615,9 @@ func (client *ManageAudienceAPI) GetAudienceData( decoder := json.NewDecoder(res.Body) result := GetAudienceDataResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -460,27 +628,43 @@ func (client *ManageAudienceAPI) GetAudienceData( // https://developers.line.biz/en/reference/messaging-api/#get-authority-level func (client *ManageAudienceAPI) GetAudienceGroupAuthorityLevel() (*GetAudienceGroupAuthorityLevelResponse, error) { + response, body, error := client.GetAudienceGroupAuthorityLevelWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetAudienceGroupAuthorityLevel +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get the authority level of the audience +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-authority-level +func (client *ManageAudienceAPI) GetAudienceGroupAuthorityLevelWithHttpInfo() (*http.Response, *GetAudienceGroupAuthorityLevelResponse, error) { path := "/v2/bot/audienceGroup/authorityLevel" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -488,9 +672,9 @@ func (client *ManageAudienceAPI) GetAudienceGroupAuthorityLevel() (*GetAudienceG decoder := json.NewDecoder(res.Body) result := GetAudienceGroupAuthorityLevelResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -521,12 +705,61 @@ func (client *ManageAudienceAPI) GetAudienceGroups( createRoute AudienceGroupCreateRoute, ) (*GetAudienceGroupsResponse, error) { + response, body, error := client.GetAudienceGroupsWithHttpInfo( + + page, + + description, + + status, + + size, + + includesExternalPublicGroups, + + createRoute, + ) + + defer response.Body.Close() + + return body, error +} + +// GetAudienceGroups +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Gets data for more than one audience. +// Parameters: +// page The page to return when getting (paginated) results. Must be 1 or higher. +// description The name of the audience(s) to return. You can search for partial matches. This is case-insensitive, meaning AUDIENCE and audience are considered identical. If omitted, the name of the audience(s) will not be used as a search criterion. +// status The status of the audience(s) to return. If omitted, the status of the audience(s) will not be used as a search criterion. +// size The number of audiences per page. Default: 20 Max: 40 +// includesExternalPublicGroups true (default): Get public audiences created in all channels linked to the same bot. false: Get audiences created in the same channel. +// createRoute How the audience was created. If omitted, all audiences are included. `OA_MANAGER`: Return only audiences created with LINE Official Account Manager (opens new window). `MESSAGING_API`: Return only audiences created with Messaging API. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-audience-groups +func (client *ManageAudienceAPI) GetAudienceGroupsWithHttpInfo( + + page int64, + + description string, + + status AudienceGroupStatus, + + size int64, + + includesExternalPublicGroups bool, + + createRoute AudienceGroupCreateRoute, + +) (*http.Response, *GetAudienceGroupsResponse, error) { path := "/v2/bot/audienceGroup/list" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -543,15 +776,15 @@ func (client *ManageAudienceAPI) GetAudienceGroups( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -559,9 +792,9 @@ func (client *ManageAudienceAPI) GetAudienceGroups( decoder := json.NewDecoder(res.Body) result := GetAudienceGroupsResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -577,17 +810,41 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupAuthorityLevel( updateAudienceGroupAuthorityLevelRequest *UpdateAudienceGroupAuthorityLevelRequest, ) (struct{}, error) { + response, body, error := client.UpdateAudienceGroupAuthorityLevelWithHttpInfo( + + updateAudienceGroupAuthorityLevelRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// UpdateAudienceGroupAuthorityLevel +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Change the authority level of the audience +// Parameters: +// updateAudienceGroupAuthorityLevelRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#change-authority-level +func (client *ManageAudienceAPI) UpdateAudienceGroupAuthorityLevelWithHttpInfo( + + updateAudienceGroupAuthorityLevelRequest *UpdateAudienceGroupAuthorityLevelRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/audienceGroup/authorityLevel" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(updateAudienceGroupAuthorityLevelRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Put path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPut, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -595,20 +852,20 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupAuthorityLevel( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -627,6 +884,35 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupDescription( updateAudienceGroupDescriptionRequest *UpdateAudienceGroupDescriptionRequest, ) (struct{}, error) { + response, body, error := client.UpdateAudienceGroupDescriptionWithHttpInfo( + + audienceGroupId, + + updateAudienceGroupDescriptionRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// UpdateAudienceGroupDescription +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Renames an existing audience. +// Parameters: +// audienceGroupId The audience ID. +// updateAudienceGroupDescriptionRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#set-description-audience-group +func (client *ManageAudienceAPI) UpdateAudienceGroupDescriptionWithHttpInfo( + + audienceGroupId int64, + + updateAudienceGroupDescriptionRequest *UpdateAudienceGroupDescriptionRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/audienceGroup/{audienceGroupId}/updateDescription" path = strings.Replace(path, "{audienceGroupId}", strconv.FormatInt(audienceGroupId, 10), -1) @@ -634,12 +920,12 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupDescription( var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(updateAudienceGroupDescriptionRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Put path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPut, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -647,19 +933,19 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupDescription( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } diff --git a/linebot/manage_audience/api_manage_audience_blob.go b/linebot/manage_audience/api_manage_audience_blob.go index e2b864ec..f06b2ad0 100644 --- a/linebot/manage_audience/api_manage_audience_blob.go +++ b/linebot/manage_audience/api_manage_audience_blob.go @@ -135,6 +135,40 @@ func (client *ManageAudienceBlobAPI) AddUserIdsToAudience( uploadDescription string, ) (struct{}, error) { + response, body, error := client.AddUserIdsToAudienceWithHttpInfo( + + file, + + audienceGroupId, + + uploadDescription, + ) + + defer response.Body.Close() + + return body, error +} + +// AddUserIdsToAudience +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Add user IDs or Identifiers for Advertisers (IFAs) to an audience for uploading user IDs (by file). +// Parameters: +// 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 +// audienceGroupId The audience ID. +// uploadDescription The description to register with the job + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group-by-file +func (client *ManageAudienceBlobAPI) AddUserIdsToAudienceWithHttpInfo( + + file *os.File, + + audienceGroupId int64, + + uploadDescription string, + +) (*http.Response, struct{}, error) { path := "/v2/bot/audienceGroup/upload/byFile" body := &bytes.Buffer{} @@ -146,19 +180,19 @@ func (client *ManageAudienceBlobAPI) AddUserIdsToAudience( fileWriter, err := writer.CreateFormFile("file", file.Name()) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } io.Copy(fileWriter, file) err = writer.Close() if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Put path=%s\n", path) req, err := http.NewRequest(http.MethodPut, client.Url(path), body) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", writer.FormDataContentType()) @@ -166,20 +200,20 @@ func (client *ManageAudienceBlobAPI) AddUserIdsToAudience( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -204,6 +238,45 @@ func (client *ManageAudienceBlobAPI) CreateAudienceForUploadingUserIds( uploadDescription string, ) (*CreateAudienceGroupResponse, error) { + response, body, error := client.CreateAudienceForUploadingUserIdsWithHttpInfo( + + file, + + description, + + isIfaAudience, + + uploadDescription, + ) + + defer response.Body.Close() + + return body, error +} + +// CreateAudienceForUploadingUserIds +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Create audience for uploading user IDs (by file). +// Parameters: +// 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 +// description The audience's name. This is case-insensitive, meaning AUDIENCE and audience are considered identical. Max character limit: 120 +// isIfaAudience To specify recipients by IFAs: set `true`. To specify recipients by user IDs: set `false` or omit isIfaAudience property. +// uploadDescription The description to register for the job (in `jobs[].description`). + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group-by-file +func (client *ManageAudienceBlobAPI) CreateAudienceForUploadingUserIdsWithHttpInfo( + + file *os.File, + + description string, + + isIfaAudience bool, + + uploadDescription string, + +) (*http.Response, *CreateAudienceGroupResponse, error) { path := "/v2/bot/audienceGroup/upload/byFile" body := &bytes.Buffer{} @@ -217,19 +290,19 @@ func (client *ManageAudienceBlobAPI) CreateAudienceForUploadingUserIds( fileWriter, err := writer.CreateFormFile("file", file.Name()) if err != nil { - return nil, err + return nil, nil, err } io.Copy(fileWriter, file) err = writer.Close() if err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s\n", path) req, err := http.NewRequest(http.MethodPost, client.Url(path), body) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", writer.FormDataContentType()) @@ -237,15 +310,15 @@ func (client *ManageAudienceBlobAPI) CreateAudienceForUploadingUserIds( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -253,8 +326,8 @@ func (client *ManageAudienceBlobAPI) CreateAudienceForUploadingUserIds( decoder := json.NewDecoder(res.Body) result := CreateAudienceGroupResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } diff --git a/linebot/messaging_api/api_messaging_api.go b/linebot/messaging_api/api_messaging_api.go index 63bab64e..a257266e 100644 --- a/linebot/messaging_api/api_messaging_api.go +++ b/linebot/messaging_api/api_messaging_api.go @@ -127,17 +127,41 @@ func (client *MessagingApiAPI) AudienceMatch( audienceMatchMessagesRequest *AudienceMatchMessagesRequest, ) (struct{}, error) { + response, body, error := client.AudienceMatchWithHttpInfo( + + audienceMatchMessagesRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// AudienceMatch +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Send a message using phone number +// Parameters: +// audienceMatchMessagesRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#phone-audience-match +func (client *MessagingApiAPI) AudienceMatchWithHttpInfo( + + audienceMatchMessagesRequest *AudienceMatchMessagesRequest, + +) (*http.Response, struct{}, error) { path := "/bot/ad/multicast/phone" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(audienceMatchMessagesRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -145,20 +169,20 @@ func (client *MessagingApiAPI) AudienceMatch( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -177,17 +201,46 @@ func (client *MessagingApiAPI) Broadcast( xLineRetryKey string, ) (*map[string]interface{}, error) { + response, body, error := client.BroadcastWithHttpInfo( + + broadcastRequest, + + xLineRetryKey, + ) + + defer response.Body.Close() + + return body, error +} + +// Broadcast +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Sends a message to multiple users at any time. +// Parameters: +// broadcastRequest +// xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn't generated by LINE. Each developer must generate their own retry key. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message +func (client *MessagingApiAPI) BroadcastWithHttpInfo( + + broadcastRequest *BroadcastRequest, + + xLineRetryKey string, + +) (*http.Response, *map[string]interface{}, error) { path := "/v2/bot/message/broadcast" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(broadcastRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -197,15 +250,15 @@ func (client *MessagingApiAPI) Broadcast( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -213,9 +266,9 @@ func (client *MessagingApiAPI) Broadcast( decoder := json.NewDecoder(res.Body) result := map[string]interface{}{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -226,32 +279,48 @@ func (client *MessagingApiAPI) Broadcast( // https://developers.line.biz/en/reference/messaging-api/#cancel-default-rich-menu func (client *MessagingApiAPI) CancelDefaultRichMenu() (struct{}, error) { + response, body, error := client.CancelDefaultRichMenuWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// CancelDefaultRichMenu +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Cancel default rich menu +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#cancel-default-rich-menu +func (client *MessagingApiAPI) CancelDefaultRichMenuWithHttpInfo() (*http.Response, struct{}, error) { path := "/v2/bot/user/all/richmenu" log.Printf("Sending request: method=Delete path=%s\n", path) req, err := http.NewRequest(http.MethodDelete, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -267,17 +336,41 @@ func (client *MessagingApiAPI) CreateRichMenu( richMenuRequest *RichMenuRequest, ) (*RichMenuIdResponse, error) { + response, body, error := client.CreateRichMenuWithHttpInfo( + + richMenuRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// CreateRichMenu +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Create rich menu +// Parameters: +// richMenuRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#create-rich-menu +func (client *MessagingApiAPI) CreateRichMenuWithHttpInfo( + + richMenuRequest *RichMenuRequest, + +) (*http.Response, *RichMenuIdResponse, error) { path := "/v2/bot/richmenu" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(richMenuRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -285,15 +378,15 @@ func (client *MessagingApiAPI) CreateRichMenu( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -301,9 +394,9 @@ func (client *MessagingApiAPI) CreateRichMenu( decoder := json.NewDecoder(res.Body) result := RichMenuIdResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -319,17 +412,41 @@ func (client *MessagingApiAPI) CreateRichMenuAlias( createRichMenuAliasRequest *CreateRichMenuAliasRequest, ) (struct{}, error) { + response, body, error := client.CreateRichMenuAliasWithHttpInfo( + + createRichMenuAliasRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// CreateRichMenuAlias +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Create rich menu alias +// Parameters: +// createRichMenuAliasRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#create-rich-menu-alias +func (client *MessagingApiAPI) CreateRichMenuAliasWithHttpInfo( + + createRichMenuAliasRequest *CreateRichMenuAliasRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/alias" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(createRichMenuAliasRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -337,20 +454,20 @@ func (client *MessagingApiAPI) CreateRichMenuAlias( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -366,6 +483,30 @@ func (client *MessagingApiAPI) DeleteRichMenu( richMenuId string, ) (struct{}, error) { + response, body, error := client.DeleteRichMenuWithHttpInfo( + + richMenuId, + ) + + defer response.Body.Close() + + return body, error +} + +// DeleteRichMenu +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Deletes a rich menu. +// Parameters: +// richMenuId ID of a rich menu + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu +func (client *MessagingApiAPI) DeleteRichMenuWithHttpInfo( + + richMenuId string, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/{richMenuId}" path = strings.Replace(path, "{richMenuId}", richMenuId, -1) @@ -373,27 +514,27 @@ func (client *MessagingApiAPI) DeleteRichMenu( log.Printf("Sending request: method=Delete path=%s\n", path) req, err := http.NewRequest(http.MethodDelete, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -409,6 +550,30 @@ func (client *MessagingApiAPI) DeleteRichMenuAlias( richMenuAliasId string, ) (struct{}, error) { + response, body, error := client.DeleteRichMenuAliasWithHttpInfo( + + richMenuAliasId, + ) + + defer response.Body.Close() + + return body, error +} + +// DeleteRichMenuAlias +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Delete rich menu alias +// Parameters: +// richMenuAliasId Rich menu alias ID that you want to delete. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu-alias +func (client *MessagingApiAPI) DeleteRichMenuAliasWithHttpInfo( + + richMenuAliasId string, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/alias/{richMenuAliasId}" path = strings.Replace(path, "{richMenuAliasId}", richMenuAliasId, -1) @@ -416,27 +581,27 @@ func (client *MessagingApiAPI) DeleteRichMenuAlias( log.Printf("Sending request: method=Delete path=%s\n", path) req, err := http.NewRequest(http.MethodDelete, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -452,12 +617,36 @@ func (client *MessagingApiAPI) GetAdPhoneMessageStatistics( date string, ) (*NumberOfMessagesResponse, error) { + response, body, error := client.GetAdPhoneMessageStatisticsWithHttpInfo( + + date, + ) + + defer response.Body.Close() + + return body, error +} + +// GetAdPhoneMessageStatistics +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get result of message delivery using phone number +// Parameters: +// date Date the message was sent Format: `yyyyMMdd` (e.g. `20190831`) Time Zone: UTC+9 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#get-phone-audience-match +func (client *MessagingApiAPI) GetAdPhoneMessageStatisticsWithHttpInfo( + + date string, + +) (*http.Response, *NumberOfMessagesResponse, error) { path := "/v2/bot/message/delivery/ad_phone" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -469,15 +658,15 @@ func (client *MessagingApiAPI) GetAdPhoneMessageStatistics( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -485,9 +674,9 @@ func (client *MessagingApiAPI) GetAdPhoneMessageStatistics( decoder := json.NewDecoder(res.Body) result := NumberOfMessagesResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -506,12 +695,41 @@ func (client *MessagingApiAPI) GetAggregationUnitNameList( start string, ) (*GetAggregationUnitNameListResponse, error) { + response, body, error := client.GetAggregationUnitNameListWithHttpInfo( + + limit, + + start, + ) + + defer response.Body.Close() + + return body, error +} + +// GetAggregationUnitNameList +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get name list of units used this month +// Parameters: +// limit The maximum number of aggregation units you can get per request. +// start Value of the continuation token found in the next property of the JSON object returned in the response. If you can't get all the aggregation units in one request, include this parameter to get the remaining array. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-name-list-of-units-used-this-month +func (client *MessagingApiAPI) GetAggregationUnitNameListWithHttpInfo( + + limit string, + + start string, + +) (*http.Response, *GetAggregationUnitNameListResponse, error) { path := "/v2/bot/message/aggregation/list" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -524,15 +742,15 @@ func (client *MessagingApiAPI) GetAggregationUnitNameList( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -540,9 +758,9 @@ func (client *MessagingApiAPI) GetAggregationUnitNameList( decoder := json.NewDecoder(res.Body) result := GetAggregationUnitNameListResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -553,27 +771,43 @@ func (client *MessagingApiAPI) GetAggregationUnitNameList( // https://developers.line.biz/en/reference/messaging-api/#get-number-of-units-used-this-month func (client *MessagingApiAPI) GetAggregationUnitUsage() (*GetAggregationUnitUsageResponse, error) { + response, body, error := client.GetAggregationUnitUsageWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetAggregationUnitUsage +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get number of units used this month +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-number-of-units-used-this-month +func (client *MessagingApiAPI) GetAggregationUnitUsageWithHttpInfo() (*http.Response, *GetAggregationUnitUsageResponse, error) { path := "/v2/bot/message/aggregation/info" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -581,9 +815,9 @@ func (client *MessagingApiAPI) GetAggregationUnitUsage() (*GetAggregationUnitUsa decoder := json.NewDecoder(res.Body) result := GetAggregationUnitUsageResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -594,27 +828,43 @@ func (client *MessagingApiAPI) GetAggregationUnitUsage() (*GetAggregationUnitUsa // https://developers.line.biz/en/reference/messaging-api/#get-bot-info func (client *MessagingApiAPI) GetBotInfo() (*BotInfoResponse, error) { + response, body, error := client.GetBotInfoWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetBotInfo +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get bot info +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-bot-info +func (client *MessagingApiAPI) GetBotInfoWithHttpInfo() (*http.Response, *BotInfoResponse, error) { path := "/v2/bot/info" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -622,9 +872,9 @@ func (client *MessagingApiAPI) GetBotInfo() (*BotInfoResponse, error) { decoder := json.NewDecoder(res.Body) result := BotInfoResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -635,27 +885,43 @@ func (client *MessagingApiAPI) GetBotInfo() (*BotInfoResponse, error) { // https://developers.line.biz/en/reference/messaging-api/#get-default-rich-menu-id func (client *MessagingApiAPI) GetDefaultRichMenuId() (*RichMenuIdResponse, error) { + response, body, error := client.GetDefaultRichMenuIdWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetDefaultRichMenuId +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Gets the ID of the default rich menu set with the Messaging API. +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-default-rich-menu-id +func (client *MessagingApiAPI) GetDefaultRichMenuIdWithHttpInfo() (*http.Response, *RichMenuIdResponse, error) { path := "/v2/bot/user/all/richmenu" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -663,9 +929,9 @@ func (client *MessagingApiAPI) GetDefaultRichMenuId() (*RichMenuIdResponse, erro decoder := json.NewDecoder(res.Body) result := RichMenuIdResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -684,12 +950,41 @@ func (client *MessagingApiAPI) GetFollowers( limit int32, ) (*GetFollowersResponse, error) { + response, body, error := client.GetFollowersWithHttpInfo( + + start, + + limit, + ) + + defer response.Body.Close() + + return body, error +} + +// GetFollowers +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get a list of users who added your LINE Official Account as a friend +// Parameters: +// start Value of the continuation token found in the next property of the JSON object returned in the response. Include this parameter to get the next array of user IDs. +// limit The maximum number of user IDs to retrieve in a single request. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-follower-ids +func (client *MessagingApiAPI) GetFollowersWithHttpInfo( + + start string, + + limit int32, + +) (*http.Response, *GetFollowersResponse, error) { path := "/v2/bot/followers/ids" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -702,15 +997,15 @@ func (client *MessagingApiAPI) GetFollowers( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -718,9 +1013,9 @@ func (client *MessagingApiAPI) GetFollowers( decoder := json.NewDecoder(res.Body) result := GetFollowersResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -736,6 +1031,30 @@ func (client *MessagingApiAPI) GetGroupMemberCount( groupId string, ) (*GroupMemberCountResponse, error) { + response, body, error := client.GetGroupMemberCountWithHttpInfo( + + groupId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetGroupMemberCount +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get number of users in a group chat +// Parameters: +// groupId Group ID + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-members-group-count +func (client *MessagingApiAPI) GetGroupMemberCountWithHttpInfo( + + groupId string, + +) (*http.Response, *GroupMemberCountResponse, error) { path := "/v2/bot/group/{groupId}/members/count" path = strings.Replace(path, "{groupId}", groupId, -1) @@ -743,22 +1062,22 @@ func (client *MessagingApiAPI) GetGroupMemberCount( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -766,9 +1085,9 @@ func (client *MessagingApiAPI) GetGroupMemberCount( decoder := json.NewDecoder(res.Body) result := GroupMemberCountResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -787,6 +1106,35 @@ func (client *MessagingApiAPI) GetGroupMemberProfile( userId string, ) (*GroupUserProfileResponse, error) { + response, body, error := client.GetGroupMemberProfileWithHttpInfo( + + groupId, + + userId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetGroupMemberProfile +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get group chat member profile +// Parameters: +// groupId Group ID +// userId User ID + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-group-member-profile +func (client *MessagingApiAPI) GetGroupMemberProfileWithHttpInfo( + + groupId string, + + userId string, + +) (*http.Response, *GroupUserProfileResponse, error) { path := "/v2/bot/group/{groupId}/member/{userId}" path = strings.Replace(path, "{groupId}", groupId, -1) @@ -796,22 +1144,22 @@ func (client *MessagingApiAPI) GetGroupMemberProfile( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -819,9 +1167,9 @@ func (client *MessagingApiAPI) GetGroupMemberProfile( decoder := json.NewDecoder(res.Body) result := GroupUserProfileResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -840,34 +1188,63 @@ func (client *MessagingApiAPI) GetGroupMembersIds( start string, ) (*MembersIdsResponse, error) { - path := "/v2/bot/group/{groupId}/members/ids" + response, body, error := client.GetGroupMembersIdsWithHttpInfo( - path = strings.Replace(path, "{groupId}", groupId, -1) + groupId, - log.Printf("Sending request: method=Get path=%s\n", path) - req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) - if err != nil { - return nil, err - } + start, + ) - var query url.Values - query = url.Values{"start": []string{string(start)}} + defer response.Body.Close() - req.URL.RawQuery = query.Encode() + return body, error +} - res, err := client.Do(req) - log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) +// GetGroupMembersIds +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get group chat member user IDs +// Parameters: +// groupId Group ID +// start Value of the continuation token found in the `next` property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-group-member-user-ids +func (client *MessagingApiAPI) GetGroupMembersIdsWithHttpInfo( + + groupId string, + + start string, + +) (*http.Response, *MembersIdsResponse, error) { + path := "/v2/bot/group/{groupId}/members/ids" + + path = strings.Replace(path, "{groupId}", groupId, -1) + log.Printf("Sending request: method=Get path=%s\n", path) + req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err + } + + var query url.Values + query = url.Values{"start": []string{string(start)}} + + req.URL.RawQuery = query.Encode() + + res, err := client.Do(req) + log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) + + if err != nil { + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -875,9 +1252,9 @@ func (client *MessagingApiAPI) GetGroupMembersIds( decoder := json.NewDecoder(res.Body) result := MembersIdsResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -893,6 +1270,30 @@ func (client *MessagingApiAPI) GetGroupSummary( groupId string, ) (*GroupSummaryResponse, error) { + response, body, error := client.GetGroupSummaryWithHttpInfo( + + groupId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetGroupSummary +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get group chat summary +// Parameters: +// groupId Group ID + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-group-summary +func (client *MessagingApiAPI) GetGroupSummaryWithHttpInfo( + + groupId string, + +) (*http.Response, *GroupSummaryResponse, error) { path := "/v2/bot/group/{groupId}/summary" path = strings.Replace(path, "{groupId}", groupId, -1) @@ -900,22 +1301,22 @@ func (client *MessagingApiAPI) GetGroupSummary( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -923,9 +1324,9 @@ func (client *MessagingApiAPI) GetGroupSummary( decoder := json.NewDecoder(res.Body) result := GroupSummaryResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -936,27 +1337,43 @@ func (client *MessagingApiAPI) GetGroupSummary( // https://developers.line.biz/en/reference/messaging-api/#get-quota func (client *MessagingApiAPI) GetMessageQuota() (*MessageQuotaResponse, error) { + response, body, error := client.GetMessageQuotaWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetMessageQuota +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Gets the target limit for sending messages in the current month. The total number of the free messages and the additional messages is returned. +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-quota +func (client *MessagingApiAPI) GetMessageQuotaWithHttpInfo() (*http.Response, *MessageQuotaResponse, error) { path := "/v2/bot/message/quota" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -964,9 +1381,9 @@ func (client *MessagingApiAPI) GetMessageQuota() (*MessageQuotaResponse, error) decoder := json.NewDecoder(res.Body) result := MessageQuotaResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -977,27 +1394,43 @@ func (client *MessagingApiAPI) GetMessageQuota() (*MessageQuotaResponse, error) // https://developers.line.biz/en/reference/messaging-api/#get-consumption func (client *MessagingApiAPI) GetMessageQuotaConsumption() (*QuotaConsumptionResponse, error) { + response, body, error := client.GetMessageQuotaConsumptionWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetMessageQuotaConsumption +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Gets the number of messages sent in the current month. +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-consumption +func (client *MessagingApiAPI) GetMessageQuotaConsumptionWithHttpInfo() (*http.Response, *QuotaConsumptionResponse, error) { path := "/v2/bot/message/quota/consumption" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1005,9 +1438,9 @@ func (client *MessagingApiAPI) GetMessageQuotaConsumption() (*QuotaConsumptionRe decoder := json.NewDecoder(res.Body) result := QuotaConsumptionResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1023,12 +1456,36 @@ func (client *MessagingApiAPI) GetNarrowcastProgress( requestId string, ) (*NarrowcastProgressResponse, error) { + response, body, error := client.GetNarrowcastProgressWithHttpInfo( + + requestId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetNarrowcastProgress +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Gets the status of a narrowcast message. +// Parameters: +// requestId The narrowcast message's request ID. Each Messaging API request has a request ID. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-narrowcast-progress-status +func (client *MessagingApiAPI) GetNarrowcastProgressWithHttpInfo( + + requestId string, + +) (*http.Response, *NarrowcastProgressResponse, error) { path := "/v2/bot/message/progress/narrowcast" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -1040,15 +1497,15 @@ func (client *MessagingApiAPI) GetNarrowcastProgress( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1056,9 +1513,9 @@ func (client *MessagingApiAPI) GetNarrowcastProgress( decoder := json.NewDecoder(res.Body) result := NarrowcastProgressResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1074,12 +1531,36 @@ func (client *MessagingApiAPI) GetNumberOfSentBroadcastMessages( date string, ) (*NumberOfMessagesResponse, error) { + response, body, error := client.GetNumberOfSentBroadcastMessagesWithHttpInfo( + + date, + ) + + defer response.Body.Close() + + return body, error +} + +// GetNumberOfSentBroadcastMessages +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get number of sent broadcast messages +// Parameters: +// date Date the messages were sent Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-number-of-broadcast-messages +func (client *MessagingApiAPI) GetNumberOfSentBroadcastMessagesWithHttpInfo( + + date string, + +) (*http.Response, *NumberOfMessagesResponse, error) { path := "/v2/bot/message/delivery/broadcast" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -1091,15 +1572,15 @@ func (client *MessagingApiAPI) GetNumberOfSentBroadcastMessages( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1107,9 +1588,9 @@ func (client *MessagingApiAPI) GetNumberOfSentBroadcastMessages( decoder := json.NewDecoder(res.Body) result := NumberOfMessagesResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1125,12 +1606,36 @@ func (client *MessagingApiAPI) GetNumberOfSentMulticastMessages( date string, ) (*NumberOfMessagesResponse, error) { + response, body, error := client.GetNumberOfSentMulticastMessagesWithHttpInfo( + + date, + ) + + defer response.Body.Close() + + return body, error +} + +// GetNumberOfSentMulticastMessages +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get number of sent multicast messages +// Parameters: +// date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-number-of-multicast-messages +func (client *MessagingApiAPI) GetNumberOfSentMulticastMessagesWithHttpInfo( + + date string, + +) (*http.Response, *NumberOfMessagesResponse, error) { path := "/v2/bot/message/delivery/multicast" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -1142,15 +1647,15 @@ func (client *MessagingApiAPI) GetNumberOfSentMulticastMessages( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1158,9 +1663,9 @@ func (client *MessagingApiAPI) GetNumberOfSentMulticastMessages( decoder := json.NewDecoder(res.Body) result := NumberOfMessagesResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1176,12 +1681,36 @@ func (client *MessagingApiAPI) GetNumberOfSentPushMessages( date string, ) (*NumberOfMessagesResponse, error) { + response, body, error := client.GetNumberOfSentPushMessagesWithHttpInfo( + + date, + ) + + defer response.Body.Close() + + return body, error +} + +// GetNumberOfSentPushMessages +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get number of sent push messages +// Parameters: +// date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-number-of-push-messages +func (client *MessagingApiAPI) GetNumberOfSentPushMessagesWithHttpInfo( + + date string, + +) (*http.Response, *NumberOfMessagesResponse, error) { path := "/v2/bot/message/delivery/push" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -1193,15 +1722,15 @@ func (client *MessagingApiAPI) GetNumberOfSentPushMessages( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1209,9 +1738,9 @@ func (client *MessagingApiAPI) GetNumberOfSentPushMessages( decoder := json.NewDecoder(res.Body) result := NumberOfMessagesResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1227,12 +1756,36 @@ func (client *MessagingApiAPI) GetNumberOfSentReplyMessages( date string, ) (*NumberOfMessagesResponse, error) { + response, body, error := client.GetNumberOfSentReplyMessagesWithHttpInfo( + + date, + ) + + defer response.Body.Close() + + return body, error +} + +// GetNumberOfSentReplyMessages +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get number of sent reply messages +// Parameters: +// date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-number-of-reply-messages +func (client *MessagingApiAPI) GetNumberOfSentReplyMessagesWithHttpInfo( + + date string, + +) (*http.Response, *NumberOfMessagesResponse, error) { path := "/v2/bot/message/delivery/reply" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -1244,15 +1797,15 @@ func (client *MessagingApiAPI) GetNumberOfSentReplyMessages( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1260,9 +1813,9 @@ func (client *MessagingApiAPI) GetNumberOfSentReplyMessages( decoder := json.NewDecoder(res.Body) result := NumberOfMessagesResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1278,12 +1831,36 @@ func (client *MessagingApiAPI) GetPNPMessageStatistics( date string, ) (*NumberOfMessagesResponse, error) { + response, body, error := client.GetPNPMessageStatisticsWithHttpInfo( + + date, + ) + + defer response.Body.Close() + + return body, error +} + +// GetPNPMessageStatistics +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get number of sent LINE notification messages +// Parameters: +// date Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#get-number-of-sent-line-notification-messages +func (client *MessagingApiAPI) GetPNPMessageStatisticsWithHttpInfo( + + date string, + +) (*http.Response, *NumberOfMessagesResponse, error) { path := "/v2/bot/message/delivery/pnp" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -1295,15 +1872,15 @@ func (client *MessagingApiAPI) GetPNPMessageStatistics( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1311,9 +1888,9 @@ func (client *MessagingApiAPI) GetPNPMessageStatistics( decoder := json.NewDecoder(res.Body) result := NumberOfMessagesResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1329,6 +1906,30 @@ func (client *MessagingApiAPI) GetProfile( userId string, ) (*UserProfileResponse, error) { + response, body, error := client.GetProfileWithHttpInfo( + + userId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetProfile +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get profile +// Parameters: +// userId User ID + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-profile +func (client *MessagingApiAPI) GetProfileWithHttpInfo( + + userId string, + +) (*http.Response, *UserProfileResponse, error) { path := "/v2/bot/profile/{userId}" path = strings.Replace(path, "{userId}", userId, -1) @@ -1336,22 +1937,22 @@ func (client *MessagingApiAPI) GetProfile( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1359,9 +1960,9 @@ func (client *MessagingApiAPI) GetProfile( decoder := json.NewDecoder(res.Body) result := UserProfileResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1377,6 +1978,30 @@ func (client *MessagingApiAPI) GetRichMenu( richMenuId string, ) (*RichMenuResponse, error) { + response, body, error := client.GetRichMenuWithHttpInfo( + + richMenuId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetRichMenu +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Gets a rich menu via a rich menu ID. +// Parameters: +// richMenuId ID of a rich menu + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-rich-menu +func (client *MessagingApiAPI) GetRichMenuWithHttpInfo( + + richMenuId string, + +) (*http.Response, *RichMenuResponse, error) { path := "/v2/bot/richmenu/{richMenuId}" path = strings.Replace(path, "{richMenuId}", richMenuId, -1) @@ -1384,22 +2009,22 @@ func (client *MessagingApiAPI) GetRichMenu( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1407,9 +2032,9 @@ func (client *MessagingApiAPI) GetRichMenu( decoder := json.NewDecoder(res.Body) result := RichMenuResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1425,6 +2050,30 @@ func (client *MessagingApiAPI) GetRichMenuAlias( richMenuAliasId string, ) (*RichMenuAliasResponse, error) { + response, body, error := client.GetRichMenuAliasWithHttpInfo( + + richMenuAliasId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetRichMenuAlias +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get rich menu alias information +// Parameters: +// richMenuAliasId The rich menu alias ID whose information you want to obtain. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-by-id +func (client *MessagingApiAPI) GetRichMenuAliasWithHttpInfo( + + richMenuAliasId string, + +) (*http.Response, *RichMenuAliasResponse, error) { path := "/v2/bot/richmenu/alias/{richMenuAliasId}" path = strings.Replace(path, "{richMenuAliasId}", richMenuAliasId, -1) @@ -1432,22 +2081,22 @@ func (client *MessagingApiAPI) GetRichMenuAlias( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1455,9 +2104,9 @@ func (client *MessagingApiAPI) GetRichMenuAlias( decoder := json.NewDecoder(res.Body) result := RichMenuAliasResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1468,27 +2117,43 @@ func (client *MessagingApiAPI) GetRichMenuAlias( // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-list func (client *MessagingApiAPI) GetRichMenuAliasList() (*RichMenuAliasListResponse, error) { + response, body, error := client.GetRichMenuAliasListWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetRichMenuAliasList +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get list of rich menu alias +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-list +func (client *MessagingApiAPI) GetRichMenuAliasListWithHttpInfo() (*http.Response, *RichMenuAliasListResponse, error) { path := "/v2/bot/richmenu/alias/list" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1496,9 +2161,9 @@ func (client *MessagingApiAPI) GetRichMenuAliasList() (*RichMenuAliasListRespons decoder := json.NewDecoder(res.Body) result := RichMenuAliasListResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1514,12 +2179,36 @@ func (client *MessagingApiAPI) GetRichMenuBatchProgress( requestId string, ) (*RichMenuBatchProgressResponse, error) { + response, body, error := client.GetRichMenuBatchProgressWithHttpInfo( + + requestId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetRichMenuBatchProgress +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get the status of Replace or unlink a linked rich menus in batches. +// Parameters: +// requestId A request ID used to batch control the rich menu linked to the user. Each Messaging API request has a request ID. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-batch-control-rich-menus-progress-status +func (client *MessagingApiAPI) GetRichMenuBatchProgressWithHttpInfo( + + requestId string, + +) (*http.Response, *RichMenuBatchProgressResponse, error) { path := "/v2/bot/richmenu/progress/batch" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -1531,15 +2220,15 @@ func (client *MessagingApiAPI) GetRichMenuBatchProgress( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1547,9 +2236,9 @@ func (client *MessagingApiAPI) GetRichMenuBatchProgress( decoder := json.NewDecoder(res.Body) result := RichMenuBatchProgressResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1565,29 +2254,53 @@ func (client *MessagingApiAPI) GetRichMenuIdOfUser( userId string, ) (*RichMenuIdResponse, error) { - path := "/v2/bot/user/{userId}/richmenu" + response, body, error := client.GetRichMenuIdOfUserWithHttpInfo( - path = strings.Replace(path, "{userId}", userId, -1) + userId, + ) - log.Printf("Sending request: method=Get path=%s\n", path) + defer response.Body.Close() + + return body, error +} + +// GetRichMenuIdOfUser +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get rich menu ID of user +// Parameters: +// userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-id-of-user +func (client *MessagingApiAPI) GetRichMenuIdOfUserWithHttpInfo( + + userId string, + +) (*http.Response, *RichMenuIdResponse, error) { + path := "/v2/bot/user/{userId}/richmenu" + + path = strings.Replace(path, "{userId}", userId, -1) + + log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1595,9 +2308,9 @@ func (client *MessagingApiAPI) GetRichMenuIdOfUser( decoder := json.NewDecoder(res.Body) result := RichMenuIdResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1608,27 +2321,43 @@ func (client *MessagingApiAPI) GetRichMenuIdOfUser( // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list func (client *MessagingApiAPI) GetRichMenuList() (*RichMenuListResponse, error) { + response, body, error := client.GetRichMenuListWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetRichMenuList +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get rich menu list +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list +func (client *MessagingApiAPI) GetRichMenuListWithHttpInfo() (*http.Response, *RichMenuListResponse, error) { path := "/v2/bot/richmenu/list" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1636,9 +2365,9 @@ func (client *MessagingApiAPI) GetRichMenuList() (*RichMenuListResponse, error) decoder := json.NewDecoder(res.Body) result := RichMenuListResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1654,6 +2383,30 @@ func (client *MessagingApiAPI) GetRoomMemberCount( roomId string, ) (*RoomMemberCountResponse, error) { + response, body, error := client.GetRoomMemberCountWithHttpInfo( + + roomId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetRoomMemberCount +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get number of users in a multi-person chat +// Parameters: +// roomId Room ID + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-members-room-count +func (client *MessagingApiAPI) GetRoomMemberCountWithHttpInfo( + + roomId string, + +) (*http.Response, *RoomMemberCountResponse, error) { path := "/v2/bot/room/{roomId}/members/count" path = strings.Replace(path, "{roomId}", roomId, -1) @@ -1661,22 +2414,22 @@ func (client *MessagingApiAPI) GetRoomMemberCount( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1684,9 +2437,9 @@ func (client *MessagingApiAPI) GetRoomMemberCount( decoder := json.NewDecoder(res.Body) result := RoomMemberCountResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1705,6 +2458,35 @@ func (client *MessagingApiAPI) GetRoomMemberProfile( userId string, ) (*RoomUserProfileResponse, error) { + response, body, error := client.GetRoomMemberProfileWithHttpInfo( + + roomId, + + userId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetRoomMemberProfile +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get multi-person chat member profile +// Parameters: +// roomId Room ID +// userId User ID + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-room-member-profile +func (client *MessagingApiAPI) GetRoomMemberProfileWithHttpInfo( + + roomId string, + + userId string, + +) (*http.Response, *RoomUserProfileResponse, error) { path := "/v2/bot/room/{roomId}/member/{userId}" path = strings.Replace(path, "{roomId}", roomId, -1) @@ -1714,22 +2496,22 @@ func (client *MessagingApiAPI) GetRoomMemberProfile( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1737,9 +2519,9 @@ func (client *MessagingApiAPI) GetRoomMemberProfile( decoder := json.NewDecoder(res.Body) result := RoomUserProfileResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1758,6 +2540,35 @@ func (client *MessagingApiAPI) GetRoomMembersIds( start string, ) (*MembersIdsResponse, error) { + response, body, error := client.GetRoomMembersIdsWithHttpInfo( + + roomId, + + start, + ) + + defer response.Body.Close() + + return body, error +} + +// GetRoomMembersIds +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get multi-person chat member user IDs +// Parameters: +// roomId Room ID +// start Value of the continuation token found in the `next` property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-room-member-user-ids +func (client *MessagingApiAPI) GetRoomMembersIdsWithHttpInfo( + + roomId string, + + start string, + +) (*http.Response, *MembersIdsResponse, error) { path := "/v2/bot/room/{roomId}/members/ids" path = strings.Replace(path, "{roomId}", roomId, -1) @@ -1765,7 +2576,7 @@ func (client *MessagingApiAPI) GetRoomMembersIds( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -1777,15 +2588,15 @@ func (client *MessagingApiAPI) GetRoomMembersIds( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1793,9 +2604,9 @@ func (client *MessagingApiAPI) GetRoomMembersIds( decoder := json.NewDecoder(res.Body) result := MembersIdsResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1806,27 +2617,43 @@ func (client *MessagingApiAPI) GetRoomMembersIds( // https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information func (client *MessagingApiAPI) GetWebhookEndpoint() (*GetWebhookEndpointResponse, error) { + response, body, error := client.GetWebhookEndpointWithHttpInfo() + + defer response.Body.Close() + + return body, error +} + +// GetWebhookEndpoint +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get webhook endpoint information +// Parameters: + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information +func (client *MessagingApiAPI) GetWebhookEndpointWithHttpInfo() (*http.Response, *GetWebhookEndpointResponse, error) { path := "/v2/bot/channel/webhook/endpoint" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1834,9 +2661,9 @@ func (client *MessagingApiAPI) GetWebhookEndpoint() (*GetWebhookEndpointResponse decoder := json.NewDecoder(res.Body) result := GetWebhookEndpointResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1852,6 +2679,30 @@ func (client *MessagingApiAPI) IssueLinkToken( userId string, ) (*IssueLinkTokenResponse, error) { + response, body, error := client.IssueLinkTokenWithHttpInfo( + + userId, + ) + + defer response.Body.Close() + + return body, error +} + +// IssueLinkToken +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Issue link token +// Parameters: +// userId User ID for the LINE account to be linked. Found in the `source` object of account link event objects. Do not use the LINE ID used in LINE. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#issue-link-token +func (client *MessagingApiAPI) IssueLinkTokenWithHttpInfo( + + userId string, + +) (*http.Response, *IssueLinkTokenResponse, error) { path := "/v2/bot/user/{userId}/linkToken" path = strings.Replace(path, "{userId}", userId, -1) @@ -1859,22 +2710,22 @@ func (client *MessagingApiAPI) IssueLinkToken( log.Printf("Sending request: method=Post path=%s\n", path) req, err := http.NewRequest(http.MethodPost, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -1882,9 +2733,9 @@ func (client *MessagingApiAPI) IssueLinkToken( decoder := json.NewDecoder(res.Body) result := IssueLinkTokenResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -1900,6 +2751,30 @@ func (client *MessagingApiAPI) LeaveGroup( groupId string, ) (struct{}, error) { + response, body, error := client.LeaveGroupWithHttpInfo( + + groupId, + ) + + defer response.Body.Close() + + return body, error +} + +// LeaveGroup +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Leave group chat +// Parameters: +// groupId Group ID + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#leave-group +func (client *MessagingApiAPI) LeaveGroupWithHttpInfo( + + groupId string, + +) (*http.Response, struct{}, error) { path := "/v2/bot/group/{groupId}/leave" path = strings.Replace(path, "{groupId}", groupId, -1) @@ -1907,27 +2782,27 @@ func (client *MessagingApiAPI) LeaveGroup( log.Printf("Sending request: method=Post path=%s\n", path) req, err := http.NewRequest(http.MethodPost, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -1943,6 +2818,30 @@ func (client *MessagingApiAPI) LeaveRoom( roomId string, ) (struct{}, error) { + response, body, error := client.LeaveRoomWithHttpInfo( + + roomId, + ) + + defer response.Body.Close() + + return body, error +} + +// LeaveRoom +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Leave multi-person chat +// Parameters: +// roomId Room ID + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#leave-room +func (client *MessagingApiAPI) LeaveRoomWithHttpInfo( + + roomId string, + +) (*http.Response, struct{}, error) { path := "/v2/bot/room/{roomId}/leave" path = strings.Replace(path, "{roomId}", roomId, -1) @@ -1950,27 +2849,27 @@ func (client *MessagingApiAPI) LeaveRoom( log.Printf("Sending request: method=Post path=%s\n", path) req, err := http.NewRequest(http.MethodPost, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -1989,6 +2888,35 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUser( richMenuId string, ) (struct{}, error) { + response, body, error := client.LinkRichMenuIdToUserWithHttpInfo( + + userId, + + richMenuId, + ) + + defer response.Body.Close() + + return body, error +} + +// LinkRichMenuIdToUser +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Link rich menu to user. +// Parameters: +// userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. +// richMenuId ID of a rich menu + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-user +func (client *MessagingApiAPI) LinkRichMenuIdToUserWithHttpInfo( + + userId string, + + richMenuId string, + +) (*http.Response, struct{}, error) { path := "/v2/bot/user/{userId}/richmenu/{richMenuId}" path = strings.Replace(path, "{userId}", userId, -1) @@ -1998,27 +2926,27 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUser( log.Printf("Sending request: method=Post path=%s\n", path) req, err := http.NewRequest(http.MethodPost, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2034,17 +2962,41 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUsers( richMenuBulkLinkRequest *RichMenuBulkLinkRequest, ) (struct{}, error) { + response, body, error := client.LinkRichMenuIdToUsersWithHttpInfo( + + richMenuBulkLinkRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// LinkRichMenuIdToUsers +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Link rich menu to multiple users +// Parameters: +// richMenuBulkLinkRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-users +func (client *MessagingApiAPI) LinkRichMenuIdToUsersWithHttpInfo( + + richMenuBulkLinkRequest *RichMenuBulkLinkRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/bulk/link" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(richMenuBulkLinkRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2052,20 +3004,20 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUsers( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2081,17 +3033,41 @@ func (client *MessagingApiAPI) MarkMessagesAsRead( markMessagesAsReadRequest *MarkMessagesAsReadRequest, ) (struct{}, error) { + response, body, error := client.MarkMessagesAsReadWithHttpInfo( + + markMessagesAsReadRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// MarkMessagesAsRead +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Mark messages from users as read +// Parameters: +// markMessagesAsReadRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#mark-messages-from-users-as-read +func (client *MessagingApiAPI) MarkMessagesAsReadWithHttpInfo( + + markMessagesAsReadRequest *MarkMessagesAsReadRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/message/markAsRead" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(markMessagesAsReadRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2099,20 +3075,20 @@ func (client *MessagingApiAPI) MarkMessagesAsRead( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2131,17 +3107,46 @@ func (client *MessagingApiAPI) Multicast( xLineRetryKey string, ) (*map[string]interface{}, error) { + response, body, error := client.MulticastWithHttpInfo( + + multicastRequest, + + xLineRetryKey, + ) + + defer response.Body.Close() + + return body, error +} + +// Multicast +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// An API that efficiently sends the same message to multiple user IDs. You can't send messages to group chats or multi-person chats. +// Parameters: +// multicastRequest +// xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn't generated by LINE. Each developer must generate their own retry key. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#send-multicast-message +func (client *MessagingApiAPI) MulticastWithHttpInfo( + + multicastRequest *MulticastRequest, + + xLineRetryKey string, + +) (*http.Response, *map[string]interface{}, error) { path := "/v2/bot/message/multicast" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(multicastRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2151,15 +3156,15 @@ func (client *MessagingApiAPI) Multicast( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -2167,9 +3172,9 @@ func (client *MessagingApiAPI) Multicast( decoder := json.NewDecoder(res.Body) result := map[string]interface{}{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -2188,17 +3193,46 @@ func (client *MessagingApiAPI) Narrowcast( xLineRetryKey string, ) (*map[string]interface{}, error) { + response, body, error := client.NarrowcastWithHttpInfo( + + narrowcastRequest, + + xLineRetryKey, + ) + + defer response.Body.Close() + + return body, error +} + +// Narrowcast +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Send narrowcast message +// Parameters: +// narrowcastRequest +// xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn't generated by LINE. Each developer must generate their own retry key. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#send-narrowcast-message +func (client *MessagingApiAPI) NarrowcastWithHttpInfo( + + narrowcastRequest *NarrowcastRequest, + + xLineRetryKey string, + +) (*http.Response, *map[string]interface{}, error) { path := "/v2/bot/message/narrowcast" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(narrowcastRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2208,15 +3242,15 @@ func (client *MessagingApiAPI) Narrowcast( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -2224,9 +3258,9 @@ func (client *MessagingApiAPI) Narrowcast( decoder := json.NewDecoder(res.Body) result := map[string]interface{}{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -2245,17 +3279,46 @@ func (client *MessagingApiAPI) PushMessage( xLineRetryKey string, ) (*PushMessageResponse, error) { + response, body, error := client.PushMessageWithHttpInfo( + + pushMessageRequest, + + xLineRetryKey, + ) + + defer response.Body.Close() + + return body, error +} + +// PushMessage +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Sends a message to a user, group chat, or multi-person chat at any time. +// Parameters: +// pushMessageRequest +// xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn't generated by LINE. Each developer must generate their own retry key. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#send-push-message +func (client *MessagingApiAPI) PushMessageWithHttpInfo( + + pushMessageRequest *PushMessageRequest, + + xLineRetryKey string, + +) (*http.Response, *PushMessageResponse, error) { path := "/v2/bot/message/push" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(pushMessageRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2265,15 +3328,15 @@ func (client *MessagingApiAPI) PushMessage( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -2281,9 +3344,9 @@ func (client *MessagingApiAPI) PushMessage( decoder := json.NewDecoder(res.Body) result := PushMessageResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -2302,17 +3365,46 @@ func (client *MessagingApiAPI) PushMessagesByPhone( xLineDeliveryTag string, ) (struct{}, error) { + response, body, error := client.PushMessagesByPhoneWithHttpInfo( + + pnpMessagesRequest, + + xLineDeliveryTag, + ) + + defer response.Body.Close() + + return body, error +} + +// PushMessagesByPhone +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Send LINE notification message +// Parameters: +// pnpMessagesRequest +// xLineDeliveryTag String returned in the delivery.data property of the delivery completion event via Webhook. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#send-line-notification-message +func (client *MessagingApiAPI) PushMessagesByPhoneWithHttpInfo( + + pnpMessagesRequest *PnpMessagesRequest, + + xLineDeliveryTag string, + +) (*http.Response, struct{}, error) { path := "/bot/pnp/push" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(pnpMessagesRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2322,20 +3414,20 @@ func (client *MessagingApiAPI) PushMessagesByPhone( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2351,17 +3443,41 @@ func (client *MessagingApiAPI) ReplyMessage( replyMessageRequest *ReplyMessageRequest, ) (*ReplyMessageResponse, error) { + response, body, error := client.ReplyMessageWithHttpInfo( + + replyMessageRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// ReplyMessage +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Send reply message +// Parameters: +// replyMessageRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#send-reply-message +func (client *MessagingApiAPI) ReplyMessageWithHttpInfo( + + replyMessageRequest *ReplyMessageRequest, + +) (*http.Response, *ReplyMessageResponse, error) { path := "/v2/bot/message/reply" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(replyMessageRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2369,15 +3485,15 @@ func (client *MessagingApiAPI) ReplyMessage( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -2385,9 +3501,9 @@ func (client *MessagingApiAPI) ReplyMessage( decoder := json.NewDecoder(res.Body) result := ReplyMessageResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -2403,17 +3519,41 @@ func (client *MessagingApiAPI) RichMenuBatch( richMenuBatchRequest *RichMenuBatchRequest, ) (struct{}, error) { + response, body, error := client.RichMenuBatchWithHttpInfo( + + richMenuBatchRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// RichMenuBatch +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// You can use this endpoint to batch control the rich menu linked to the users using the endpoint such as Link rich menu to user. The following operations are available: 1. Replace a rich menu with another rich menu for all users linked to a specific rich menu 2. Unlink a rich menu for all users linked to a specific rich menu 3. Unlink a rich menu for all users linked the rich menu +// Parameters: +// richMenuBatchRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#batch-control-rich-menus-of-users +func (client *MessagingApiAPI) RichMenuBatchWithHttpInfo( + + richMenuBatchRequest *RichMenuBatchRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/batch" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(richMenuBatchRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2421,20 +3561,20 @@ func (client *MessagingApiAPI) RichMenuBatch( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2450,6 +3590,30 @@ func (client *MessagingApiAPI) SetDefaultRichMenu( richMenuId string, ) (struct{}, error) { + response, body, error := client.SetDefaultRichMenuWithHttpInfo( + + richMenuId, + ) + + defer response.Body.Close() + + return body, error +} + +// SetDefaultRichMenu +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Set default rich menu +// Parameters: +// richMenuId ID of a rich menu + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#set-default-rich-menu +func (client *MessagingApiAPI) SetDefaultRichMenuWithHttpInfo( + + richMenuId string, + +) (*http.Response, struct{}, error) { path := "/v2/bot/user/all/richmenu/{richMenuId}" path = strings.Replace(path, "{richMenuId}", richMenuId, -1) @@ -2457,27 +3621,27 @@ func (client *MessagingApiAPI) SetDefaultRichMenu( log.Printf("Sending request: method=Post path=%s\n", path) req, err := http.NewRequest(http.MethodPost, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2493,17 +3657,41 @@ func (client *MessagingApiAPI) SetWebhookEndpoint( setWebhookEndpointRequest *SetWebhookEndpointRequest, ) (struct{}, error) { + response, body, error := client.SetWebhookEndpointWithHttpInfo( + + setWebhookEndpointRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// SetWebhookEndpoint +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Set webhook endpoint URL +// Parameters: +// setWebhookEndpointRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#set-webhook-endpoint-url +func (client *MessagingApiAPI) SetWebhookEndpointWithHttpInfo( + + setWebhookEndpointRequest *SetWebhookEndpointRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/channel/webhook/endpoint" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(setWebhookEndpointRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Put path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPut, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2511,20 +3699,20 @@ func (client *MessagingApiAPI) SetWebhookEndpoint( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2540,17 +3728,41 @@ func (client *MessagingApiAPI) TestWebhookEndpoint( testWebhookEndpointRequest *TestWebhookEndpointRequest, ) (*TestWebhookEndpointResponse, error) { + response, body, error := client.TestWebhookEndpointWithHttpInfo( + + testWebhookEndpointRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// TestWebhookEndpoint +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Test webhook endpoint +// Parameters: +// testWebhookEndpointRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#test-webhook-endpoint +func (client *MessagingApiAPI) TestWebhookEndpointWithHttpInfo( + + testWebhookEndpointRequest *TestWebhookEndpointRequest, + +) (*http.Response, *TestWebhookEndpointResponse, error) { path := "/v2/bot/channel/webhook/test" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(testWebhookEndpointRequest); err != nil { - return nil, err + return nil, nil, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2558,15 +3770,15 @@ func (client *MessagingApiAPI) TestWebhookEndpoint( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -2574,9 +3786,9 @@ func (client *MessagingApiAPI) TestWebhookEndpoint( decoder := json.NewDecoder(res.Body) result := TestWebhookEndpointResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -2592,6 +3804,30 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUser( userId string, ) (struct{}, error) { + response, body, error := client.UnlinkRichMenuIdFromUserWithHttpInfo( + + userId, + ) + + defer response.Body.Close() + + return body, error +} + +// UnlinkRichMenuIdFromUser +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Unlink rich menu from user +// Parameters: +// userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#unlink-rich-menu-from-user +func (client *MessagingApiAPI) UnlinkRichMenuIdFromUserWithHttpInfo( + + userId string, + +) (*http.Response, struct{}, error) { path := "/v2/bot/user/{userId}/richmenu" path = strings.Replace(path, "{userId}", userId, -1) @@ -2599,27 +3835,27 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUser( log.Printf("Sending request: method=Delete path=%s\n", path) req, err := http.NewRequest(http.MethodDelete, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2635,17 +3871,41 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUsers( richMenuBulkUnlinkRequest *RichMenuBulkUnlinkRequest, ) (struct{}, error) { + response, body, error := client.UnlinkRichMenuIdFromUsersWithHttpInfo( + + richMenuBulkUnlinkRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// UnlinkRichMenuIdFromUsers +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Unlink rich menus from multiple users +// Parameters: +// richMenuBulkUnlinkRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#unlink-rich-menu-from-users +func (client *MessagingApiAPI) UnlinkRichMenuIdFromUsersWithHttpInfo( + + richMenuBulkUnlinkRequest *RichMenuBulkUnlinkRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/bulk/unlink" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(richMenuBulkUnlinkRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2653,20 +3913,20 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUsers( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2685,6 +3945,35 @@ func (client *MessagingApiAPI) UpdateRichMenuAlias( updateRichMenuAliasRequest *UpdateRichMenuAliasRequest, ) (struct{}, error) { + response, body, error := client.UpdateRichMenuAliasWithHttpInfo( + + richMenuAliasId, + + updateRichMenuAliasRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// UpdateRichMenuAlias +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Update rich menu alias +// Parameters: +// richMenuAliasId The rich menu alias ID you want to update. +// updateRichMenuAliasRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#update-rich-menu-alias +func (client *MessagingApiAPI) UpdateRichMenuAliasWithHttpInfo( + + richMenuAliasId string, + + updateRichMenuAliasRequest *UpdateRichMenuAliasRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/alias/{richMenuAliasId}" path = strings.Replace(path, "{richMenuAliasId}", richMenuAliasId, -1) @@ -2692,12 +3981,12 @@ func (client *MessagingApiAPI) UpdateRichMenuAlias( var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(updateRichMenuAliasRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2705,20 +3994,20 @@ func (client *MessagingApiAPI) UpdateRichMenuAlias( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2734,17 +4023,41 @@ func (client *MessagingApiAPI) ValidateBroadcast( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { + response, body, error := client.ValidateBroadcastWithHttpInfo( + + validateMessageRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// ValidateBroadcast +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Validate message objects of a broadcast message +// Parameters: +// validateMessageRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-broadcast-message +func (client *MessagingApiAPI) ValidateBroadcastWithHttpInfo( + + validateMessageRequest *ValidateMessageRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/message/validate/broadcast" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(validateMessageRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2752,20 +4065,20 @@ func (client *MessagingApiAPI) ValidateBroadcast( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2781,17 +4094,41 @@ func (client *MessagingApiAPI) ValidateMulticast( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { + response, body, error := client.ValidateMulticastWithHttpInfo( + + validateMessageRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// ValidateMulticast +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Validate message objects of a multicast message +// Parameters: +// validateMessageRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-multicast-message +func (client *MessagingApiAPI) ValidateMulticastWithHttpInfo( + + validateMessageRequest *ValidateMessageRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/message/validate/multicast" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(validateMessageRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2799,20 +4136,20 @@ func (client *MessagingApiAPI) ValidateMulticast( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2828,17 +4165,41 @@ func (client *MessagingApiAPI) ValidateNarrowcast( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { + response, body, error := client.ValidateNarrowcastWithHttpInfo( + + validateMessageRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// ValidateNarrowcast +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Validate message objects of a narrowcast message +// Parameters: +// validateMessageRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-narrowcast-message +func (client *MessagingApiAPI) ValidateNarrowcastWithHttpInfo( + + validateMessageRequest *ValidateMessageRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/message/validate/narrowcast" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(validateMessageRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2846,20 +4207,20 @@ func (client *MessagingApiAPI) ValidateNarrowcast( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2875,17 +4236,41 @@ func (client *MessagingApiAPI) ValidatePush( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { + response, body, error := client.ValidatePushWithHttpInfo( + + validateMessageRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// ValidatePush +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Validate message objects of a push message +// Parameters: +// validateMessageRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-push-message +func (client *MessagingApiAPI) ValidatePushWithHttpInfo( + + validateMessageRequest *ValidateMessageRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/message/validate/push" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(validateMessageRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2893,20 +4278,20 @@ func (client *MessagingApiAPI) ValidatePush( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2922,17 +4307,41 @@ func (client *MessagingApiAPI) ValidateReply( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { + response, body, error := client.ValidateReplyWithHttpInfo( + + validateMessageRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// ValidateReply +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Validate message objects of a reply message +// Parameters: +// validateMessageRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-reply-message +func (client *MessagingApiAPI) ValidateReplyWithHttpInfo( + + validateMessageRequest *ValidateMessageRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/message/validate/reply" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(validateMessageRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2940,20 +4349,20 @@ func (client *MessagingApiAPI) ValidateReply( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -2969,17 +4378,41 @@ func (client *MessagingApiAPI) ValidateRichMenuBatchRequest( richMenuBatchRequest *RichMenuBatchRequest, ) (struct{}, error) { + response, body, error := client.ValidateRichMenuBatchRequestWithHttpInfo( + + richMenuBatchRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// ValidateRichMenuBatchRequest +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Validate a request body of the Replace or unlink the linked rich menus in batches endpoint. +// Parameters: +// richMenuBatchRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#validate-batch-control-rich-menus-request +func (client *MessagingApiAPI) ValidateRichMenuBatchRequestWithHttpInfo( + + richMenuBatchRequest *RichMenuBatchRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/validate/batch" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(richMenuBatchRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -2987,20 +4420,20 @@ func (client *MessagingApiAPI) ValidateRichMenuBatchRequest( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -3016,17 +4449,41 @@ func (client *MessagingApiAPI) ValidateRichMenuObject( richMenuRequest *RichMenuRequest, ) (struct{}, error) { + response, body, error := client.ValidateRichMenuObjectWithHttpInfo( + + richMenuRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// ValidateRichMenuObject +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Validate rich menu object +// Parameters: +// richMenuRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#validate-rich-menu-object +func (client *MessagingApiAPI) ValidateRichMenuObjectWithHttpInfo( + + richMenuRequest *RichMenuRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/validate" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(richMenuRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -3034,19 +4491,19 @@ func (client *MessagingApiAPI) ValidateRichMenuObject( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } diff --git a/linebot/messaging_api/api_messaging_api_blob.go b/linebot/messaging_api/api_messaging_api_blob.go index 229dee88..6adcfa66 100644 --- a/linebot/messaging_api/api_messaging_api_blob.go +++ b/linebot/messaging_api/api_messaging_api_blob.go @@ -127,6 +127,28 @@ func (client *MessagingApiBlobAPI) GetMessageContent( messageId string, ) (*http.Response, error) { + _, body, error := client.GetMessageContentWithHttpInfo( + + messageId, + ) + + return body, error +} + +// GetMessageContent +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Download image, video, and audio data sent from users. +// Parameters: +// messageId Message ID of video or audio + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-content +func (client *MessagingApiBlobAPI) GetMessageContentWithHttpInfo( + + messageId string, + +) (*http.Response, *http.Response, error) { path := "/v2/bot/message/{messageId}/content" path = strings.Replace(path, "{messageId}", messageId, -1) @@ -134,25 +156,25 @@ func (client *MessagingApiBlobAPI) GetMessageContent( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } - return res, nil + return res, res, nil } @@ -169,6 +191,28 @@ func (client *MessagingApiBlobAPI) GetMessageContentPreview( messageId string, ) (*http.Response, error) { + _, body, error := client.GetMessageContentPreviewWithHttpInfo( + + messageId, + ) + + return body, error +} + +// GetMessageContentPreview +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Get a preview image of the image or video +// Parameters: +// messageId Message ID of image or video + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#get-image-or-video-preview +func (client *MessagingApiBlobAPI) GetMessageContentPreviewWithHttpInfo( + + messageId string, + +) (*http.Response, *http.Response, error) { path := "/v2/bot/message/{messageId}/content/preview" path = strings.Replace(path, "{messageId}", messageId, -1) @@ -176,25 +220,25 @@ func (client *MessagingApiBlobAPI) GetMessageContentPreview( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } - return res, nil + return res, res, nil } @@ -210,6 +254,30 @@ func (client *MessagingApiBlobAPI) GetMessageContentTranscodingByMessageId( messageId string, ) (*GetMessageContentTranscodingResponse, error) { + response, body, error := client.GetMessageContentTranscodingByMessageIdWithHttpInfo( + + messageId, + ) + + defer response.Body.Close() + + return body, error +} + +// GetMessageContentTranscodingByMessageId +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Verify the preparation status of a video or audio for getting +// Parameters: +// messageId Message ID of video or audio + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#verify-video-or-audio-preparation-status +func (client *MessagingApiBlobAPI) GetMessageContentTranscodingByMessageIdWithHttpInfo( + + messageId string, + +) (*http.Response, *GetMessageContentTranscodingResponse, error) { path := "/v2/bot/message/{messageId}/content/transcoding" path = strings.Replace(path, "{messageId}", messageId, -1) @@ -217,22 +285,22 @@ func (client *MessagingApiBlobAPI) GetMessageContentTranscodingByMessageId( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -240,9 +308,9 @@ func (client *MessagingApiBlobAPI) GetMessageContentTranscodingByMessageId( decoder := json.NewDecoder(res.Body) result := GetMessageContentTranscodingResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -259,6 +327,28 @@ func (client *MessagingApiBlobAPI) GetRichMenuImage( richMenuId string, ) (*http.Response, error) { + _, body, error := client.GetRichMenuImageWithHttpInfo( + + richMenuId, + ) + + return body, error +} + +// GetRichMenuImage +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Download rich menu image. +// Parameters: +// richMenuId ID of the rich menu with the image to be downloaded + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#download-rich-menu-image +func (client *MessagingApiBlobAPI) GetRichMenuImageWithHttpInfo( + + richMenuId string, + +) (*http.Response, *http.Response, error) { path := "/v2/bot/richmenu/{richMenuId}/content" path = strings.Replace(path, "{richMenuId}", richMenuId, -1) @@ -266,25 +356,25 @@ func (client *MessagingApiBlobAPI) GetRichMenuImage( log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } - return res, nil + return res, res, nil } @@ -305,6 +395,38 @@ func (client *MessagingApiBlobAPI) SetRichMenuImage( bodyReader io.Reader, ) (struct{}, error) { + response, body, error := client.SetRichMenuImageWithHttpInfo( + + richMenuId, + + bodyContentType, + bodyReader, + ) + + defer response.Body.Close() + + return body, error +} + +// SetRichMenuImage +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Upload rich menu image +// Parameters: +// richMenuId The ID of the rich menu to attach the image to +// bodyContentType content-type +// bodyReader file content + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/messaging-api/#upload-rich-menu-image +func (client *MessagingApiBlobAPI) SetRichMenuImageWithHttpInfo( + + richMenuId string, + + bodyContentType string, + bodyReader io.Reader, + +) (*http.Response, struct{}, error) { path := "/v2/bot/richmenu/{richMenuId}/content" path = strings.Replace(path, "{richMenuId}", richMenuId, -1) @@ -312,7 +434,7 @@ func (client *MessagingApiBlobAPI) SetRichMenuImage( log.Printf("Sending request: method=Post path=%s bodyContentType=%s\n", path, bodyContentType) req, err := http.NewRequest(http.MethodPost, client.Url(path), bodyReader) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", bodyContentType) @@ -320,19 +442,19 @@ func (client *MessagingApiBlobAPI) SetRichMenuImage( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } diff --git a/linebot/messaging_api/tests/handwritten/api_WithHttpInfo_test.go b/linebot/messaging_api/tests/handwritten/api_WithHttpInfo_test.go new file mode 100644 index 00000000..d2db09b4 --- /dev/null +++ b/linebot/messaging_api/tests/handwritten/api_WithHttpInfo_test.go @@ -0,0 +1,43 @@ +package tests + +import ( + "log" + "net/http" + "net/http/httptest" + "testing" + + "github.com/line/line-bot-sdk-go/v7/linebot/messaging_api" +) + +func TestTextMessageWithHttpInfo(t *testing.T) { + server := httptest.NewServer( + http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Add("X-Line-Request-Id", "1234567890") + w.Write([]byte(`{}`)) + }), + ) + client, err := messaging_api.NewMessagingApiAPI( + "channelToken", + messaging_api.WithEndpoint(server.URL), + ) + if err != nil { + t.Fatalf("Failed to create client: %v", err) + } + resp, _, err := client.PushMessageWithHttpInfo(&messaging_api.PushMessageRequest{ + Messages: []messaging_api.MessageInterface{ + &messaging_api.TextMessage{ + Text: "Hello, world", + }, + }, + }, "") + if err != nil { + t.Fatalf("Failed to create audience: %v", err) + } + log.Printf("Got response: %v", resp) + if resp.StatusCode != http.StatusOK { + t.Errorf("status: %d", resp.StatusCode) + } + if resp.Header.Get("X-Line-Request-Id") != "1234567890" { + t.Errorf("X-Line-Request-Id: %s", resp.Header.Get("X-Line-Request-Id")) + } +} diff --git a/linebot/module/api_line_module.go b/linebot/module/api_line_module.go index 08c44c5d..00599478 100644 --- a/linebot/module/api_line_module.go +++ b/linebot/module/api_line_module.go @@ -130,6 +130,35 @@ func (client *LineModuleAPI) AcquireChatControl( acquireChatControlRequest *AcquireChatControlRequest, ) (struct{}, error) { + response, body, error := client.AcquireChatControlWithHttpInfo( + + chatId, + + acquireChatControlRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// AcquireChatControl +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// If the Standby Channel wants to take the initiative (Chat Control), it calls the Acquire Control API. The channel that was previously an Active Channel will automatically switch to a Standby Channel. +// Parameters: +// chatId The `userId`, `roomId`, or `groupId` +// acquireChatControlRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#acquire-control-api +func (client *LineModuleAPI) AcquireChatControlWithHttpInfo( + + chatId string, + + acquireChatControlRequest *AcquireChatControlRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/chat/{chatId}/control/acquire" path = strings.Replace(path, "{chatId}", chatId, -1) @@ -137,12 +166,12 @@ func (client *LineModuleAPI) AcquireChatControl( var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(acquireChatControlRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -150,20 +179,20 @@ func (client *LineModuleAPI) AcquireChatControl( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -179,17 +208,41 @@ func (client *LineModuleAPI) DetachModule( detachModuleRequest *DetachModuleRequest, ) (struct{}, error) { + response, body, error := client.DetachModuleWithHttpInfo( + + detachModuleRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// DetachModule +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// The module channel admin calls the Detach API to detach the module channel from a LINE Official Account. +// Parameters: +// detachModuleRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#unlink-detach-module-channel-by-operation-mc-admin +func (client *LineModuleAPI) DetachModuleWithHttpInfo( + + detachModuleRequest *DetachModuleRequest, + +) (*http.Response, struct{}, error) { path := "/v2/bot/channel/detach" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(detachModuleRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -197,20 +250,20 @@ func (client *LineModuleAPI) DetachModule( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } @@ -229,12 +282,41 @@ func (client *LineModuleAPI) GetModules( limit int32, ) (*GetModulesResponse, error) { + response, body, error := client.GetModulesWithHttpInfo( + + start, + + limit, + ) + + defer response.Body.Close() + + return body, error +} + +// GetModules +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Gets a list of basic information about the bots of multiple LINE Official Accounts that have attached module channels. +// Parameters: +// start Value of the continuation token found in the next property of the JSON object returned in the response. If you can't get all basic information about the bots in one request, include this parameter to get the remaining array. +// limit Specify the maximum number of bots that you get basic information from. The default value is 100. Max value: 100 + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#get-multiple-bot-info-api +func (client *LineModuleAPI) GetModulesWithHttpInfo( + + start string, + + limit int32, + +) (*http.Response, *GetModulesResponse, error) { path := "/v2/bot/list" log.Printf("Sending request: method=Get path=%s\n", path) req, err := http.NewRequest(http.MethodGet, client.Url(path), nil) if err != nil { - return nil, err + return nil, nil, err } var query url.Values @@ -247,15 +329,15 @@ func (client *LineModuleAPI) GetModules( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -263,9 +345,9 @@ func (client *LineModuleAPI) GetModules( decoder := json.NewDecoder(res.Body) result := GetModulesResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } @@ -281,6 +363,30 @@ func (client *LineModuleAPI) ReleaseChatControl( chatId string, ) (struct{}, error) { + response, body, error := client.ReleaseChatControlWithHttpInfo( + + chatId, + ) + + defer response.Body.Close() + + return body, error +} + +// ReleaseChatControl +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// To return the initiative (Chat Control) of Active Channel to Primary Channel, call the Release Control API. +// Parameters: +// chatId The `userId`, `roomId`, or `groupId` + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#release-control-api +func (client *LineModuleAPI) ReleaseChatControlWithHttpInfo( + + chatId string, + +) (*http.Response, struct{}, error) { path := "/v2/bot/chat/{chatId}/control/release" path = strings.Replace(path, "{chatId}", chatId, -1) @@ -288,26 +394,26 @@ func (client *LineModuleAPI) ReleaseChatControl( log.Printf("Sending request: method=Post path=%s\n", path) req, err := http.NewRequest(http.MethodPost, client.Url(path), nil) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } res, err := client.Do(req) log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } diff --git a/linebot/module_attach/api_line_module_attach.go b/linebot/module_attach/api_line_module_attach.go index d882cc2d..c7d028c0 100644 --- a/linebot/module_attach/api_line_module_attach.go +++ b/linebot/module_attach/api_line_module_attach.go @@ -153,6 +153,75 @@ func (client *LineModuleAttachAPI) AttachModule( brandType string, ) (*AttachModuleResponse, error) { + response, body, error := client.AttachModuleWithHttpInfo( + + grantType, + + code, + + redirectUri, + + codeVerifier, + + clientId, + + clientSecret, + + region, + + basicSearchId, + + scope, + + brandType, + ) + + defer response.Body.Close() + + return body, error +} + +// AttachModule +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Attach by operation of the module channel provider +// Parameters: +// grantType authorization_code +// code Authorization code received from the LINE Platform. +// redirectUri Specify the redirect_uri specified in the URL for authentication and authorization. +// codeVerifier Specify when using PKCE (Proof Key for Code Exchange) defined in the OAuth 2.0 extension specification as a countermeasure against authorization code interception attacks. +// clientId Instead of using Authorization header, you can use this parameter to specify the channel ID of the module channel. You can find the channel ID of the module channel in the LINE Developers Console. +// clientSecret Instead of using Authorization header, you can use this parameter to specify the channel secret of the module channel. You can find the channel secret of the module channel in the LINE Developers Console. +// region If you specified a value for region in the URL for authentication and authorization, specify the same value. +// basicSearchId If you specified a value for basic_search_id in the URL for authentication and authorization, specify the same value. +// scope If you specified a value for scope in the URL for authentication and authorization, specify the same value. +// brandType If you specified a value for brand_type in the URL for authentication and authorization, specify the same value. + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#link-attach-by-operation-module-channel-provider +func (client *LineModuleAttachAPI) AttachModuleWithHttpInfo( + + grantType string, + + code string, + + redirectUri string, + + codeVerifier string, + + clientId string, + + clientSecret string, + + region string, + + basicSearchId string, + + scope string, + + brandType string, + +) (*http.Response, *AttachModuleResponse, error) { path := "/module/auth/v1/token" vs := url.Values{ @@ -173,7 +242,7 @@ func (client *LineModuleAttachAPI) AttachModule( log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf) req, err := http.NewRequest(http.MethodPost, client.Url(path), body) if err != nil { - return nil, err + return nil, nil, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") @@ -181,15 +250,15 @@ func (client *LineModuleAttachAPI) AttachModule( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return nil, err + return res, nil, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + return res, nil, fmt.Errorf("failed to read response body: %w", err) } - return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() @@ -197,8 +266,8 @@ func (client *LineModuleAttachAPI) AttachModule( decoder := json.NewDecoder(res.Body) result := AttachModuleResponse{} if err := decoder.Decode(&result); err != nil { - return nil, fmt.Errorf("failed to decode JSON: %w", err) + return res, nil, fmt.Errorf("failed to decode JSON: %w", err) } - return &result, nil + return res, &result, nil } diff --git a/linebot/shop/api_shop.go b/linebot/shop/api_shop.go index c7aa05ba..136c3d85 100644 --- a/linebot/shop/api_shop.go +++ b/linebot/shop/api_shop.go @@ -126,17 +126,41 @@ func (client *ShopAPI) MissionStickerV3( missionStickerRequest *MissionStickerRequest, ) (struct{}, error) { + response, body, error := client.MissionStickerV3WithHttpInfo( + + missionStickerRequest, + ) + + defer response.Body.Close() + + return body, error +} + +// MissionStickerV3 +// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature. +// +// Sends a mission sticker. +// Parameters: +// missionStickerRequest + +// You must close the response body when finished with it. +// https://developers.line.biz/en/reference/partner-docs/#send-mission-stickers-v3 +func (client *ShopAPI) MissionStickerV3WithHttpInfo( + + missionStickerRequest *MissionStickerRequest, + +) (*http.Response, struct{}, error) { path := "/shop/v3/mission" var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(missionStickerRequest); err != nil { - return struct{}{}, err + return nil, struct{}{}, err } log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String()) req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf) if err != nil { - return struct{}{}, err + return nil, struct{}{}, err } req.Header.Set("Content-Type", "application/json; charset=UTF-8") @@ -144,19 +168,19 @@ func (client *ShopAPI) MissionStickerV3( log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength) if err != nil { - return struct{}{}, err + return res, struct{}{}, err } if res.StatusCode/100 != 2 { body, err := io.ReadAll(res.Body) if err != nil { - return struct{}{}, fmt.Errorf("failed to read response body: %w", err) + return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err) } - return struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) + return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(body)) } defer res.Body.Close() - return struct{}{}, nil + return res, struct{}{}, nil } From 44a1a93a09b40300fad8858ec9ffeb2e165b950b Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Mon, 6 Nov 2023 15:15:26 +0900 Subject: [PATCH 2/5] oops --- .../src/main/resources/line-bot-sdk-go-generator/api.pebble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble b/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble index 66c9bd3d..604fa80b 100644 --- a/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble +++ b/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble @@ -171,7 +171,7 @@ func (client *{{ classname }}) {{ op.operationId }}( // {{ param.paramName }} {{ param.description }} {%- endif %} {% endfor %} -// You must close the response body when finished with it. +{% if op.isResponseFile %}// You must close the response body when finished with it.{% endif %} {% if op.externalDocs != null -%}// {{op.externalDocs.url}}{% endif %} func (client *{{ classname }}) {{ op.operationId }}WithHttpInfo( {% for param in op.allParams %} From d4b7f4f3313476dff5fac543f74d7218483a0d0b Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Mon, 6 Nov 2023 15:16:48 +0900 Subject: [PATCH 3/5] oops --- .../api_channel_access_token.go | 8 --- linebot/insight/api_insight.go | 5 -- linebot/liff/api_liff.go | 4 -- .../manage_audience/api_manage_audience.go | 11 ---- .../api_manage_audience_blob.go | 2 - linebot/messaging_api/api_messaging_api.go | 61 ------------------- .../messaging_api/api_messaging_api_blob.go | 2 - linebot/module/api_line_module.go | 4 -- .../module_attach/api_line_module_attach.go | 1 - linebot/shop/api_shop.go | 1 - 10 files changed, 99 deletions(-) diff --git a/linebot/channel_access_token/api_channel_access_token.go b/linebot/channel_access_token/api_channel_access_token.go index 5507e0b8..cf087e49 100644 --- a/linebot/channel_access_token/api_channel_access_token.go +++ b/linebot/channel_access_token/api_channel_access_token.go @@ -149,7 +149,6 @@ func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIds( // clientAssertionType `urn:ietf:params:oauth:client-assertion-type:jwt-bearer` // clientAssertion A JSON Web Token (JWT) (opens new window)the client needs to create and sign with the private key. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-all-valid-channel-access-token-key-ids-v2-1 func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIdsWithHttpInfo( @@ -239,7 +238,6 @@ func (client *ChannelAccessTokenAPI) IssueChannelToken( // clientId Channel ID. // clientSecret Channel secret. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#issue-shortlived-channel-access-token func (client *ChannelAccessTokenAPI) IssueChannelTokenWithHttpInfo( @@ -334,7 +332,6 @@ func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWT( // clientAssertionType urn:ietf:params:oauth:client-assertion-type:jwt-bearer // clientAssertion A JSON Web Token the client needs to create and sign with the private key of the Assertion Signing Key. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#issue-channel-access-token-v2-1 func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWTWithHttpInfo( @@ -441,7 +438,6 @@ func (client *ChannelAccessTokenAPI) IssueStatelessChannelToken( // clientId Channel ID. // clientSecret Channel secret. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#issue-stateless-channel-access-token func (client *ChannelAccessTokenAPI) IssueStatelessChannelTokenWithHttpInfo( @@ -530,7 +526,6 @@ func (client *ChannelAccessTokenAPI) RevokeChannelToken( // Parameters: // accessToken Channel access token -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#revoke-longlived-or-shortlived-channel-access-token func (client *ChannelAccessTokenAPI) RevokeChannelTokenWithHttpInfo( @@ -614,7 +609,6 @@ func (client *ChannelAccessTokenAPI) RevokeChannelTokenByJWT( // clientSecret Channel Secret // accessToken Channel access token -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#revoke-channel-access-token-v2-1 func (client *ChannelAccessTokenAPI) RevokeChannelTokenByJWTWithHttpInfo( @@ -692,7 +686,6 @@ func (client *ChannelAccessTokenAPI) VerifyChannelToken( // Parameters: // accessToken A short-lived or long-lived channel access token. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#verfiy-channel-access-token func (client *ChannelAccessTokenAPI) VerifyChannelTokenWithHttpInfo( @@ -769,7 +762,6 @@ func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWT( // Parameters: // accessToken Channel access token with a user-specified expiration (Channel Access Token v2.1). -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#verfiy-channel-access-token-v2-1 func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWTWithHttpInfo( diff --git a/linebot/insight/api_insight.go b/linebot/insight/api_insight.go index 2348024c..4fab9f49 100644 --- a/linebot/insight/api_insight.go +++ b/linebot/insight/api_insight.go @@ -133,7 +133,6 @@ func (client *InsightAPI) GetFriendsDemographics() (*GetFriendsDemographicsRespo // Retrieves the demographic attributes for a LINE Official Account's friends.You can only retrieve information about friends for LINE Official Accounts created by users in Japan (JP), Thailand (TH), Taiwan (TW) and Indonesia (ID). // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-demographic func (client *InsightAPI) GetFriendsDemographicsWithHttpInfo() (*http.Response, *GetFriendsDemographicsResponse, error) { path := "/v2/bot/insight/demographic" @@ -199,7 +198,6 @@ func (client *InsightAPI) GetMessageEvent( // Parameters: // requestId Request ID of a narrowcast message or broadcast message. Each Messaging API request has a request ID. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-message-event func (client *InsightAPI) GetMessageEventWithHttpInfo( @@ -274,7 +272,6 @@ func (client *InsightAPI) GetNumberOfFollowers( // Parameters: // date Date for which to retrieve the number of followers. Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-number-of-followers func (client *InsightAPI) GetNumberOfFollowersWithHttpInfo( @@ -349,7 +346,6 @@ func (client *InsightAPI) GetNumberOfMessageDeliveries( // Parameters: // date Date for which to retrieve number of sent messages. - Format: yyyyMMdd (e.g. 20191231) - Timezone: UTC+9 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-number-of-delivery-messages func (client *InsightAPI) GetNumberOfMessageDeliveriesWithHttpInfo( @@ -436,7 +432,6 @@ func (client *InsightAPI) GetStatisticsPerUnit( // from Start date of aggregation period. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9 // to End date of aggregation period. The end date can be specified for up to 30 days later. For example, if the start date is 20210301, the latest end date is 20210331. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-statistics-per-unit func (client *InsightAPI) GetStatisticsPerUnitWithHttpInfo( diff --git a/linebot/liff/api_liff.go b/linebot/liff/api_liff.go index 6235cabe..5182121b 100644 --- a/linebot/liff/api_liff.go +++ b/linebot/liff/api_liff.go @@ -144,7 +144,6 @@ func (client *LiffAPI) AddLIFFApp( // Parameters: // addLiffAppRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/liff-server/#add-liff-app func (client *LiffAPI) AddLIFFAppWithHttpInfo( @@ -220,7 +219,6 @@ func (client *LiffAPI) DeleteLIFFApp( // Parameters: // liffId ID of the LIFF app to be updated -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/liff-server/#delete-liff-app func (client *LiffAPI) DeleteLIFFAppWithHttpInfo( @@ -278,7 +276,6 @@ func (client *LiffAPI) GetAllLIFFApps() (*GetAllLiffAppsResponse, error) { // Gets information on all the LIFF apps added to the channel. // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/liff-server/#get-all-liff-apps func (client *LiffAPI) GetAllLIFFAppsWithHttpInfo() (*http.Response, *GetAllLiffAppsResponse, error) { path := "/liff/v1/apps" @@ -350,7 +347,6 @@ func (client *LiffAPI) UpdateLIFFApp( // liffId ID of the LIFF app to be updated // updateLiffAppRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/liff-server/#update-liff-app func (client *LiffAPI) UpdateLIFFAppWithHttpInfo( diff --git a/linebot/manage_audience/api_manage_audience.go b/linebot/manage_audience/api_manage_audience.go index 52cd8eda..18176f65 100644 --- a/linebot/manage_audience/api_manage_audience.go +++ b/linebot/manage_audience/api_manage_audience.go @@ -145,7 +145,6 @@ func (client *ManageAudienceAPI) ActivateAudienceGroup( // Parameters: // audienceGroupId The audience ID. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#activate-audience-group func (client *ManageAudienceAPI) ActivateAudienceGroupWithHttpInfo( @@ -212,7 +211,6 @@ func (client *ManageAudienceAPI) AddAudienceToAudienceGroup( // Parameters: // addAudienceToAudienceGroupRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group func (client *ManageAudienceAPI) AddAudienceToAudienceGroupWithHttpInfo( @@ -283,7 +281,6 @@ func (client *ManageAudienceAPI) CreateAudienceGroup( // Parameters: // createAudienceGroupRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group func (client *ManageAudienceAPI) CreateAudienceGroupWithHttpInfo( @@ -359,7 +356,6 @@ func (client *ManageAudienceAPI) CreateClickBasedAudienceGroup( // Parameters: // createClickBasedAudienceGroupRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#create-click-audience-group func (client *ManageAudienceAPI) CreateClickBasedAudienceGroupWithHttpInfo( @@ -435,7 +431,6 @@ func (client *ManageAudienceAPI) CreateImpBasedAudienceGroup( // Parameters: // createImpBasedAudienceGroupRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#create-imp-audience-group func (client *ManageAudienceAPI) CreateImpBasedAudienceGroupWithHttpInfo( @@ -511,7 +506,6 @@ func (client *ManageAudienceAPI) DeleteAudienceGroup( // Parameters: // audienceGroupId The audience ID. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#delete-audience-group func (client *ManageAudienceAPI) DeleteAudienceGroupWithHttpInfo( @@ -578,7 +572,6 @@ func (client *ManageAudienceAPI) GetAudienceData( // Parameters: // audienceGroupId The audience ID. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-audience-group func (client *ManageAudienceAPI) GetAudienceDataWithHttpInfo( @@ -641,7 +634,6 @@ func (client *ManageAudienceAPI) GetAudienceGroupAuthorityLevel() (*GetAudienceG // Get the authority level of the audience // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-authority-level func (client *ManageAudienceAPI) GetAudienceGroupAuthorityLevelWithHttpInfo() (*http.Response, *GetAudienceGroupAuthorityLevelResponse, error) { path := "/v2/bot/audienceGroup/authorityLevel" @@ -737,7 +729,6 @@ func (client *ManageAudienceAPI) GetAudienceGroups( // includesExternalPublicGroups true (default): Get public audiences created in all channels linked to the same bot. false: Get audiences created in the same channel. // createRoute How the audience was created. If omitted, all audiences are included. `OA_MANAGER`: Return only audiences created with LINE Official Account Manager (opens new window). `MESSAGING_API`: Return only audiences created with Messaging API. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-audience-groups func (client *ManageAudienceAPI) GetAudienceGroupsWithHttpInfo( @@ -827,7 +818,6 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupAuthorityLevel( // Parameters: // updateAudienceGroupAuthorityLevelRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#change-authority-level func (client *ManageAudienceAPI) UpdateAudienceGroupAuthorityLevelWithHttpInfo( @@ -904,7 +894,6 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupDescription( // audienceGroupId The audience ID. // updateAudienceGroupDescriptionRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#set-description-audience-group func (client *ManageAudienceAPI) UpdateAudienceGroupDescriptionWithHttpInfo( diff --git a/linebot/manage_audience/api_manage_audience_blob.go b/linebot/manage_audience/api_manage_audience_blob.go index f06b2ad0..70d18a91 100644 --- a/linebot/manage_audience/api_manage_audience_blob.go +++ b/linebot/manage_audience/api_manage_audience_blob.go @@ -158,7 +158,6 @@ func (client *ManageAudienceBlobAPI) AddUserIdsToAudience( // audienceGroupId The audience ID. // uploadDescription The description to register with the job -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group-by-file func (client *ManageAudienceBlobAPI) AddUserIdsToAudienceWithHttpInfo( @@ -264,7 +263,6 @@ func (client *ManageAudienceBlobAPI) CreateAudienceForUploadingUserIds( // isIfaAudience To specify recipients by IFAs: set `true`. To specify recipients by user IDs: set `false` or omit isIfaAudience property. // uploadDescription The description to register for the job (in `jobs[].description`). -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group-by-file func (client *ManageAudienceBlobAPI) CreateAudienceForUploadingUserIdsWithHttpInfo( diff --git a/linebot/messaging_api/api_messaging_api.go b/linebot/messaging_api/api_messaging_api.go index a257266e..ee942fa4 100644 --- a/linebot/messaging_api/api_messaging_api.go +++ b/linebot/messaging_api/api_messaging_api.go @@ -144,7 +144,6 @@ func (client *MessagingApiAPI) AudienceMatch( // Parameters: // audienceMatchMessagesRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#phone-audience-match func (client *MessagingApiAPI) AudienceMatchWithHttpInfo( @@ -221,7 +220,6 @@ func (client *MessagingApiAPI) Broadcast( // broadcastRequest // xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn't generated by LINE. Each developer must generate their own retry key. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message func (client *MessagingApiAPI) BroadcastWithHttpInfo( @@ -292,7 +290,6 @@ func (client *MessagingApiAPI) CancelDefaultRichMenu() (struct{}, error) { // Cancel default rich menu // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#cancel-default-rich-menu func (client *MessagingApiAPI) CancelDefaultRichMenuWithHttpInfo() (*http.Response, struct{}, error) { path := "/v2/bot/user/all/richmenu" @@ -353,7 +350,6 @@ func (client *MessagingApiAPI) CreateRichMenu( // Parameters: // richMenuRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#create-rich-menu func (client *MessagingApiAPI) CreateRichMenuWithHttpInfo( @@ -429,7 +425,6 @@ func (client *MessagingApiAPI) CreateRichMenuAlias( // Parameters: // createRichMenuAliasRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#create-rich-menu-alias func (client *MessagingApiAPI) CreateRichMenuAliasWithHttpInfo( @@ -500,7 +495,6 @@ func (client *MessagingApiAPI) DeleteRichMenu( // Parameters: // richMenuId ID of a rich menu -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu func (client *MessagingApiAPI) DeleteRichMenuWithHttpInfo( @@ -567,7 +561,6 @@ func (client *MessagingApiAPI) DeleteRichMenuAlias( // Parameters: // richMenuAliasId Rich menu alias ID that you want to delete. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#delete-rich-menu-alias func (client *MessagingApiAPI) DeleteRichMenuAliasWithHttpInfo( @@ -634,7 +627,6 @@ func (client *MessagingApiAPI) GetAdPhoneMessageStatistics( // Parameters: // date Date the message was sent Format: `yyyyMMdd` (e.g. `20190831`) Time Zone: UTC+9 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#get-phone-audience-match func (client *MessagingApiAPI) GetAdPhoneMessageStatisticsWithHttpInfo( @@ -715,7 +707,6 @@ func (client *MessagingApiAPI) GetAggregationUnitNameList( // limit The maximum number of aggregation units you can get per request. // start Value of the continuation token found in the next property of the JSON object returned in the response. If you can't get all the aggregation units in one request, include this parameter to get the remaining array. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-name-list-of-units-used-this-month func (client *MessagingApiAPI) GetAggregationUnitNameListWithHttpInfo( @@ -784,7 +775,6 @@ func (client *MessagingApiAPI) GetAggregationUnitUsage() (*GetAggregationUnitUsa // Get number of units used this month // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-number-of-units-used-this-month func (client *MessagingApiAPI) GetAggregationUnitUsageWithHttpInfo() (*http.Response, *GetAggregationUnitUsageResponse, error) { path := "/v2/bot/message/aggregation/info" @@ -841,7 +831,6 @@ func (client *MessagingApiAPI) GetBotInfo() (*BotInfoResponse, error) { // Get bot info // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-bot-info func (client *MessagingApiAPI) GetBotInfoWithHttpInfo() (*http.Response, *BotInfoResponse, error) { path := "/v2/bot/info" @@ -898,7 +887,6 @@ func (client *MessagingApiAPI) GetDefaultRichMenuId() (*RichMenuIdResponse, erro // Gets the ID of the default rich menu set with the Messaging API. // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-default-rich-menu-id func (client *MessagingApiAPI) GetDefaultRichMenuIdWithHttpInfo() (*http.Response, *RichMenuIdResponse, error) { path := "/v2/bot/user/all/richmenu" @@ -970,7 +958,6 @@ func (client *MessagingApiAPI) GetFollowers( // start Value of the continuation token found in the next property of the JSON object returned in the response. Include this parameter to get the next array of user IDs. // limit The maximum number of user IDs to retrieve in a single request. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-follower-ids func (client *MessagingApiAPI) GetFollowersWithHttpInfo( @@ -1048,7 +1035,6 @@ func (client *MessagingApiAPI) GetGroupMemberCount( // Parameters: // groupId Group ID -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-members-group-count func (client *MessagingApiAPI) GetGroupMemberCountWithHttpInfo( @@ -1126,7 +1112,6 @@ func (client *MessagingApiAPI) GetGroupMemberProfile( // groupId Group ID // userId User ID -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-group-member-profile func (client *MessagingApiAPI) GetGroupMemberProfileWithHttpInfo( @@ -1208,7 +1193,6 @@ func (client *MessagingApiAPI) GetGroupMembersIds( // groupId Group ID // start Value of the continuation token found in the `next` property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-group-member-user-ids func (client *MessagingApiAPI) GetGroupMembersIdsWithHttpInfo( @@ -1287,7 +1271,6 @@ func (client *MessagingApiAPI) GetGroupSummary( // Parameters: // groupId Group ID -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-group-summary func (client *MessagingApiAPI) GetGroupSummaryWithHttpInfo( @@ -1350,7 +1333,6 @@ func (client *MessagingApiAPI) GetMessageQuota() (*MessageQuotaResponse, error) // Gets the target limit for sending messages in the current month. The total number of the free messages and the additional messages is returned. // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-quota func (client *MessagingApiAPI) GetMessageQuotaWithHttpInfo() (*http.Response, *MessageQuotaResponse, error) { path := "/v2/bot/message/quota" @@ -1407,7 +1389,6 @@ func (client *MessagingApiAPI) GetMessageQuotaConsumption() (*QuotaConsumptionRe // Gets the number of messages sent in the current month. // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-consumption func (client *MessagingApiAPI) GetMessageQuotaConsumptionWithHttpInfo() (*http.Response, *QuotaConsumptionResponse, error) { path := "/v2/bot/message/quota/consumption" @@ -1473,7 +1454,6 @@ func (client *MessagingApiAPI) GetNarrowcastProgress( // Parameters: // requestId The narrowcast message's request ID. Each Messaging API request has a request ID. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-narrowcast-progress-status func (client *MessagingApiAPI) GetNarrowcastProgressWithHttpInfo( @@ -1548,7 +1528,6 @@ func (client *MessagingApiAPI) GetNumberOfSentBroadcastMessages( // Parameters: // date Date the messages were sent Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-number-of-broadcast-messages func (client *MessagingApiAPI) GetNumberOfSentBroadcastMessagesWithHttpInfo( @@ -1623,7 +1602,6 @@ func (client *MessagingApiAPI) GetNumberOfSentMulticastMessages( // Parameters: // date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-number-of-multicast-messages func (client *MessagingApiAPI) GetNumberOfSentMulticastMessagesWithHttpInfo( @@ -1698,7 +1676,6 @@ func (client *MessagingApiAPI) GetNumberOfSentPushMessages( // Parameters: // date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-number-of-push-messages func (client *MessagingApiAPI) GetNumberOfSentPushMessagesWithHttpInfo( @@ -1773,7 +1750,6 @@ func (client *MessagingApiAPI) GetNumberOfSentReplyMessages( // Parameters: // date Date the messages were sent Format: `yyyyMMdd` (e.g. `20191231`) Timezone: UTC+9 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-number-of-reply-messages func (client *MessagingApiAPI) GetNumberOfSentReplyMessagesWithHttpInfo( @@ -1848,7 +1824,6 @@ func (client *MessagingApiAPI) GetPNPMessageStatistics( // Parameters: // date Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#get-number-of-sent-line-notification-messages func (client *MessagingApiAPI) GetPNPMessageStatisticsWithHttpInfo( @@ -1923,7 +1898,6 @@ func (client *MessagingApiAPI) GetProfile( // Parameters: // userId User ID -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-profile func (client *MessagingApiAPI) GetProfileWithHttpInfo( @@ -1995,7 +1969,6 @@ func (client *MessagingApiAPI) GetRichMenu( // Parameters: // richMenuId ID of a rich menu -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu func (client *MessagingApiAPI) GetRichMenuWithHttpInfo( @@ -2067,7 +2040,6 @@ func (client *MessagingApiAPI) GetRichMenuAlias( // Parameters: // richMenuAliasId The rich menu alias ID whose information you want to obtain. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-by-id func (client *MessagingApiAPI) GetRichMenuAliasWithHttpInfo( @@ -2130,7 +2102,6 @@ func (client *MessagingApiAPI) GetRichMenuAliasList() (*RichMenuAliasListRespons // Get list of rich menu alias // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-list func (client *MessagingApiAPI) GetRichMenuAliasListWithHttpInfo() (*http.Response, *RichMenuAliasListResponse, error) { path := "/v2/bot/richmenu/alias/list" @@ -2196,7 +2167,6 @@ func (client *MessagingApiAPI) GetRichMenuBatchProgress( // Parameters: // requestId A request ID used to batch control the rich menu linked to the user. Each Messaging API request has a request ID. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-batch-control-rich-menus-progress-status func (client *MessagingApiAPI) GetRichMenuBatchProgressWithHttpInfo( @@ -2271,7 +2241,6 @@ func (client *MessagingApiAPI) GetRichMenuIdOfUser( // Parameters: // userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-id-of-user func (client *MessagingApiAPI) GetRichMenuIdOfUserWithHttpInfo( @@ -2334,7 +2303,6 @@ func (client *MessagingApiAPI) GetRichMenuList() (*RichMenuListResponse, error) // Get rich menu list // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list func (client *MessagingApiAPI) GetRichMenuListWithHttpInfo() (*http.Response, *RichMenuListResponse, error) { path := "/v2/bot/richmenu/list" @@ -2400,7 +2368,6 @@ func (client *MessagingApiAPI) GetRoomMemberCount( // Parameters: // roomId Room ID -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-members-room-count func (client *MessagingApiAPI) GetRoomMemberCountWithHttpInfo( @@ -2478,7 +2445,6 @@ func (client *MessagingApiAPI) GetRoomMemberProfile( // roomId Room ID // userId User ID -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-room-member-profile func (client *MessagingApiAPI) GetRoomMemberProfileWithHttpInfo( @@ -2560,7 +2526,6 @@ func (client *MessagingApiAPI) GetRoomMembersIds( // roomId Room ID // start Value of the continuation token found in the `next` property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-room-member-user-ids func (client *MessagingApiAPI) GetRoomMembersIdsWithHttpInfo( @@ -2630,7 +2595,6 @@ func (client *MessagingApiAPI) GetWebhookEndpoint() (*GetWebhookEndpointResponse // Get webhook endpoint information // Parameters: -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information func (client *MessagingApiAPI) GetWebhookEndpointWithHttpInfo() (*http.Response, *GetWebhookEndpointResponse, error) { path := "/v2/bot/channel/webhook/endpoint" @@ -2696,7 +2660,6 @@ func (client *MessagingApiAPI) IssueLinkToken( // Parameters: // userId User ID for the LINE account to be linked. Found in the `source` object of account link event objects. Do not use the LINE ID used in LINE. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#issue-link-token func (client *MessagingApiAPI) IssueLinkTokenWithHttpInfo( @@ -2768,7 +2731,6 @@ func (client *MessagingApiAPI) LeaveGroup( // Parameters: // groupId Group ID -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#leave-group func (client *MessagingApiAPI) LeaveGroupWithHttpInfo( @@ -2835,7 +2797,6 @@ func (client *MessagingApiAPI) LeaveRoom( // Parameters: // roomId Room ID -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#leave-room func (client *MessagingApiAPI) LeaveRoomWithHttpInfo( @@ -2908,7 +2869,6 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUser( // userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. // richMenuId ID of a rich menu -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-user func (client *MessagingApiAPI) LinkRichMenuIdToUserWithHttpInfo( @@ -2979,7 +2939,6 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUsers( // Parameters: // richMenuBulkLinkRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#link-rich-menu-to-users func (client *MessagingApiAPI) LinkRichMenuIdToUsersWithHttpInfo( @@ -3050,7 +3009,6 @@ func (client *MessagingApiAPI) MarkMessagesAsRead( // Parameters: // markMessagesAsReadRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#mark-messages-from-users-as-read func (client *MessagingApiAPI) MarkMessagesAsReadWithHttpInfo( @@ -3127,7 +3085,6 @@ func (client *MessagingApiAPI) Multicast( // multicastRequest // xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn't generated by LINE. Each developer must generate their own retry key. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#send-multicast-message func (client *MessagingApiAPI) MulticastWithHttpInfo( @@ -3213,7 +3170,6 @@ func (client *MessagingApiAPI) Narrowcast( // narrowcastRequest // xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn't generated by LINE. Each developer must generate their own retry key. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#send-narrowcast-message func (client *MessagingApiAPI) NarrowcastWithHttpInfo( @@ -3299,7 +3255,6 @@ func (client *MessagingApiAPI) PushMessage( // pushMessageRequest // xLineRetryKey Retry key. Specifies the UUID in hexadecimal format (e.g., `123e4567-e89b-12d3-a456-426614174000`) generated by any method. The retry key isn't generated by LINE. Each developer must generate their own retry key. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#send-push-message func (client *MessagingApiAPI) PushMessageWithHttpInfo( @@ -3385,7 +3340,6 @@ func (client *MessagingApiAPI) PushMessagesByPhone( // pnpMessagesRequest // xLineDeliveryTag String returned in the delivery.data property of the delivery completion event via Webhook. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#send-line-notification-message func (client *MessagingApiAPI) PushMessagesByPhoneWithHttpInfo( @@ -3460,7 +3414,6 @@ func (client *MessagingApiAPI) ReplyMessage( // Parameters: // replyMessageRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#send-reply-message func (client *MessagingApiAPI) ReplyMessageWithHttpInfo( @@ -3536,7 +3489,6 @@ func (client *MessagingApiAPI) RichMenuBatch( // Parameters: // richMenuBatchRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#batch-control-rich-menus-of-users func (client *MessagingApiAPI) RichMenuBatchWithHttpInfo( @@ -3607,7 +3559,6 @@ func (client *MessagingApiAPI) SetDefaultRichMenu( // Parameters: // richMenuId ID of a rich menu -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#set-default-rich-menu func (client *MessagingApiAPI) SetDefaultRichMenuWithHttpInfo( @@ -3674,7 +3625,6 @@ func (client *MessagingApiAPI) SetWebhookEndpoint( // Parameters: // setWebhookEndpointRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#set-webhook-endpoint-url func (client *MessagingApiAPI) SetWebhookEndpointWithHttpInfo( @@ -3745,7 +3695,6 @@ func (client *MessagingApiAPI) TestWebhookEndpoint( // Parameters: // testWebhookEndpointRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#test-webhook-endpoint func (client *MessagingApiAPI) TestWebhookEndpointWithHttpInfo( @@ -3821,7 +3770,6 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUser( // Parameters: // userId User ID. Found in the `source` object of webhook event objects. Do not use the LINE ID used in LINE. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#unlink-rich-menu-from-user func (client *MessagingApiAPI) UnlinkRichMenuIdFromUserWithHttpInfo( @@ -3888,7 +3836,6 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUsers( // Parameters: // richMenuBulkUnlinkRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#unlink-rich-menu-from-users func (client *MessagingApiAPI) UnlinkRichMenuIdFromUsersWithHttpInfo( @@ -3965,7 +3912,6 @@ func (client *MessagingApiAPI) UpdateRichMenuAlias( // richMenuAliasId The rich menu alias ID you want to update. // updateRichMenuAliasRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#update-rich-menu-alias func (client *MessagingApiAPI) UpdateRichMenuAliasWithHttpInfo( @@ -4040,7 +3986,6 @@ func (client *MessagingApiAPI) ValidateBroadcast( // Parameters: // validateMessageRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-broadcast-message func (client *MessagingApiAPI) ValidateBroadcastWithHttpInfo( @@ -4111,7 +4056,6 @@ func (client *MessagingApiAPI) ValidateMulticast( // Parameters: // validateMessageRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-multicast-message func (client *MessagingApiAPI) ValidateMulticastWithHttpInfo( @@ -4182,7 +4126,6 @@ func (client *MessagingApiAPI) ValidateNarrowcast( // Parameters: // validateMessageRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-narrowcast-message func (client *MessagingApiAPI) ValidateNarrowcastWithHttpInfo( @@ -4253,7 +4196,6 @@ func (client *MessagingApiAPI) ValidatePush( // Parameters: // validateMessageRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-push-message func (client *MessagingApiAPI) ValidatePushWithHttpInfo( @@ -4324,7 +4266,6 @@ func (client *MessagingApiAPI) ValidateReply( // Parameters: // validateMessageRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-reply-message func (client *MessagingApiAPI) ValidateReplyWithHttpInfo( @@ -4395,7 +4336,6 @@ func (client *MessagingApiAPI) ValidateRichMenuBatchRequest( // Parameters: // richMenuBatchRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#validate-batch-control-rich-menus-request func (client *MessagingApiAPI) ValidateRichMenuBatchRequestWithHttpInfo( @@ -4466,7 +4406,6 @@ func (client *MessagingApiAPI) ValidateRichMenuObject( // Parameters: // richMenuRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#validate-rich-menu-object func (client *MessagingApiAPI) ValidateRichMenuObjectWithHttpInfo( diff --git a/linebot/messaging_api/api_messaging_api_blob.go b/linebot/messaging_api/api_messaging_api_blob.go index 6adcfa66..172de31b 100644 --- a/linebot/messaging_api/api_messaging_api_blob.go +++ b/linebot/messaging_api/api_messaging_api_blob.go @@ -271,7 +271,6 @@ func (client *MessagingApiBlobAPI) GetMessageContentTranscodingByMessageId( // Parameters: // messageId Message ID of video or audio -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#verify-video-or-audio-preparation-status func (client *MessagingApiBlobAPI) GetMessageContentTranscodingByMessageIdWithHttpInfo( @@ -417,7 +416,6 @@ func (client *MessagingApiBlobAPI) SetRichMenuImage( // bodyContentType content-type // bodyReader file content -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/messaging-api/#upload-rich-menu-image func (client *MessagingApiBlobAPI) SetRichMenuImageWithHttpInfo( diff --git a/linebot/module/api_line_module.go b/linebot/module/api_line_module.go index 00599478..3ac51a86 100644 --- a/linebot/module/api_line_module.go +++ b/linebot/module/api_line_module.go @@ -150,7 +150,6 @@ func (client *LineModuleAPI) AcquireChatControl( // chatId The `userId`, `roomId`, or `groupId` // acquireChatControlRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#acquire-control-api func (client *LineModuleAPI) AcquireChatControlWithHttpInfo( @@ -225,7 +224,6 @@ func (client *LineModuleAPI) DetachModule( // Parameters: // detachModuleRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#unlink-detach-module-channel-by-operation-mc-admin func (client *LineModuleAPI) DetachModuleWithHttpInfo( @@ -302,7 +300,6 @@ func (client *LineModuleAPI) GetModules( // start Value of the continuation token found in the next property of the JSON object returned in the response. If you can't get all basic information about the bots in one request, include this parameter to get the remaining array. // limit Specify the maximum number of bots that you get basic information from. The default value is 100. Max value: 100 -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#get-multiple-bot-info-api func (client *LineModuleAPI) GetModulesWithHttpInfo( @@ -380,7 +377,6 @@ func (client *LineModuleAPI) ReleaseChatControl( // Parameters: // chatId The `userId`, `roomId`, or `groupId` -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#release-control-api func (client *LineModuleAPI) ReleaseChatControlWithHttpInfo( diff --git a/linebot/module_attach/api_line_module_attach.go b/linebot/module_attach/api_line_module_attach.go index c7d028c0..97cacb23 100644 --- a/linebot/module_attach/api_line_module_attach.go +++ b/linebot/module_attach/api_line_module_attach.go @@ -197,7 +197,6 @@ func (client *LineModuleAttachAPI) AttachModule( // scope If you specified a value for scope in the URL for authentication and authorization, specify the same value. // brandType If you specified a value for brand_type in the URL for authentication and authorization, specify the same value. -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#link-attach-by-operation-module-channel-provider func (client *LineModuleAttachAPI) AttachModuleWithHttpInfo( diff --git a/linebot/shop/api_shop.go b/linebot/shop/api_shop.go index 136c3d85..5f1d2c2e 100644 --- a/linebot/shop/api_shop.go +++ b/linebot/shop/api_shop.go @@ -143,7 +143,6 @@ func (client *ShopAPI) MissionStickerV3( // Parameters: // missionStickerRequest -// You must close the response body when finished with it. // https://developers.line.biz/en/reference/partner-docs/#send-mission-stickers-v3 func (client *ShopAPI) MissionStickerV3WithHttpInfo( From aa6c1ae9e4d294d4f02852e2ef82351acdf57832 Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Wed, 8 Nov 2023 09:36:23 +0900 Subject: [PATCH 4/5] Do not close response body twice. --- .../line-bot-sdk-go-generator/api.pebble | 3 - .../api_channel_access_token.go | 24 --- linebot/insight/api_insight.go | 15 -- linebot/liff/api_liff.go | 12 -- .../manage_audience/api_manage_audience.go | 33 ---- .../api_manage_audience_blob.go | 6 - linebot/messaging_api/api_messaging_api.go | 183 ------------------ .../messaging_api/api_messaging_api_blob.go | 9 - linebot/module/api_line_module.go | 12 -- .../module_attach/api_line_module_attach.go | 3 - linebot/shop/api_shop.go | 3 - 11 files changed, 303 deletions(-) diff --git a/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble b/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble index 604fa80b..8693dee6 100644 --- a/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble +++ b/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble @@ -152,9 +152,6 @@ func (client *{{ classname }}) {{ op.operationId }}( {% endif %} {% endfor %} ) - {% if not op.isResponseFile %} - defer response.Body.Close() - {% endif %} return body, error } diff --git a/linebot/channel_access_token/api_channel_access_token.go b/linebot/channel_access_token/api_channel_access_token.go index cf087e49..585429a5 100644 --- a/linebot/channel_access_token/api_channel_access_token.go +++ b/linebot/channel_access_token/api_channel_access_token.go @@ -135,9 +135,6 @@ func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIds( clientAssertion, ) - - defer response.Body.Close() - return body, error } @@ -223,9 +220,6 @@ func (client *ChannelAccessTokenAPI) IssueChannelToken( clientSecret, ) - - defer response.Body.Close() - return body, error } @@ -317,9 +311,6 @@ func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWT( clientAssertion, ) - - defer response.Body.Close() - return body, error } @@ -421,9 +412,6 @@ func (client *ChannelAccessTokenAPI) IssueStatelessChannelToken( clientSecret, ) - - defer response.Body.Close() - return body, error } @@ -513,9 +501,6 @@ func (client *ChannelAccessTokenAPI) RevokeChannelToken( accessToken, ) - - defer response.Body.Close() - return body, error } @@ -594,9 +579,6 @@ func (client *ChannelAccessTokenAPI) RevokeChannelTokenByJWT( accessToken, ) - - defer response.Body.Close() - return body, error } @@ -673,9 +655,6 @@ func (client *ChannelAccessTokenAPI) VerifyChannelToken( accessToken, ) - - defer response.Body.Close() - return body, error } @@ -749,9 +728,6 @@ func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWT( accessToken, ) - - defer response.Body.Close() - return body, error } diff --git a/linebot/insight/api_insight.go b/linebot/insight/api_insight.go index 4fab9f49..4c648580 100644 --- a/linebot/insight/api_insight.go +++ b/linebot/insight/api_insight.go @@ -121,9 +121,6 @@ func WithEndpoint(endpoint string) InsightAPIOption { // https://developers.line.biz/en/reference/messaging-api/#get-demographic func (client *InsightAPI) GetFriendsDemographics() (*GetFriendsDemographicsResponse, error) { response, body, error := client.GetFriendsDemographicsWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -185,9 +182,6 @@ func (client *InsightAPI) GetMessageEvent( requestId, ) - - defer response.Body.Close() - return body, error } @@ -259,9 +253,6 @@ func (client *InsightAPI) GetNumberOfFollowers( date, ) - - defer response.Body.Close() - return body, error } @@ -333,9 +324,6 @@ func (client *InsightAPI) GetNumberOfMessageDeliveries( date, ) - - defer response.Body.Close() - return body, error } @@ -417,9 +405,6 @@ func (client *InsightAPI) GetStatisticsPerUnit( to, ) - - defer response.Body.Close() - return body, error } diff --git a/linebot/liff/api_liff.go b/linebot/liff/api_liff.go index 5182121b..b187d6c6 100644 --- a/linebot/liff/api_liff.go +++ b/linebot/liff/api_liff.go @@ -131,9 +131,6 @@ func (client *LiffAPI) AddLIFFApp( addLiffAppRequest, ) - - defer response.Body.Close() - return body, error } @@ -206,9 +203,6 @@ func (client *LiffAPI) DeleteLIFFApp( liffId, ) - - defer response.Body.Close() - return body, error } @@ -264,9 +258,6 @@ func (client *LiffAPI) DeleteLIFFAppWithHttpInfo( // https://developers.line.biz/en/reference/liff-server/#get-all-liff-apps func (client *LiffAPI) GetAllLIFFApps() (*GetAllLiffAppsResponse, error) { response, body, error := client.GetAllLIFFAppsWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -333,9 +324,6 @@ func (client *LiffAPI) UpdateLIFFApp( updateLiffAppRequest, ) - - defer response.Body.Close() - return body, error } diff --git a/linebot/manage_audience/api_manage_audience.go b/linebot/manage_audience/api_manage_audience.go index 18176f65..0476c587 100644 --- a/linebot/manage_audience/api_manage_audience.go +++ b/linebot/manage_audience/api_manage_audience.go @@ -132,9 +132,6 @@ func (client *ManageAudienceAPI) ActivateAudienceGroup( audienceGroupId, ) - - defer response.Body.Close() - return body, error } @@ -198,9 +195,6 @@ func (client *ManageAudienceAPI) AddAudienceToAudienceGroup( addAudienceToAudienceGroupRequest, ) - - defer response.Body.Close() - return body, error } @@ -268,9 +262,6 @@ func (client *ManageAudienceAPI) CreateAudienceGroup( createAudienceGroupRequest, ) - - defer response.Body.Close() - return body, error } @@ -343,9 +334,6 @@ func (client *ManageAudienceAPI) CreateClickBasedAudienceGroup( createClickBasedAudienceGroupRequest, ) - - defer response.Body.Close() - return body, error } @@ -418,9 +406,6 @@ func (client *ManageAudienceAPI) CreateImpBasedAudienceGroup( createImpBasedAudienceGroupRequest, ) - - defer response.Body.Close() - return body, error } @@ -493,9 +478,6 @@ func (client *ManageAudienceAPI) DeleteAudienceGroup( audienceGroupId, ) - - defer response.Body.Close() - return body, error } @@ -559,9 +541,6 @@ func (client *ManageAudienceAPI) GetAudienceData( audienceGroupId, ) - - defer response.Body.Close() - return body, error } @@ -622,9 +601,6 @@ func (client *ManageAudienceAPI) GetAudienceDataWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-authority-level func (client *ManageAudienceAPI) GetAudienceGroupAuthorityLevel() (*GetAudienceGroupAuthorityLevelResponse, error) { response, body, error := client.GetAudienceGroupAuthorityLevelWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -711,9 +687,6 @@ func (client *ManageAudienceAPI) GetAudienceGroups( createRoute, ) - - defer response.Body.Close() - return body, error } @@ -805,9 +778,6 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupAuthorityLevel( updateAudienceGroupAuthorityLevelRequest, ) - - defer response.Body.Close() - return body, error } @@ -880,9 +850,6 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupDescription( updateAudienceGroupDescriptionRequest, ) - - defer response.Body.Close() - return body, error } diff --git a/linebot/manage_audience/api_manage_audience_blob.go b/linebot/manage_audience/api_manage_audience_blob.go index 70d18a91..2c7a3a17 100644 --- a/linebot/manage_audience/api_manage_audience_blob.go +++ b/linebot/manage_audience/api_manage_audience_blob.go @@ -143,9 +143,6 @@ func (client *ManageAudienceBlobAPI) AddUserIdsToAudience( uploadDescription, ) - - defer response.Body.Close() - return body, error } @@ -247,9 +244,6 @@ func (client *ManageAudienceBlobAPI) CreateAudienceForUploadingUserIds( uploadDescription, ) - - defer response.Body.Close() - return body, error } diff --git a/linebot/messaging_api/api_messaging_api.go b/linebot/messaging_api/api_messaging_api.go index ee942fa4..4b6dd2a9 100644 --- a/linebot/messaging_api/api_messaging_api.go +++ b/linebot/messaging_api/api_messaging_api.go @@ -131,9 +131,6 @@ func (client *MessagingApiAPI) AudienceMatch( audienceMatchMessagesRequest, ) - - defer response.Body.Close() - return body, error } @@ -206,9 +203,6 @@ func (client *MessagingApiAPI) Broadcast( xLineRetryKey, ) - - defer response.Body.Close() - return body, error } @@ -278,9 +272,6 @@ func (client *MessagingApiAPI) BroadcastWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#cancel-default-rich-menu func (client *MessagingApiAPI) CancelDefaultRichMenu() (struct{}, error) { response, body, error := client.CancelDefaultRichMenuWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -337,9 +328,6 @@ func (client *MessagingApiAPI) CreateRichMenu( richMenuRequest, ) - - defer response.Body.Close() - return body, error } @@ -412,9 +400,6 @@ func (client *MessagingApiAPI) CreateRichMenuAlias( createRichMenuAliasRequest, ) - - defer response.Body.Close() - return body, error } @@ -482,9 +467,6 @@ func (client *MessagingApiAPI) DeleteRichMenu( richMenuId, ) - - defer response.Body.Close() - return body, error } @@ -548,9 +530,6 @@ func (client *MessagingApiAPI) DeleteRichMenuAlias( richMenuAliasId, ) - - defer response.Body.Close() - return body, error } @@ -614,9 +593,6 @@ func (client *MessagingApiAPI) GetAdPhoneMessageStatistics( date, ) - - defer response.Body.Close() - return body, error } @@ -693,9 +669,6 @@ func (client *MessagingApiAPI) GetAggregationUnitNameList( start, ) - - defer response.Body.Close() - return body, error } @@ -763,9 +736,6 @@ func (client *MessagingApiAPI) GetAggregationUnitNameListWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-number-of-units-used-this-month func (client *MessagingApiAPI) GetAggregationUnitUsage() (*GetAggregationUnitUsageResponse, error) { response, body, error := client.GetAggregationUnitUsageWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -819,9 +789,6 @@ func (client *MessagingApiAPI) GetAggregationUnitUsageWithHttpInfo() (*http.Resp // https://developers.line.biz/en/reference/messaging-api/#get-bot-info func (client *MessagingApiAPI) GetBotInfo() (*BotInfoResponse, error) { response, body, error := client.GetBotInfoWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -875,9 +842,6 @@ func (client *MessagingApiAPI) GetBotInfoWithHttpInfo() (*http.Response, *BotInf // https://developers.line.biz/en/reference/messaging-api/#get-default-rich-menu-id func (client *MessagingApiAPI) GetDefaultRichMenuId() (*RichMenuIdResponse, error) { response, body, error := client.GetDefaultRichMenuIdWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -944,9 +908,6 @@ func (client *MessagingApiAPI) GetFollowers( limit, ) - - defer response.Body.Close() - return body, error } @@ -1022,9 +983,6 @@ func (client *MessagingApiAPI) GetGroupMemberCount( groupId, ) - - defer response.Body.Close() - return body, error } @@ -1098,9 +1056,6 @@ func (client *MessagingApiAPI) GetGroupMemberProfile( userId, ) - - defer response.Body.Close() - return body, error } @@ -1179,9 +1134,6 @@ func (client *MessagingApiAPI) GetGroupMembersIds( start, ) - - defer response.Body.Close() - return body, error } @@ -1258,9 +1210,6 @@ func (client *MessagingApiAPI) GetGroupSummary( groupId, ) - - defer response.Body.Close() - return body, error } @@ -1321,9 +1270,6 @@ func (client *MessagingApiAPI) GetGroupSummaryWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-quota func (client *MessagingApiAPI) GetMessageQuota() (*MessageQuotaResponse, error) { response, body, error := client.GetMessageQuotaWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -1377,9 +1323,6 @@ func (client *MessagingApiAPI) GetMessageQuotaWithHttpInfo() (*http.Response, *M // https://developers.line.biz/en/reference/messaging-api/#get-consumption func (client *MessagingApiAPI) GetMessageQuotaConsumption() (*QuotaConsumptionResponse, error) { response, body, error := client.GetMessageQuotaConsumptionWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -1441,9 +1384,6 @@ func (client *MessagingApiAPI) GetNarrowcastProgress( requestId, ) - - defer response.Body.Close() - return body, error } @@ -1515,9 +1455,6 @@ func (client *MessagingApiAPI) GetNumberOfSentBroadcastMessages( date, ) - - defer response.Body.Close() - return body, error } @@ -1589,9 +1526,6 @@ func (client *MessagingApiAPI) GetNumberOfSentMulticastMessages( date, ) - - defer response.Body.Close() - return body, error } @@ -1663,9 +1597,6 @@ func (client *MessagingApiAPI) GetNumberOfSentPushMessages( date, ) - - defer response.Body.Close() - return body, error } @@ -1737,9 +1668,6 @@ func (client *MessagingApiAPI) GetNumberOfSentReplyMessages( date, ) - - defer response.Body.Close() - return body, error } @@ -1811,9 +1739,6 @@ func (client *MessagingApiAPI) GetPNPMessageStatistics( date, ) - - defer response.Body.Close() - return body, error } @@ -1885,9 +1810,6 @@ func (client *MessagingApiAPI) GetProfile( userId, ) - - defer response.Body.Close() - return body, error } @@ -1956,9 +1878,6 @@ func (client *MessagingApiAPI) GetRichMenu( richMenuId, ) - - defer response.Body.Close() - return body, error } @@ -2027,9 +1946,6 @@ func (client *MessagingApiAPI) GetRichMenuAlias( richMenuAliasId, ) - - defer response.Body.Close() - return body, error } @@ -2090,9 +2006,6 @@ func (client *MessagingApiAPI) GetRichMenuAliasWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-list func (client *MessagingApiAPI) GetRichMenuAliasList() (*RichMenuAliasListResponse, error) { response, body, error := client.GetRichMenuAliasListWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -2154,9 +2067,6 @@ func (client *MessagingApiAPI) GetRichMenuBatchProgress( requestId, ) - - defer response.Body.Close() - return body, error } @@ -2228,9 +2138,6 @@ func (client *MessagingApiAPI) GetRichMenuIdOfUser( userId, ) - - defer response.Body.Close() - return body, error } @@ -2291,9 +2198,6 @@ func (client *MessagingApiAPI) GetRichMenuIdOfUserWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list func (client *MessagingApiAPI) GetRichMenuList() (*RichMenuListResponse, error) { response, body, error := client.GetRichMenuListWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -2355,9 +2259,6 @@ func (client *MessagingApiAPI) GetRoomMemberCount( roomId, ) - - defer response.Body.Close() - return body, error } @@ -2431,9 +2332,6 @@ func (client *MessagingApiAPI) GetRoomMemberProfile( userId, ) - - defer response.Body.Close() - return body, error } @@ -2512,9 +2410,6 @@ func (client *MessagingApiAPI) GetRoomMembersIds( start, ) - - defer response.Body.Close() - return body, error } @@ -2583,9 +2478,6 @@ func (client *MessagingApiAPI) GetRoomMembersIdsWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information func (client *MessagingApiAPI) GetWebhookEndpoint() (*GetWebhookEndpointResponse, error) { response, body, error := client.GetWebhookEndpointWithHttpInfo() - - defer response.Body.Close() - return body, error } @@ -2647,9 +2539,6 @@ func (client *MessagingApiAPI) IssueLinkToken( userId, ) - - defer response.Body.Close() - return body, error } @@ -2718,9 +2607,6 @@ func (client *MessagingApiAPI) LeaveGroup( groupId, ) - - defer response.Body.Close() - return body, error } @@ -2784,9 +2670,6 @@ func (client *MessagingApiAPI) LeaveRoom( roomId, ) - - defer response.Body.Close() - return body, error } @@ -2855,9 +2738,6 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUser( richMenuId, ) - - defer response.Body.Close() - return body, error } @@ -2926,9 +2806,6 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUsers( richMenuBulkLinkRequest, ) - - defer response.Body.Close() - return body, error } @@ -2996,9 +2873,6 @@ func (client *MessagingApiAPI) MarkMessagesAsRead( markMessagesAsReadRequest, ) - - defer response.Body.Close() - return body, error } @@ -3071,9 +2945,6 @@ func (client *MessagingApiAPI) Multicast( xLineRetryKey, ) - - defer response.Body.Close() - return body, error } @@ -3156,9 +3027,6 @@ func (client *MessagingApiAPI) Narrowcast( xLineRetryKey, ) - - defer response.Body.Close() - return body, error } @@ -3241,9 +3109,6 @@ func (client *MessagingApiAPI) PushMessage( xLineRetryKey, ) - - defer response.Body.Close() - return body, error } @@ -3326,9 +3191,6 @@ func (client *MessagingApiAPI) PushMessagesByPhone( xLineDeliveryTag, ) - - defer response.Body.Close() - return body, error } @@ -3401,9 +3263,6 @@ func (client *MessagingApiAPI) ReplyMessage( replyMessageRequest, ) - - defer response.Body.Close() - return body, error } @@ -3476,9 +3335,6 @@ func (client *MessagingApiAPI) RichMenuBatch( richMenuBatchRequest, ) - - defer response.Body.Close() - return body, error } @@ -3546,9 +3402,6 @@ func (client *MessagingApiAPI) SetDefaultRichMenu( richMenuId, ) - - defer response.Body.Close() - return body, error } @@ -3612,9 +3465,6 @@ func (client *MessagingApiAPI) SetWebhookEndpoint( setWebhookEndpointRequest, ) - - defer response.Body.Close() - return body, error } @@ -3682,9 +3532,6 @@ func (client *MessagingApiAPI) TestWebhookEndpoint( testWebhookEndpointRequest, ) - - defer response.Body.Close() - return body, error } @@ -3757,9 +3604,6 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUser( userId, ) - - defer response.Body.Close() - return body, error } @@ -3823,9 +3667,6 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUsers( richMenuBulkUnlinkRequest, ) - - defer response.Body.Close() - return body, error } @@ -3898,9 +3739,6 @@ func (client *MessagingApiAPI) UpdateRichMenuAlias( updateRichMenuAliasRequest, ) - - defer response.Body.Close() - return body, error } @@ -3973,9 +3811,6 @@ func (client *MessagingApiAPI) ValidateBroadcast( validateMessageRequest, ) - - defer response.Body.Close() - return body, error } @@ -4043,9 +3878,6 @@ func (client *MessagingApiAPI) ValidateMulticast( validateMessageRequest, ) - - defer response.Body.Close() - return body, error } @@ -4113,9 +3945,6 @@ func (client *MessagingApiAPI) ValidateNarrowcast( validateMessageRequest, ) - - defer response.Body.Close() - return body, error } @@ -4183,9 +4012,6 @@ func (client *MessagingApiAPI) ValidatePush( validateMessageRequest, ) - - defer response.Body.Close() - return body, error } @@ -4253,9 +4079,6 @@ func (client *MessagingApiAPI) ValidateReply( validateMessageRequest, ) - - defer response.Body.Close() - return body, error } @@ -4323,9 +4146,6 @@ func (client *MessagingApiAPI) ValidateRichMenuBatchRequest( richMenuBatchRequest, ) - - defer response.Body.Close() - return body, error } @@ -4393,9 +4213,6 @@ func (client *MessagingApiAPI) ValidateRichMenuObject( richMenuRequest, ) - - defer response.Body.Close() - return body, error } diff --git a/linebot/messaging_api/api_messaging_api_blob.go b/linebot/messaging_api/api_messaging_api_blob.go index 172de31b..93ec411d 100644 --- a/linebot/messaging_api/api_messaging_api_blob.go +++ b/linebot/messaging_api/api_messaging_api_blob.go @@ -131,7 +131,6 @@ func (client *MessagingApiBlobAPI) GetMessageContent( messageId, ) - return body, error } @@ -195,7 +194,6 @@ func (client *MessagingApiBlobAPI) GetMessageContentPreview( messageId, ) - return body, error } @@ -258,9 +256,6 @@ func (client *MessagingApiBlobAPI) GetMessageContentTranscodingByMessageId( messageId, ) - - defer response.Body.Close() - return body, error } @@ -330,7 +325,6 @@ func (client *MessagingApiBlobAPI) GetRichMenuImage( richMenuId, ) - return body, error } @@ -401,9 +395,6 @@ func (client *MessagingApiBlobAPI) SetRichMenuImage( bodyContentType, bodyReader, ) - - defer response.Body.Close() - return body, error } diff --git a/linebot/module/api_line_module.go b/linebot/module/api_line_module.go index 3ac51a86..de156fc9 100644 --- a/linebot/module/api_line_module.go +++ b/linebot/module/api_line_module.go @@ -136,9 +136,6 @@ func (client *LineModuleAPI) AcquireChatControl( acquireChatControlRequest, ) - - defer response.Body.Close() - return body, error } @@ -211,9 +208,6 @@ func (client *LineModuleAPI) DetachModule( detachModuleRequest, ) - - defer response.Body.Close() - return body, error } @@ -286,9 +280,6 @@ func (client *LineModuleAPI) GetModules( limit, ) - - defer response.Body.Close() - return body, error } @@ -364,9 +355,6 @@ func (client *LineModuleAPI) ReleaseChatControl( chatId, ) - - defer response.Body.Close() - return body, error } diff --git a/linebot/module_attach/api_line_module_attach.go b/linebot/module_attach/api_line_module_attach.go index 97cacb23..cf7edfd6 100644 --- a/linebot/module_attach/api_line_module_attach.go +++ b/linebot/module_attach/api_line_module_attach.go @@ -175,9 +175,6 @@ func (client *LineModuleAttachAPI) AttachModule( brandType, ) - - defer response.Body.Close() - return body, error } diff --git a/linebot/shop/api_shop.go b/linebot/shop/api_shop.go index 5f1d2c2e..28e64762 100644 --- a/linebot/shop/api_shop.go +++ b/linebot/shop/api_shop.go @@ -130,9 +130,6 @@ func (client *ShopAPI) MissionStickerV3( missionStickerRequest, ) - - defer response.Body.Close() - return body, error } From c8333469d5c50d2ffdcf2a46c1da574eee9bc290 Mon Sep 17 00:00:00 2001 From: Tokuhiro Matsuno Date: Mon, 13 Nov 2023 18:25:49 +0900 Subject: [PATCH 5/5] fix: unused varaible --- .../line-bot-sdk-go-generator/api.pebble | 2 +- .../api_channel_access_token.go | 16 +-- linebot/insight/api_insight.go | 10 +- linebot/liff/api_liff.go | 8 +- .../manage_audience/api_manage_audience.go | 22 ++-- .../api_manage_audience_blob.go | 4 +- linebot/messaging_api/api_messaging_api.go | 122 +++++++++--------- .../messaging_api/api_messaging_api_blob.go | 4 +- linebot/module/api_line_module.go | 8 +- .../module_attach/api_line_module_attach.go | 2 +- linebot/shop/api_shop.go | 2 +- 11 files changed, 100 insertions(+), 100 deletions(-) diff --git a/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble b/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble index 8693dee6..2511d6cd 100644 --- a/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble +++ b/generator/src/main/resources/line-bot-sdk-go-generator/api.pebble @@ -142,7 +142,7 @@ func (client *{{ classname }}) {{ op.operationId }}( {% endif %} {% endfor %} ) ({% if op.isResponseFile %}*http.Response{% elseif op.returnType %}*{{ op.returnType }}{% else %}struct{}{% endif %}, error) { - {% if op.isResponseFile %}_{% else %}response{% endif %}, body, error := client.{{ op.operationId }}WithHttpInfo( + _, body, error := client.{{ op.operationId }}WithHttpInfo( {% for param in op.allParams %} {% if param.isBodyParam and param.isFile %} {{ param.paramName }}ContentType, diff --git a/linebot/channel_access_token/api_channel_access_token.go b/linebot/channel_access_token/api_channel_access_token.go index 585429a5..0d64b8b9 100644 --- a/linebot/channel_access_token/api_channel_access_token.go +++ b/linebot/channel_access_token/api_channel_access_token.go @@ -129,7 +129,7 @@ func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIds( clientAssertion string, ) (*ChannelAccessTokenKeyIdsResponse, error) { - response, body, error := client.GetsAllValidChannelAccessTokenKeyIdsWithHttpInfo( + _, body, error := client.GetsAllValidChannelAccessTokenKeyIdsWithHttpInfo( clientAssertionType, @@ -212,7 +212,7 @@ func (client *ChannelAccessTokenAPI) IssueChannelToken( clientSecret string, ) (*IssueShortLivedChannelAccessTokenResponse, error) { - response, body, error := client.IssueChannelTokenWithHttpInfo( + _, body, error := client.IssueChannelTokenWithHttpInfo( grantType, @@ -303,7 +303,7 @@ func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWT( clientAssertion string, ) (*IssueChannelAccessTokenResponse, error) { - response, body, error := client.IssueChannelTokenByJWTWithHttpInfo( + _, body, error := client.IssueChannelTokenByJWTWithHttpInfo( grantType, @@ -400,7 +400,7 @@ func (client *ChannelAccessTokenAPI) IssueStatelessChannelToken( clientSecret string, ) (*IssueStatelessChannelAccessTokenResponse, error) { - response, body, error := client.IssueStatelessChannelTokenWithHttpInfo( + _, body, error := client.IssueStatelessChannelTokenWithHttpInfo( grantType, @@ -497,7 +497,7 @@ func (client *ChannelAccessTokenAPI) RevokeChannelToken( accessToken string, ) (struct{}, error) { - response, body, error := client.RevokeChannelTokenWithHttpInfo( + _, body, error := client.RevokeChannelTokenWithHttpInfo( accessToken, ) @@ -571,7 +571,7 @@ func (client *ChannelAccessTokenAPI) RevokeChannelTokenByJWT( accessToken string, ) (struct{}, error) { - response, body, error := client.RevokeChannelTokenByJWTWithHttpInfo( + _, body, error := client.RevokeChannelTokenByJWTWithHttpInfo( clientId, @@ -651,7 +651,7 @@ func (client *ChannelAccessTokenAPI) VerifyChannelToken( accessToken string, ) (*VerifyChannelAccessTokenResponse, error) { - response, body, error := client.VerifyChannelTokenWithHttpInfo( + _, body, error := client.VerifyChannelTokenWithHttpInfo( accessToken, ) @@ -724,7 +724,7 @@ func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWT( accessToken string, ) (*VerifyChannelAccessTokenResponse, error) { - response, body, error := client.VerifyChannelTokenByJWTWithHttpInfo( + _, body, error := client.VerifyChannelTokenByJWTWithHttpInfo( accessToken, ) diff --git a/linebot/insight/api_insight.go b/linebot/insight/api_insight.go index 4c648580..d7cc7e23 100644 --- a/linebot/insight/api_insight.go +++ b/linebot/insight/api_insight.go @@ -120,7 +120,7 @@ func WithEndpoint(endpoint string) InsightAPIOption { // https://developers.line.biz/en/reference/messaging-api/#get-demographic func (client *InsightAPI) GetFriendsDemographics() (*GetFriendsDemographicsResponse, error) { - response, body, error := client.GetFriendsDemographicsWithHttpInfo() + _, body, error := client.GetFriendsDemographicsWithHttpInfo() return body, error } @@ -178,7 +178,7 @@ func (client *InsightAPI) GetMessageEvent( requestId string, ) (*GetMessageEventResponse, error) { - response, body, error := client.GetMessageEventWithHttpInfo( + _, body, error := client.GetMessageEventWithHttpInfo( requestId, ) @@ -249,7 +249,7 @@ func (client *InsightAPI) GetNumberOfFollowers( date string, ) (*GetNumberOfFollowersResponse, error) { - response, body, error := client.GetNumberOfFollowersWithHttpInfo( + _, body, error := client.GetNumberOfFollowersWithHttpInfo( date, ) @@ -320,7 +320,7 @@ func (client *InsightAPI) GetNumberOfMessageDeliveries( date string, ) (*GetNumberOfMessageDeliveriesResponse, error) { - response, body, error := client.GetNumberOfMessageDeliveriesWithHttpInfo( + _, body, error := client.GetNumberOfMessageDeliveriesWithHttpInfo( date, ) @@ -397,7 +397,7 @@ func (client *InsightAPI) GetStatisticsPerUnit( to string, ) (*GetStatisticsPerUnitResponse, error) { - response, body, error := client.GetStatisticsPerUnitWithHttpInfo( + _, body, error := client.GetStatisticsPerUnitWithHttpInfo( customAggregationUnit, diff --git a/linebot/liff/api_liff.go b/linebot/liff/api_liff.go index b187d6c6..6bc026df 100644 --- a/linebot/liff/api_liff.go +++ b/linebot/liff/api_liff.go @@ -127,7 +127,7 @@ func (client *LiffAPI) AddLIFFApp( addLiffAppRequest *AddLiffAppRequest, ) (*AddLiffAppResponse, error) { - response, body, error := client.AddLIFFAppWithHttpInfo( + _, body, error := client.AddLIFFAppWithHttpInfo( addLiffAppRequest, ) @@ -199,7 +199,7 @@ func (client *LiffAPI) DeleteLIFFApp( liffId string, ) (struct{}, error) { - response, body, error := client.DeleteLIFFAppWithHttpInfo( + _, body, error := client.DeleteLIFFAppWithHttpInfo( liffId, ) @@ -257,7 +257,7 @@ func (client *LiffAPI) DeleteLIFFAppWithHttpInfo( // https://developers.line.biz/en/reference/liff-server/#get-all-liff-apps func (client *LiffAPI) GetAllLIFFApps() (*GetAllLiffAppsResponse, error) { - response, body, error := client.GetAllLIFFAppsWithHttpInfo() + _, body, error := client.GetAllLIFFAppsWithHttpInfo() return body, error } @@ -318,7 +318,7 @@ func (client *LiffAPI) UpdateLIFFApp( updateLiffAppRequest *UpdateLiffAppRequest, ) (struct{}, error) { - response, body, error := client.UpdateLIFFAppWithHttpInfo( + _, body, error := client.UpdateLIFFAppWithHttpInfo( liffId, diff --git a/linebot/manage_audience/api_manage_audience.go b/linebot/manage_audience/api_manage_audience.go index 0476c587..c9b4b6ab 100644 --- a/linebot/manage_audience/api_manage_audience.go +++ b/linebot/manage_audience/api_manage_audience.go @@ -128,7 +128,7 @@ func (client *ManageAudienceAPI) ActivateAudienceGroup( audienceGroupId int64, ) (struct{}, error) { - response, body, error := client.ActivateAudienceGroupWithHttpInfo( + _, body, error := client.ActivateAudienceGroupWithHttpInfo( audienceGroupId, ) @@ -191,7 +191,7 @@ func (client *ManageAudienceAPI) AddAudienceToAudienceGroup( addAudienceToAudienceGroupRequest *AddAudienceToAudienceGroupRequest, ) (struct{}, error) { - response, body, error := client.AddAudienceToAudienceGroupWithHttpInfo( + _, body, error := client.AddAudienceToAudienceGroupWithHttpInfo( addAudienceToAudienceGroupRequest, ) @@ -258,7 +258,7 @@ func (client *ManageAudienceAPI) CreateAudienceGroup( createAudienceGroupRequest *CreateAudienceGroupRequest, ) (*CreateAudienceGroupResponse, error) { - response, body, error := client.CreateAudienceGroupWithHttpInfo( + _, body, error := client.CreateAudienceGroupWithHttpInfo( createAudienceGroupRequest, ) @@ -330,7 +330,7 @@ func (client *ManageAudienceAPI) CreateClickBasedAudienceGroup( createClickBasedAudienceGroupRequest *CreateClickBasedAudienceGroupRequest, ) (*CreateClickBasedAudienceGroupResponse, error) { - response, body, error := client.CreateClickBasedAudienceGroupWithHttpInfo( + _, body, error := client.CreateClickBasedAudienceGroupWithHttpInfo( createClickBasedAudienceGroupRequest, ) @@ -402,7 +402,7 @@ func (client *ManageAudienceAPI) CreateImpBasedAudienceGroup( createImpBasedAudienceGroupRequest *CreateImpBasedAudienceGroupRequest, ) (*CreateImpBasedAudienceGroupResponse, error) { - response, body, error := client.CreateImpBasedAudienceGroupWithHttpInfo( + _, body, error := client.CreateImpBasedAudienceGroupWithHttpInfo( createImpBasedAudienceGroupRequest, ) @@ -474,7 +474,7 @@ func (client *ManageAudienceAPI) DeleteAudienceGroup( audienceGroupId int64, ) (struct{}, error) { - response, body, error := client.DeleteAudienceGroupWithHttpInfo( + _, body, error := client.DeleteAudienceGroupWithHttpInfo( audienceGroupId, ) @@ -537,7 +537,7 @@ func (client *ManageAudienceAPI) GetAudienceData( audienceGroupId int64, ) (*GetAudienceDataResponse, error) { - response, body, error := client.GetAudienceDataWithHttpInfo( + _, body, error := client.GetAudienceDataWithHttpInfo( audienceGroupId, ) @@ -600,7 +600,7 @@ func (client *ManageAudienceAPI) GetAudienceDataWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-authority-level func (client *ManageAudienceAPI) GetAudienceGroupAuthorityLevel() (*GetAudienceGroupAuthorityLevelResponse, error) { - response, body, error := client.GetAudienceGroupAuthorityLevelWithHttpInfo() + _, body, error := client.GetAudienceGroupAuthorityLevelWithHttpInfo() return body, error } @@ -673,7 +673,7 @@ func (client *ManageAudienceAPI) GetAudienceGroups( createRoute AudienceGroupCreateRoute, ) (*GetAudienceGroupsResponse, error) { - response, body, error := client.GetAudienceGroupsWithHttpInfo( + _, body, error := client.GetAudienceGroupsWithHttpInfo( page, @@ -774,7 +774,7 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupAuthorityLevel( updateAudienceGroupAuthorityLevelRequest *UpdateAudienceGroupAuthorityLevelRequest, ) (struct{}, error) { - response, body, error := client.UpdateAudienceGroupAuthorityLevelWithHttpInfo( + _, body, error := client.UpdateAudienceGroupAuthorityLevelWithHttpInfo( updateAudienceGroupAuthorityLevelRequest, ) @@ -844,7 +844,7 @@ func (client *ManageAudienceAPI) UpdateAudienceGroupDescription( updateAudienceGroupDescriptionRequest *UpdateAudienceGroupDescriptionRequest, ) (struct{}, error) { - response, body, error := client.UpdateAudienceGroupDescriptionWithHttpInfo( + _, body, error := client.UpdateAudienceGroupDescriptionWithHttpInfo( audienceGroupId, diff --git a/linebot/manage_audience/api_manage_audience_blob.go b/linebot/manage_audience/api_manage_audience_blob.go index 2c7a3a17..10665624 100644 --- a/linebot/manage_audience/api_manage_audience_blob.go +++ b/linebot/manage_audience/api_manage_audience_blob.go @@ -135,7 +135,7 @@ func (client *ManageAudienceBlobAPI) AddUserIdsToAudience( uploadDescription string, ) (struct{}, error) { - response, body, error := client.AddUserIdsToAudienceWithHttpInfo( + _, body, error := client.AddUserIdsToAudienceWithHttpInfo( file, @@ -234,7 +234,7 @@ func (client *ManageAudienceBlobAPI) CreateAudienceForUploadingUserIds( uploadDescription string, ) (*CreateAudienceGroupResponse, error) { - response, body, error := client.CreateAudienceForUploadingUserIdsWithHttpInfo( + _, body, error := client.CreateAudienceForUploadingUserIdsWithHttpInfo( file, diff --git a/linebot/messaging_api/api_messaging_api.go b/linebot/messaging_api/api_messaging_api.go index 4b6dd2a9..865ba247 100644 --- a/linebot/messaging_api/api_messaging_api.go +++ b/linebot/messaging_api/api_messaging_api.go @@ -127,7 +127,7 @@ func (client *MessagingApiAPI) AudienceMatch( audienceMatchMessagesRequest *AudienceMatchMessagesRequest, ) (struct{}, error) { - response, body, error := client.AudienceMatchWithHttpInfo( + _, body, error := client.AudienceMatchWithHttpInfo( audienceMatchMessagesRequest, ) @@ -197,7 +197,7 @@ func (client *MessagingApiAPI) Broadcast( xLineRetryKey string, ) (*map[string]interface{}, error) { - response, body, error := client.BroadcastWithHttpInfo( + _, body, error := client.BroadcastWithHttpInfo( broadcastRequest, @@ -271,7 +271,7 @@ func (client *MessagingApiAPI) BroadcastWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#cancel-default-rich-menu func (client *MessagingApiAPI) CancelDefaultRichMenu() (struct{}, error) { - response, body, error := client.CancelDefaultRichMenuWithHttpInfo() + _, body, error := client.CancelDefaultRichMenuWithHttpInfo() return body, error } @@ -324,7 +324,7 @@ func (client *MessagingApiAPI) CreateRichMenu( richMenuRequest *RichMenuRequest, ) (*RichMenuIdResponse, error) { - response, body, error := client.CreateRichMenuWithHttpInfo( + _, body, error := client.CreateRichMenuWithHttpInfo( richMenuRequest, ) @@ -396,7 +396,7 @@ func (client *MessagingApiAPI) CreateRichMenuAlias( createRichMenuAliasRequest *CreateRichMenuAliasRequest, ) (struct{}, error) { - response, body, error := client.CreateRichMenuAliasWithHttpInfo( + _, body, error := client.CreateRichMenuAliasWithHttpInfo( createRichMenuAliasRequest, ) @@ -463,7 +463,7 @@ func (client *MessagingApiAPI) DeleteRichMenu( richMenuId string, ) (struct{}, error) { - response, body, error := client.DeleteRichMenuWithHttpInfo( + _, body, error := client.DeleteRichMenuWithHttpInfo( richMenuId, ) @@ -526,7 +526,7 @@ func (client *MessagingApiAPI) DeleteRichMenuAlias( richMenuAliasId string, ) (struct{}, error) { - response, body, error := client.DeleteRichMenuAliasWithHttpInfo( + _, body, error := client.DeleteRichMenuAliasWithHttpInfo( richMenuAliasId, ) @@ -589,7 +589,7 @@ func (client *MessagingApiAPI) GetAdPhoneMessageStatistics( date string, ) (*NumberOfMessagesResponse, error) { - response, body, error := client.GetAdPhoneMessageStatisticsWithHttpInfo( + _, body, error := client.GetAdPhoneMessageStatisticsWithHttpInfo( date, ) @@ -663,7 +663,7 @@ func (client *MessagingApiAPI) GetAggregationUnitNameList( start string, ) (*GetAggregationUnitNameListResponse, error) { - response, body, error := client.GetAggregationUnitNameListWithHttpInfo( + _, body, error := client.GetAggregationUnitNameListWithHttpInfo( limit, @@ -735,7 +735,7 @@ func (client *MessagingApiAPI) GetAggregationUnitNameListWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-number-of-units-used-this-month func (client *MessagingApiAPI) GetAggregationUnitUsage() (*GetAggregationUnitUsageResponse, error) { - response, body, error := client.GetAggregationUnitUsageWithHttpInfo() + _, body, error := client.GetAggregationUnitUsageWithHttpInfo() return body, error } @@ -788,7 +788,7 @@ func (client *MessagingApiAPI) GetAggregationUnitUsageWithHttpInfo() (*http.Resp // https://developers.line.biz/en/reference/messaging-api/#get-bot-info func (client *MessagingApiAPI) GetBotInfo() (*BotInfoResponse, error) { - response, body, error := client.GetBotInfoWithHttpInfo() + _, body, error := client.GetBotInfoWithHttpInfo() return body, error } @@ -841,7 +841,7 @@ func (client *MessagingApiAPI) GetBotInfoWithHttpInfo() (*http.Response, *BotInf // https://developers.line.biz/en/reference/messaging-api/#get-default-rich-menu-id func (client *MessagingApiAPI) GetDefaultRichMenuId() (*RichMenuIdResponse, error) { - response, body, error := client.GetDefaultRichMenuIdWithHttpInfo() + _, body, error := client.GetDefaultRichMenuIdWithHttpInfo() return body, error } @@ -902,7 +902,7 @@ func (client *MessagingApiAPI) GetFollowers( limit int32, ) (*GetFollowersResponse, error) { - response, body, error := client.GetFollowersWithHttpInfo( + _, body, error := client.GetFollowersWithHttpInfo( start, @@ -979,7 +979,7 @@ func (client *MessagingApiAPI) GetGroupMemberCount( groupId string, ) (*GroupMemberCountResponse, error) { - response, body, error := client.GetGroupMemberCountWithHttpInfo( + _, body, error := client.GetGroupMemberCountWithHttpInfo( groupId, ) @@ -1050,7 +1050,7 @@ func (client *MessagingApiAPI) GetGroupMemberProfile( userId string, ) (*GroupUserProfileResponse, error) { - response, body, error := client.GetGroupMemberProfileWithHttpInfo( + _, body, error := client.GetGroupMemberProfileWithHttpInfo( groupId, @@ -1128,7 +1128,7 @@ func (client *MessagingApiAPI) GetGroupMembersIds( start string, ) (*MembersIdsResponse, error) { - response, body, error := client.GetGroupMembersIdsWithHttpInfo( + _, body, error := client.GetGroupMembersIdsWithHttpInfo( groupId, @@ -1206,7 +1206,7 @@ func (client *MessagingApiAPI) GetGroupSummary( groupId string, ) (*GroupSummaryResponse, error) { - response, body, error := client.GetGroupSummaryWithHttpInfo( + _, body, error := client.GetGroupSummaryWithHttpInfo( groupId, ) @@ -1269,7 +1269,7 @@ func (client *MessagingApiAPI) GetGroupSummaryWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-quota func (client *MessagingApiAPI) GetMessageQuota() (*MessageQuotaResponse, error) { - response, body, error := client.GetMessageQuotaWithHttpInfo() + _, body, error := client.GetMessageQuotaWithHttpInfo() return body, error } @@ -1322,7 +1322,7 @@ func (client *MessagingApiAPI) GetMessageQuotaWithHttpInfo() (*http.Response, *M // https://developers.line.biz/en/reference/messaging-api/#get-consumption func (client *MessagingApiAPI) GetMessageQuotaConsumption() (*QuotaConsumptionResponse, error) { - response, body, error := client.GetMessageQuotaConsumptionWithHttpInfo() + _, body, error := client.GetMessageQuotaConsumptionWithHttpInfo() return body, error } @@ -1380,7 +1380,7 @@ func (client *MessagingApiAPI) GetNarrowcastProgress( requestId string, ) (*NarrowcastProgressResponse, error) { - response, body, error := client.GetNarrowcastProgressWithHttpInfo( + _, body, error := client.GetNarrowcastProgressWithHttpInfo( requestId, ) @@ -1451,7 +1451,7 @@ func (client *MessagingApiAPI) GetNumberOfSentBroadcastMessages( date string, ) (*NumberOfMessagesResponse, error) { - response, body, error := client.GetNumberOfSentBroadcastMessagesWithHttpInfo( + _, body, error := client.GetNumberOfSentBroadcastMessagesWithHttpInfo( date, ) @@ -1522,7 +1522,7 @@ func (client *MessagingApiAPI) GetNumberOfSentMulticastMessages( date string, ) (*NumberOfMessagesResponse, error) { - response, body, error := client.GetNumberOfSentMulticastMessagesWithHttpInfo( + _, body, error := client.GetNumberOfSentMulticastMessagesWithHttpInfo( date, ) @@ -1593,7 +1593,7 @@ func (client *MessagingApiAPI) GetNumberOfSentPushMessages( date string, ) (*NumberOfMessagesResponse, error) { - response, body, error := client.GetNumberOfSentPushMessagesWithHttpInfo( + _, body, error := client.GetNumberOfSentPushMessagesWithHttpInfo( date, ) @@ -1664,7 +1664,7 @@ func (client *MessagingApiAPI) GetNumberOfSentReplyMessages( date string, ) (*NumberOfMessagesResponse, error) { - response, body, error := client.GetNumberOfSentReplyMessagesWithHttpInfo( + _, body, error := client.GetNumberOfSentReplyMessagesWithHttpInfo( date, ) @@ -1735,7 +1735,7 @@ func (client *MessagingApiAPI) GetPNPMessageStatistics( date string, ) (*NumberOfMessagesResponse, error) { - response, body, error := client.GetPNPMessageStatisticsWithHttpInfo( + _, body, error := client.GetPNPMessageStatisticsWithHttpInfo( date, ) @@ -1806,7 +1806,7 @@ func (client *MessagingApiAPI) GetProfile( userId string, ) (*UserProfileResponse, error) { - response, body, error := client.GetProfileWithHttpInfo( + _, body, error := client.GetProfileWithHttpInfo( userId, ) @@ -1874,7 +1874,7 @@ func (client *MessagingApiAPI) GetRichMenu( richMenuId string, ) (*RichMenuResponse, error) { - response, body, error := client.GetRichMenuWithHttpInfo( + _, body, error := client.GetRichMenuWithHttpInfo( richMenuId, ) @@ -1942,7 +1942,7 @@ func (client *MessagingApiAPI) GetRichMenuAlias( richMenuAliasId string, ) (*RichMenuAliasResponse, error) { - response, body, error := client.GetRichMenuAliasWithHttpInfo( + _, body, error := client.GetRichMenuAliasWithHttpInfo( richMenuAliasId, ) @@ -2005,7 +2005,7 @@ func (client *MessagingApiAPI) GetRichMenuAliasWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-alias-list func (client *MessagingApiAPI) GetRichMenuAliasList() (*RichMenuAliasListResponse, error) { - response, body, error := client.GetRichMenuAliasListWithHttpInfo() + _, body, error := client.GetRichMenuAliasListWithHttpInfo() return body, error } @@ -2063,7 +2063,7 @@ func (client *MessagingApiAPI) GetRichMenuBatchProgress( requestId string, ) (*RichMenuBatchProgressResponse, error) { - response, body, error := client.GetRichMenuBatchProgressWithHttpInfo( + _, body, error := client.GetRichMenuBatchProgressWithHttpInfo( requestId, ) @@ -2134,7 +2134,7 @@ func (client *MessagingApiAPI) GetRichMenuIdOfUser( userId string, ) (*RichMenuIdResponse, error) { - response, body, error := client.GetRichMenuIdOfUserWithHttpInfo( + _, body, error := client.GetRichMenuIdOfUserWithHttpInfo( userId, ) @@ -2197,7 +2197,7 @@ func (client *MessagingApiAPI) GetRichMenuIdOfUserWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list func (client *MessagingApiAPI) GetRichMenuList() (*RichMenuListResponse, error) { - response, body, error := client.GetRichMenuListWithHttpInfo() + _, body, error := client.GetRichMenuListWithHttpInfo() return body, error } @@ -2255,7 +2255,7 @@ func (client *MessagingApiAPI) GetRoomMemberCount( roomId string, ) (*RoomMemberCountResponse, error) { - response, body, error := client.GetRoomMemberCountWithHttpInfo( + _, body, error := client.GetRoomMemberCountWithHttpInfo( roomId, ) @@ -2326,7 +2326,7 @@ func (client *MessagingApiAPI) GetRoomMemberProfile( userId string, ) (*RoomUserProfileResponse, error) { - response, body, error := client.GetRoomMemberProfileWithHttpInfo( + _, body, error := client.GetRoomMemberProfileWithHttpInfo( roomId, @@ -2404,7 +2404,7 @@ func (client *MessagingApiAPI) GetRoomMembersIds( start string, ) (*MembersIdsResponse, error) { - response, body, error := client.GetRoomMembersIdsWithHttpInfo( + _, body, error := client.GetRoomMembersIdsWithHttpInfo( roomId, @@ -2477,7 +2477,7 @@ func (client *MessagingApiAPI) GetRoomMembersIdsWithHttpInfo( // https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information func (client *MessagingApiAPI) GetWebhookEndpoint() (*GetWebhookEndpointResponse, error) { - response, body, error := client.GetWebhookEndpointWithHttpInfo() + _, body, error := client.GetWebhookEndpointWithHttpInfo() return body, error } @@ -2535,7 +2535,7 @@ func (client *MessagingApiAPI) IssueLinkToken( userId string, ) (*IssueLinkTokenResponse, error) { - response, body, error := client.IssueLinkTokenWithHttpInfo( + _, body, error := client.IssueLinkTokenWithHttpInfo( userId, ) @@ -2603,7 +2603,7 @@ func (client *MessagingApiAPI) LeaveGroup( groupId string, ) (struct{}, error) { - response, body, error := client.LeaveGroupWithHttpInfo( + _, body, error := client.LeaveGroupWithHttpInfo( groupId, ) @@ -2666,7 +2666,7 @@ func (client *MessagingApiAPI) LeaveRoom( roomId string, ) (struct{}, error) { - response, body, error := client.LeaveRoomWithHttpInfo( + _, body, error := client.LeaveRoomWithHttpInfo( roomId, ) @@ -2732,7 +2732,7 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUser( richMenuId string, ) (struct{}, error) { - response, body, error := client.LinkRichMenuIdToUserWithHttpInfo( + _, body, error := client.LinkRichMenuIdToUserWithHttpInfo( userId, @@ -2802,7 +2802,7 @@ func (client *MessagingApiAPI) LinkRichMenuIdToUsers( richMenuBulkLinkRequest *RichMenuBulkLinkRequest, ) (struct{}, error) { - response, body, error := client.LinkRichMenuIdToUsersWithHttpInfo( + _, body, error := client.LinkRichMenuIdToUsersWithHttpInfo( richMenuBulkLinkRequest, ) @@ -2869,7 +2869,7 @@ func (client *MessagingApiAPI) MarkMessagesAsRead( markMessagesAsReadRequest *MarkMessagesAsReadRequest, ) (struct{}, error) { - response, body, error := client.MarkMessagesAsReadWithHttpInfo( + _, body, error := client.MarkMessagesAsReadWithHttpInfo( markMessagesAsReadRequest, ) @@ -2939,7 +2939,7 @@ func (client *MessagingApiAPI) Multicast( xLineRetryKey string, ) (*map[string]interface{}, error) { - response, body, error := client.MulticastWithHttpInfo( + _, body, error := client.MulticastWithHttpInfo( multicastRequest, @@ -3021,7 +3021,7 @@ func (client *MessagingApiAPI) Narrowcast( xLineRetryKey string, ) (*map[string]interface{}, error) { - response, body, error := client.NarrowcastWithHttpInfo( + _, body, error := client.NarrowcastWithHttpInfo( narrowcastRequest, @@ -3103,7 +3103,7 @@ func (client *MessagingApiAPI) PushMessage( xLineRetryKey string, ) (*PushMessageResponse, error) { - response, body, error := client.PushMessageWithHttpInfo( + _, body, error := client.PushMessageWithHttpInfo( pushMessageRequest, @@ -3185,7 +3185,7 @@ func (client *MessagingApiAPI) PushMessagesByPhone( xLineDeliveryTag string, ) (struct{}, error) { - response, body, error := client.PushMessagesByPhoneWithHttpInfo( + _, body, error := client.PushMessagesByPhoneWithHttpInfo( pnpMessagesRequest, @@ -3259,7 +3259,7 @@ func (client *MessagingApiAPI) ReplyMessage( replyMessageRequest *ReplyMessageRequest, ) (*ReplyMessageResponse, error) { - response, body, error := client.ReplyMessageWithHttpInfo( + _, body, error := client.ReplyMessageWithHttpInfo( replyMessageRequest, ) @@ -3331,7 +3331,7 @@ func (client *MessagingApiAPI) RichMenuBatch( richMenuBatchRequest *RichMenuBatchRequest, ) (struct{}, error) { - response, body, error := client.RichMenuBatchWithHttpInfo( + _, body, error := client.RichMenuBatchWithHttpInfo( richMenuBatchRequest, ) @@ -3398,7 +3398,7 @@ func (client *MessagingApiAPI) SetDefaultRichMenu( richMenuId string, ) (struct{}, error) { - response, body, error := client.SetDefaultRichMenuWithHttpInfo( + _, body, error := client.SetDefaultRichMenuWithHttpInfo( richMenuId, ) @@ -3461,7 +3461,7 @@ func (client *MessagingApiAPI) SetWebhookEndpoint( setWebhookEndpointRequest *SetWebhookEndpointRequest, ) (struct{}, error) { - response, body, error := client.SetWebhookEndpointWithHttpInfo( + _, body, error := client.SetWebhookEndpointWithHttpInfo( setWebhookEndpointRequest, ) @@ -3528,7 +3528,7 @@ func (client *MessagingApiAPI) TestWebhookEndpoint( testWebhookEndpointRequest *TestWebhookEndpointRequest, ) (*TestWebhookEndpointResponse, error) { - response, body, error := client.TestWebhookEndpointWithHttpInfo( + _, body, error := client.TestWebhookEndpointWithHttpInfo( testWebhookEndpointRequest, ) @@ -3600,7 +3600,7 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUser( userId string, ) (struct{}, error) { - response, body, error := client.UnlinkRichMenuIdFromUserWithHttpInfo( + _, body, error := client.UnlinkRichMenuIdFromUserWithHttpInfo( userId, ) @@ -3663,7 +3663,7 @@ func (client *MessagingApiAPI) UnlinkRichMenuIdFromUsers( richMenuBulkUnlinkRequest *RichMenuBulkUnlinkRequest, ) (struct{}, error) { - response, body, error := client.UnlinkRichMenuIdFromUsersWithHttpInfo( + _, body, error := client.UnlinkRichMenuIdFromUsersWithHttpInfo( richMenuBulkUnlinkRequest, ) @@ -3733,7 +3733,7 @@ func (client *MessagingApiAPI) UpdateRichMenuAlias( updateRichMenuAliasRequest *UpdateRichMenuAliasRequest, ) (struct{}, error) { - response, body, error := client.UpdateRichMenuAliasWithHttpInfo( + _, body, error := client.UpdateRichMenuAliasWithHttpInfo( richMenuAliasId, @@ -3807,7 +3807,7 @@ func (client *MessagingApiAPI) ValidateBroadcast( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { - response, body, error := client.ValidateBroadcastWithHttpInfo( + _, body, error := client.ValidateBroadcastWithHttpInfo( validateMessageRequest, ) @@ -3874,7 +3874,7 @@ func (client *MessagingApiAPI) ValidateMulticast( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { - response, body, error := client.ValidateMulticastWithHttpInfo( + _, body, error := client.ValidateMulticastWithHttpInfo( validateMessageRequest, ) @@ -3941,7 +3941,7 @@ func (client *MessagingApiAPI) ValidateNarrowcast( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { - response, body, error := client.ValidateNarrowcastWithHttpInfo( + _, body, error := client.ValidateNarrowcastWithHttpInfo( validateMessageRequest, ) @@ -4008,7 +4008,7 @@ func (client *MessagingApiAPI) ValidatePush( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { - response, body, error := client.ValidatePushWithHttpInfo( + _, body, error := client.ValidatePushWithHttpInfo( validateMessageRequest, ) @@ -4075,7 +4075,7 @@ func (client *MessagingApiAPI) ValidateReply( validateMessageRequest *ValidateMessageRequest, ) (struct{}, error) { - response, body, error := client.ValidateReplyWithHttpInfo( + _, body, error := client.ValidateReplyWithHttpInfo( validateMessageRequest, ) @@ -4142,7 +4142,7 @@ func (client *MessagingApiAPI) ValidateRichMenuBatchRequest( richMenuBatchRequest *RichMenuBatchRequest, ) (struct{}, error) { - response, body, error := client.ValidateRichMenuBatchRequestWithHttpInfo( + _, body, error := client.ValidateRichMenuBatchRequestWithHttpInfo( richMenuBatchRequest, ) @@ -4209,7 +4209,7 @@ func (client *MessagingApiAPI) ValidateRichMenuObject( richMenuRequest *RichMenuRequest, ) (struct{}, error) { - response, body, error := client.ValidateRichMenuObjectWithHttpInfo( + _, body, error := client.ValidateRichMenuObjectWithHttpInfo( richMenuRequest, ) diff --git a/linebot/messaging_api/api_messaging_api_blob.go b/linebot/messaging_api/api_messaging_api_blob.go index 93ec411d..2c0b62ec 100644 --- a/linebot/messaging_api/api_messaging_api_blob.go +++ b/linebot/messaging_api/api_messaging_api_blob.go @@ -252,7 +252,7 @@ func (client *MessagingApiBlobAPI) GetMessageContentTranscodingByMessageId( messageId string, ) (*GetMessageContentTranscodingResponse, error) { - response, body, error := client.GetMessageContentTranscodingByMessageIdWithHttpInfo( + _, body, error := client.GetMessageContentTranscodingByMessageIdWithHttpInfo( messageId, ) @@ -388,7 +388,7 @@ func (client *MessagingApiBlobAPI) SetRichMenuImage( bodyReader io.Reader, ) (struct{}, error) { - response, body, error := client.SetRichMenuImageWithHttpInfo( + _, body, error := client.SetRichMenuImageWithHttpInfo( richMenuId, diff --git a/linebot/module/api_line_module.go b/linebot/module/api_line_module.go index de156fc9..79e09bc2 100644 --- a/linebot/module/api_line_module.go +++ b/linebot/module/api_line_module.go @@ -130,7 +130,7 @@ func (client *LineModuleAPI) AcquireChatControl( acquireChatControlRequest *AcquireChatControlRequest, ) (struct{}, error) { - response, body, error := client.AcquireChatControlWithHttpInfo( + _, body, error := client.AcquireChatControlWithHttpInfo( chatId, @@ -204,7 +204,7 @@ func (client *LineModuleAPI) DetachModule( detachModuleRequest *DetachModuleRequest, ) (struct{}, error) { - response, body, error := client.DetachModuleWithHttpInfo( + _, body, error := client.DetachModuleWithHttpInfo( detachModuleRequest, ) @@ -274,7 +274,7 @@ func (client *LineModuleAPI) GetModules( limit int32, ) (*GetModulesResponse, error) { - response, body, error := client.GetModulesWithHttpInfo( + _, body, error := client.GetModulesWithHttpInfo( start, @@ -351,7 +351,7 @@ func (client *LineModuleAPI) ReleaseChatControl( chatId string, ) (struct{}, error) { - response, body, error := client.ReleaseChatControlWithHttpInfo( + _, body, error := client.ReleaseChatControlWithHttpInfo( chatId, ) diff --git a/linebot/module_attach/api_line_module_attach.go b/linebot/module_attach/api_line_module_attach.go index cf7edfd6..407c529c 100644 --- a/linebot/module_attach/api_line_module_attach.go +++ b/linebot/module_attach/api_line_module_attach.go @@ -153,7 +153,7 @@ func (client *LineModuleAttachAPI) AttachModule( brandType string, ) (*AttachModuleResponse, error) { - response, body, error := client.AttachModuleWithHttpInfo( + _, body, error := client.AttachModuleWithHttpInfo( grantType, diff --git a/linebot/shop/api_shop.go b/linebot/shop/api_shop.go index 28e64762..1b308b46 100644 --- a/linebot/shop/api_shop.go +++ b/linebot/shop/api_shop.go @@ -126,7 +126,7 @@ func (client *ShopAPI) MissionStickerV3( missionStickerRequest *MissionStickerRequest, ) (struct{}, error) { - response, body, error := client.MissionStickerV3WithHttpInfo( + _, body, error := client.MissionStickerV3WithHttpInfo( missionStickerRequest, )