-
Notifications
You must be signed in to change notification settings - Fork 7
/
flatten.go
52 lines (43 loc) · 1.55 KB
/
flatten.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package helper
import (
"time"
"github.com/RJPearson94/terraform-provider-twilio/twilio/utils"
"github.com/RJPearson94/twilio-sdk-go/service/conversations/v1/service/configuration/notification"
"github.com/RJPearson94/twilio-sdk-go/service/conversations/v1/service/conversation"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func FlattenTimers(d *schema.ResourceData, timers conversation.FetchConversationTimersResponse) *[]interface{} {
timerMap := make(map[string]interface{})
if _, ok := d.GetOk("timers"); ok {
timerMap["closed"] = utils.OptionalStringWithEmptyStringOnChange(d, "timers.0.closed")
timerMap["inactive"] = utils.OptionalStringWithEmptyStringOnChange(d, "timers.0.inactive")
}
if timers.DateClosed != nil {
timerMap["date_closed"] = timers.DateClosed.Format(time.RFC3339)
}
if timers.DateInactive != nil {
timerMap["date_inactive"] = timers.DateInactive.Format(time.RFC3339)
}
return &[]interface{}{
timerMap,
}
}
func FlattenNotificationsAction(input notification.FetchNotificationConversationActionResponse) *[]interface{} {
return &[]interface{}{
map[string]interface{}{
"enabled": input.Enabled,
"template": input.Template,
"sound": input.Sound,
},
}
}
func FlattenNotificationsNewMessage(input notification.FetchNotificationNewMessageResponse) *[]interface{} {
return &[]interface{}{
map[string]interface{}{
"enabled": input.Enabled,
"template": input.Template,
"sound": input.Sound,
"badge_count_enabled": input.BadgeCountEnabled,
},
}
}