Skip to content

Commit 0d01ff1

Browse files
authored
Merge pull request #95 from sugyan/update-liff-api
Update around LIFF API
2 parents 94192b9 + 47c0dbe commit 0d01ff1

File tree

5 files changed

+326
-30
lines changed

5 files changed

+326
-30
lines changed

linebot/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ const (
4848
APIEndpointDownloadRichMenuImage = "/v2/bot/richmenu/%s/content" // Download: GET / Upload: POST
4949
APIEndpointUploadRichMenuImage = "/v2/bot/richmenu/%s/content" // Download: GET / Upload: POST
5050

51-
APIEndpointGetLIFFAPP = "/liff/v1/apps"
52-
APIEndpointAddLIFFAPP = "/liff/v1/apps"
53-
APIEndpointUpdateLIFFAPP = "/liff/v1/apps/%s/view"
54-
APIEndpointDeleteLIFFAPP = "/liff/v1/apps/%s"
51+
APIEndpointGetAllLIFFApps = "/liff/v1/apps"
52+
APIEndpointAddLIFFApp = "/liff/v1/apps"
53+
APIEndpointUpdateLIFFApp = "/liff/v1/apps/%s/view"
54+
APIEndpointDeleteLIFFApp = "/liff/v1/apps/%s"
5555

5656
APIEndpointLinkToken = "/v2/bot/user/%s/linkToken"
5757
)

linebot/liff.go

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2018 LINE Corporation
2+
//
3+
// LINE Corporation licenses this file to you under the Apache License,
4+
// version 2.0 (the "License"); you may not use this file except in compliance
5+
// with the License. You may obtain a copy of the License at:
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
115
package linebot
216

317
import (
@@ -14,17 +28,12 @@ type LIFFViewType string
1428
// LIFFViewType constants
1529
const (
1630
LIFFViewTypeCompact LIFFViewType = "compact"
17-
LIFFViewTypeTail LIFFViewType = "tail"
31+
LIFFViewTypeTall LIFFViewType = "tall"
1832
LIFFViewTypeFull LIFFViewType = "full"
1933
)
2034

21-
// LIFFIDResponse type
22-
type LIFFIDResponse struct {
23-
LIFFID string `json:"liffId"`
24-
}
25-
26-
// LIFFAPP type
27-
type LIFFAPP struct {
35+
// LIFFApp type
36+
type LIFFApp struct {
2837
LIFFID string `json:"liffId"`
2938
View View `json:"view"`
3039
}
@@ -60,8 +69,8 @@ func (call *GetLIFFAllCall) WithContext(ctx context.Context) *GetLIFFAllCall {
6069
}
6170

6271
// Do method
63-
func (call *GetLIFFAllCall) Do() (*LIFFResponse, error) {
64-
res, err := call.c.get(call.ctx, APIEndpointGetLIFFAPP, nil)
72+
func (call *GetLIFFAllCall) Do() (*LIFFAppsResponse, error) {
73+
res, err := call.c.get(call.ctx, APIEndpointGetAllLIFFApps, nil)
6574
if res != nil && res.Body != nil {
6675
defer res.Body.Close()
6776
}
@@ -75,7 +84,7 @@ func (call *GetLIFFAllCall) Do() (*LIFFResponse, error) {
7584
func (client *Client) AddLIFF(view View) *AddLIFFCall {
7685
return &AddLIFFCall{
7786
c: client,
78-
View: view,
87+
view: view,
7988
}
8089
}
8190

@@ -84,7 +93,7 @@ type AddLIFFCall struct {
8493
c *Client
8594
ctx context.Context
8695

87-
View View
96+
view View
8897
}
8998

9099
// WithContext method
@@ -98,7 +107,7 @@ func (call *AddLIFFCall) encodeJSON(w io.Writer) error {
98107
return enc.Encode(&struct {
99108
View View `json:"view"`
100109
}{
101-
View: call.View,
110+
View: call.view,
102111
})
103112
}
104113

@@ -108,7 +117,7 @@ func (call *AddLIFFCall) Do() (*LIFFIDResponse, error) {
108117
if err := call.encodeJSON(&buf); err != nil {
109118
return nil, err
110119
}
111-
res, err := call.c.post(call.ctx, APIEndpointAddLIFFAPP, &buf)
120+
res, err := call.c.post(call.ctx, APIEndpointAddLIFFApp, &buf)
112121
if res != nil && res.Body != nil {
113122
defer res.Body.Close()
114123
}
@@ -122,7 +131,7 @@ func (call *AddLIFFCall) Do() (*LIFFIDResponse, error) {
122131
func (client *Client) UpdateLIFF(liffID string, view View) *UpdateLIFFCall {
123132
return &UpdateLIFFCall{
124133
c: client,
125-
LIFFID: liffID,
134+
liffID: liffID,
126135
view: view,
127136
}
128137
}
@@ -132,7 +141,7 @@ type UpdateLIFFCall struct {
132141
c *Client
133142
ctx context.Context
134143

135-
LIFFID string
144+
liffID string
136145
view View
137146
}
138147

@@ -160,7 +169,7 @@ func (call *UpdateLIFFCall) Do() (*BasicResponse, error) {
160169
return nil, err
161170
}
162171

163-
endpoint := fmt.Sprintf(APIEndpointUpdateLIFFAPP, call.LIFFID)
172+
endpoint := fmt.Sprintf(APIEndpointUpdateLIFFApp, call.liffID)
164173
res, err := call.c.put(call.ctx, endpoint, &buf)
165174
if res != nil && res.Body != nil {
166175
defer res.Body.Close()
@@ -175,7 +184,7 @@ func (call *UpdateLIFFCall) Do() (*BasicResponse, error) {
175184
func (client *Client) DeleteLIFF(liffID string) *DeleteLIFFCall {
176185
return &DeleteLIFFCall{
177186
c: client,
178-
LIFFID: liffID,
187+
liffID: liffID,
179188
}
180189
}
181190

@@ -184,7 +193,7 @@ type DeleteLIFFCall struct {
184193
c *Client
185194
ctx context.Context
186195

187-
LIFFID string
196+
liffID string
188197
}
189198

190199
// WithContext method
@@ -195,7 +204,7 @@ func (call *DeleteLIFFCall) WithContext(ctx context.Context) *DeleteLIFFCall {
195204

196205
// Do method
197206
func (call *DeleteLIFFCall) Do() (*BasicResponse, error) {
198-
endpoint := fmt.Sprintf(APIEndpointDeleteLIFFAPP, call.LIFFID)
207+
endpoint := fmt.Sprintf(APIEndpointDeleteLIFFApp, call.liffID)
199208
res, err := call.c.delete(call.ctx, endpoint)
200209
if res != nil && res.Body != nil {
201210
defer res.Body.Close()

0 commit comments

Comments
 (0)