Skip to content

Commit

Permalink
Moving the APNS Endpoints to Constants
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Jul 19, 2018
1 parent 54e104b commit 51e72c4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions azurerm/resource_arm_notification_hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

const apnsProductionName = "Production"
const apnsProductionEndpoint = "https://api.push.apple.com:443/3/device"
const apnsSandboxName = "Sandbox"
const apnsSandboxEndpoint = "https://api.development.push.apple.com:443/3/device"

func resourceArmNotificationHub() *schema.Resource {
return &schema.Resource{
Create: resourceArmNotificationHubCreateUpdate,
Expand Down Expand Up @@ -70,8 +75,8 @@ func resourceArmNotificationHub() *schema.Resource {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"Production",
"Sandbox",
apnsProductionName,
apnsSandboxName,
}, false),
},
"bundle_id": {
Expand Down Expand Up @@ -250,8 +255,8 @@ func expandNotificationHubsAPNSCredentials(inputs []interface{}) (*notificationh
token := input["token"].(string)

applicationEndpoints := map[string]string{
"Production": "https://api.push.apple.com:443/3/device",
"Sandbox": "https://api.development.push.apple.com:443/3/device",
apnsProductionName: apnsProductionEndpoint,
apnsStagingName: apnsSandboxEndpoint,
}
endpoint := applicationEndpoints[applicationMode]

Expand Down Expand Up @@ -280,8 +285,8 @@ func flattenNotificationHubsAPNSCredentials(input *notificationhubs.ApnsCredenti

if endpoint := input.Endpoint; endpoint != nil {
applicationEndpoints := map[string]string{
"https://api.push.apple.com:443/3/device": "Production",
"https://api.development.push.apple.com:443/3/device": "Sandbox",
apnsProductionEndpoint: apnsProductionName,
apnsSandboxEndpoint: apnsSandboxName,
}
applicationMode := applicationEndpoints[*endpoint]
output["application_mode"] = applicationMode
Expand Down

0 comments on commit 51e72c4

Please sign in to comment.