Skip to content

Commit bc966b9

Browse files
committed
Change optional datetimes (e.g. UpdatedAt) to pointers.
Versions later than Go 1.7 unmarshal a "null" datetime to time.Time's zero value, but 1.7 errors. See: https://travis-ci.org/messagebird/go-rest-api/jobs/421016501
1 parent e41d18d commit bc966b9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

conversation/api.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ type Conversation struct {
4848
Messages *MessagesCount
4949
Status ConversationStatus
5050
CreatedDatetime time.Time
51-
UpdatedDatetime time.Time
52-
LastReceivedDatetime time.Time
51+
UpdatedDatetime *time.Time
52+
LastReceivedDatetime *time.Time
5353
}
5454

5555
type Contact struct {
@@ -60,7 +60,7 @@ type Contact struct {
6060
LastName string
6161
CustomDetails map[string]interface{}
6262
CreatedAt time.Time
63-
UpdatedAt time.Time
63+
UpdatedAt *time.Time
6464
}
6565

6666
type Channel struct {
@@ -69,7 +69,7 @@ type Channel struct {
6969
PlatformID string
7070
Status string
7171
CreatedDatetime time.Time
72-
UpdatedDatetime time.Time
72+
UpdatedDatetime *time.Time
7373
}
7474

7575
type MessagesCount struct {
@@ -114,7 +114,7 @@ type Message struct {
114114
Type MessageType
115115
Content MessageContent
116116
CreatedDatetime time.Time
117-
UpdatedDatetime time.Time
117+
UpdatedDatetime *time.Time
118118
}
119119

120120
type MessageDirection string
@@ -205,7 +205,7 @@ type Webhook struct {
205205
Events []WebhookEvent
206206
URL string
207207
CreatedDatetime time.Time
208-
UpdatedDatetime time.Time
208+
UpdatedDatetime *time.Time
209209
}
210210

211211
type WebhookEvent string
@@ -236,7 +236,7 @@ func (c *Contact) UnmarshalJSON(data []byte) error {
236236
LastName string
237237
CustomDetails map[string]interface{}
238238
CreatedAt time.Time
239-
UpdatedAt time.Time
239+
UpdatedAt *time.Time
240240
}{}
241241

242242
if err := json.Unmarshal(data, &target); err != nil {

0 commit comments

Comments
 (0)