Skip to content

Commit 67069fd

Browse files
committed
NO-ISSUE clean up
1 parent 7da01b3 commit 67069fd

File tree

2 files changed

+1
-320
lines changed

2 files changed

+1
-320
lines changed

linebot/event.go

Lines changed: 1 addition & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const (
3535
EventTypePostback EventType = "postback"
3636
EventTypeBeacon EventType = "beacon"
3737
EventTypeAccountLink EventType = "accountLink"
38-
EventTypeThings EventType = "things"
3938
EventTypeUnsend EventType = "unsend"
4039
EventTypeVideoPlayComplete EventType = "videoPlayComplete"
4140
)
@@ -126,52 +125,6 @@ type AccountLink struct {
126125
Nonce string
127126
}
128127

129-
// ThingsResult type
130-
// Deprecated: Use OpenAPI based classes instead.
131-
type ThingsResult struct {
132-
ScenarioID string
133-
Revision int
134-
StartTime int64
135-
EndTime int64
136-
ResultCode ThingsResultCode
137-
ActionResults []*ThingsActionResult
138-
BLENotificationPayload []byte
139-
ErrorReason string
140-
}
141-
142-
// ThingsResultCode type
143-
type ThingsResultCode string
144-
145-
// ThingsResultCode constants
146-
const (
147-
ThingsResultCodeSuccess ThingsResultCode = "success"
148-
ThingsResultCodeGattError ThingsResultCode = "gatt_error"
149-
ThingsResultCodeRuntimeError ThingsResultCode = "runtime_error"
150-
)
151-
152-
// ThingsActionResult type
153-
// Deprecated: Use OpenAPI based classes instead.
154-
type ThingsActionResult struct {
155-
Type ThingsActionResultType
156-
Data []byte
157-
}
158-
159-
// ThingsActionResultType type
160-
type ThingsActionResultType string
161-
162-
// ThingsActionResultType constants
163-
const (
164-
ThingsActionResultTypeBinary ThingsActionResultType = "binary"
165-
ThingsActionResultTypeVoid ThingsActionResultType = "void"
166-
)
167-
168-
// Things type
169-
// Deprecated: Use OpenAPI based classes instead.
170-
type Things struct {
171-
DeviceID string
172-
Type string
173-
Result *ThingsResult
174-
}
175128

176129
// Unsend type
177130
// Deprecated: Use OpenAPI based classes instead.
@@ -220,7 +173,6 @@ type Event struct {
220173
Postback *Postback
221174
Beacon *Beacon
222175
AccountLink *AccountLink
223-
Things *Things
224176
Members []*EventSource
225177
Unsend *Unsend
226178
VideoPlayComplete *VideoPlayComplete
@@ -241,7 +193,6 @@ type rawEvent struct {
241193
AccountLink *rawAccountLinkEvent `json:"link,omitempty"`
242194
Joined *rawMemberEvent `json:"joined,omitempty"`
243195
Left *rawMemberEvent `json:"left,omitempty"`
244-
Things *rawThingsEvent `json:"things,omitempty"`
245196
Unsend *Unsend `json:"unsend,omitempty"`
246197
VideoPlayComplete *VideoPlayComplete `json:"videoPlayComplete,omitempty"`
247198
WebhookEventID string `json:"webhookEventId"`
@@ -288,30 +239,6 @@ type rawAccountLinkEvent struct {
288239
Nonce string `json:"nonce"`
289240
}
290241

291-
// Deprecated: Use OpenAPI based classes instead.
292-
type rawThingsResult struct {
293-
ScenarioID string `json:"scenarioId"`
294-
Revision int `json:"revision"`
295-
StartTime int64 `json:"startTime"`
296-
EndTime int64 `json:"endTime"`
297-
ResultCode ThingsResultCode `json:"resultCode"`
298-
ActionResults []*rawThingsActionResult `json:"actionResults"`
299-
BLENotificationPayload string `json:"bleNotificationPayload,omitempty"`
300-
ErrorReason string `json:"errorReason,omitempty"`
301-
}
302-
303-
// Deprecated: Use OpenAPI based classes instead.
304-
type rawThingsActionResult struct {
305-
Type ThingsActionResultType `json:"type,omitempty"`
306-
Data string `json:"data,omitempty"`
307-
}
308-
309-
// Deprecated: Use OpenAPI based classes instead.
310-
type rawThingsEvent struct {
311-
DeviceID string `json:"deviceId"`
312-
Type string `json:"type"`
313-
Result *rawThingsResult `json:"result,omitempty"`
314-
}
315242

316243
const (
317244
milliSecPerSec = int64(time.Second / time.Millisecond)
@@ -355,33 +282,7 @@ func (e *Event) MarshalJSON() ([]byte, error) {
355282
raw.Left = &rawMemberEvent{
356283
Members: e.Members,
357284
}
358-
case EventTypeThings:
359-
raw.Things = &rawThingsEvent{
360-
DeviceID: e.Things.DeviceID,
361-
Type: e.Things.Type,
362-
}
363-
if e.Things.Result != nil {
364-
raw.Things.Result = &rawThingsResult{
365-
ScenarioID: e.Things.Result.ScenarioID,
366-
Revision: e.Things.Result.Revision,
367-
StartTime: e.Things.Result.StartTime,
368-
EndTime: e.Things.Result.EndTime,
369-
ResultCode: e.Things.Result.ResultCode,
370-
371-
BLENotificationPayload: string(e.Things.Result.BLENotificationPayload),
372-
ErrorReason: e.Things.Result.ErrorReason,
373-
}
374-
if e.Things.Result.ActionResults != nil {
375-
raw.Things.Result.ActionResults = make([]*rawThingsActionResult, len(e.Things.Result.ActionResults))
376-
}
377-
for i := range e.Things.Result.ActionResults {
378-
raw.Things.Result.ActionResults[i] = &rawThingsActionResult{
379-
Type: e.Things.Result.ActionResults[i].Type,
380-
Data: string(e.Things.Result.ActionResults[i].Data),
381-
}
382-
}
383-
}
384-
}
285+
}
385286

386287
switch m := e.Message.(type) {
387288
case *TextMessage:
@@ -532,30 +433,6 @@ func (e *Event) UnmarshalJSON(body []byte) (err error) {
532433
e.Members = rawEvent.Joined.Members
533434
case EventTypeMemberLeft:
534435
e.Members = rawEvent.Left.Members
535-
case EventTypeThings:
536-
e.Things = &Things{
537-
Type: rawEvent.Things.Type,
538-
DeviceID: rawEvent.Things.DeviceID,
539-
}
540-
if rawEvent.Things.Result != nil {
541-
rawResult := rawEvent.Things.Result
542-
e.Things.Result = &ThingsResult{
543-
ScenarioID: rawResult.ScenarioID,
544-
Revision: rawResult.Revision,
545-
StartTime: rawResult.StartTime,
546-
EndTime: rawResult.EndTime,
547-
ResultCode: rawResult.ResultCode,
548-
ActionResults: make([]*ThingsActionResult, len(rawResult.ActionResults)),
549-
BLENotificationPayload: []byte(rawResult.BLENotificationPayload),
550-
ErrorReason: rawResult.ErrorReason,
551-
}
552-
for i := range rawResult.ActionResults {
553-
e.Things.Result.ActionResults[i] = &ThingsActionResult{
554-
Type: rawResult.ActionResults[i].Type,
555-
Data: []byte(rawResult.ActionResults[i].Data),
556-
}
557-
}
558-
}
559436
case EventTypeUnsend:
560437
e.Unsend = rawEvent.Unsend
561438
case EventTypeVideoPlayComplete:

linebot/webhook_test.go

Lines changed: 0 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -580,100 +580,6 @@ var webhookTestRequestBody = `{
580580
]
581581
}
582582
},
583-
{
584-
"type": "things",
585-
"mode": "active",
586-
"timestamp": 1462629479859,
587-
"source": {
588-
"type": "user",
589-
"userId": "U91eeaf62d901234567890123456789ab"
590-
},
591-
"webhookEventId": "01FZ74ASS536FW97EX38NKCZQK",
592-
"deliveryContext": {
593-
"isRedelivery": false
594-
},
595-
"things": {
596-
"deviceId": "t2c449c9d1...",
597-
"type": "link"
598-
}
599-
},
600-
{
601-
"type": "things",
602-
"mode": "active",
603-
"timestamp": 1462629479859,
604-
"source": {
605-
"type": "user",
606-
"userId": "U91eeaf62d901234567890123456789ab"
607-
},
608-
"webhookEventId": "01FZ74ASS536FW97EX38NKCZQK",
609-
"deliveryContext": {
610-
"isRedelivery": false
611-
},
612-
"things": {
613-
"deviceId": "t2c449c9d1...",
614-
"type": "unlink"
615-
}
616-
},
617-
{
618-
"type": "things",
619-
"mode": "active",
620-
"timestamp": 1462629479859,
621-
"source": {
622-
"type": "user",
623-
"userId": "U91eeaf62d901234567890123456789ab"
624-
},
625-
"webhookEventId": "01FZ74ASS536FW97EX38NKCZQK",
626-
"deliveryContext": {
627-
"isRedelivery": false
628-
},
629-
"things": {
630-
"deviceId": "t016b8dc6...",
631-
"type": "scenarioResult",
632-
"result": {
633-
"scenarioId": "01DE9CH7H...",
634-
"revision": 3,
635-
"startTime": 1563511217095,
636-
"endTime": 1563511217097,
637-
"resultCode": "success",
638-
"bleNotificationPayload": "AQ==",
639-
"actionResults": [
640-
{
641-
"type": "binary",
642-
"data": "/w=="
643-
}
644-
]
645-
}
646-
}
647-
},
648-
{
649-
"type":"things",
650-
"mode": "active",
651-
"replyToken":"f026a377...",
652-
"source":{
653-
"userId":"U91eeaf62d901234567890123456789ab",
654-
"type":"user"
655-
},
656-
"webhookEventId": "01FZ74ASS536FW97EX38NKCZQK",
657-
"deliveryContext": {
658-
"isRedelivery": false
659-
},
660-
"timestamp":1563511218376,
661-
"things":{
662-
"deviceId":"t016b8d...",
663-
"result":{
664-
"scenarioId":"01DE9CH7H...",
665-
"revision":3,
666-
"startTime":1563511217095,
667-
"endTime":1563511217097,
668-
"resultCode":"gatt_error",
669-
"errorReason":"c.l.h.D: No characteristic is found for the given UUID.",
670-
"actionResults":[
671-
672-
]
673-
},
674-
"type":"scenarioResult"
675-
}
676-
},
677583
{
678584
"replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
679585
"type": "message",
@@ -1334,99 +1240,6 @@ var webhookTestWantEvents = []*Event{
13341240
},
13351241
},
13361242
},
1337-
{
1338-
Type: EventTypeThings,
1339-
Mode: EventModeActive,
1340-
Timestamp: time.Date(2016, time.May, 7, 13, 57, 59, int(859*time.Millisecond), time.UTC),
1341-
Source: &EventSource{
1342-
Type: EventSourceTypeUser,
1343-
UserID: "U91eeaf62d901234567890123456789ab",
1344-
},
1345-
WebhookEventID: "01FZ74ASS536FW97EX38NKCZQK",
1346-
DeliveryContext: DeliveryContext{
1347-
IsRedelivery: false,
1348-
},
1349-
Things: &Things{
1350-
DeviceID: `t2c449c9d1...`,
1351-
Type: `link`,
1352-
},
1353-
},
1354-
{
1355-
Type: EventTypeThings,
1356-
Mode: EventModeActive,
1357-
Timestamp: time.Date(2016, time.May, 7, 13, 57, 59, int(859*time.Millisecond), time.UTC),
1358-
Source: &EventSource{
1359-
Type: EventSourceTypeUser,
1360-
UserID: "U91eeaf62d901234567890123456789ab",
1361-
},
1362-
WebhookEventID: "01FZ74ASS536FW97EX38NKCZQK",
1363-
DeliveryContext: DeliveryContext{
1364-
IsRedelivery: false,
1365-
},
1366-
Things: &Things{
1367-
DeviceID: `t2c449c9d1...`,
1368-
Type: `unlink`,
1369-
},
1370-
},
1371-
{
1372-
Type: EventTypeThings,
1373-
Mode: EventModeActive,
1374-
Timestamp: time.Date(2016, time.May, 7, 13, 57, 59, int(859*time.Millisecond), time.UTC),
1375-
Source: &EventSource{
1376-
Type: EventSourceTypeUser,
1377-
UserID: "U91eeaf62d901234567890123456789ab",
1378-
},
1379-
WebhookEventID: "01FZ74ASS536FW97EX38NKCZQK",
1380-
DeliveryContext: DeliveryContext{
1381-
IsRedelivery: false,
1382-
},
1383-
Things: &Things{
1384-
DeviceID: "t016b8dc6...",
1385-
Type: "scenarioResult",
1386-
Result: &ThingsResult{
1387-
ScenarioID: "01DE9CH7H...",
1388-
Revision: 3,
1389-
StartTime: 1563511217095,
1390-
EndTime: 1563511217097,
1391-
ResultCode: ThingsResultCodeSuccess,
1392-
BLENotificationPayload: []byte(`AQ==`),
1393-
ActionResults: []*ThingsActionResult{
1394-
{
1395-
Type: ThingsActionResultTypeBinary,
1396-
Data: []byte(`/w==`),
1397-
},
1398-
},
1399-
},
1400-
},
1401-
},
1402-
{
1403-
Type: EventTypeThings,
1404-
Mode: EventModeActive,
1405-
ReplyToken: "f026a377...",
1406-
Timestamp: time.Date(2019, time.July, 19, 4, 40, 18, int(376*time.Millisecond), time.UTC),
1407-
Source: &EventSource{
1408-
Type: EventSourceTypeUser,
1409-
UserID: "U91eeaf62d901234567890123456789ab",
1410-
},
1411-
WebhookEventID: "01FZ74ASS536FW97EX38NKCZQK",
1412-
DeliveryContext: DeliveryContext{
1413-
IsRedelivery: false,
1414-
},
1415-
Things: &Things{
1416-
DeviceID: "t016b8d...",
1417-
Type: "scenarioResult",
1418-
Result: &ThingsResult{
1419-
ScenarioID: "01DE9CH7H...",
1420-
Revision: 3,
1421-
StartTime: 1563511217095,
1422-
EndTime: 1563511217097,
1423-
ResultCode: ThingsResultCodeGattError,
1424-
ErrorReason: "c.l.h.D: No characteristic is found for the given UUID.",
1425-
ActionResults: []*ThingsActionResult{},
1426-
BLENotificationPayload: []byte{},
1427-
},
1428-
},
1429-
},
14301243
{
14311244
ReplyToken: "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
14321245
Type: EventTypeMessage,
@@ -1562,15 +1375,6 @@ func TestParseRequest(t *testing.T) {
15621375
want := webhookTestWantEvents[i]
15631376
if !reflect.DeepEqual(got, want) {
15641377
t.Errorf("Event %d %v; want %v", i, got, want)
1565-
gota := got
1566-
if !reflect.DeepEqual(
1567-
gota.Things.Result.BLENotificationPayload,
1568-
want.Things.Result.BLENotificationPayload,
1569-
) {
1570-
t.Log("this")
1571-
t.Log(gota.Things.Result.BLENotificationPayload == nil)
1572-
t.Log(want.Things.Result.BLENotificationPayload == nil)
1573-
}
15741378
}
15751379
}
15761380
}))

0 commit comments

Comments
 (0)