Skip to content

Commit

Permalink
Merge pull request #167 from tamccall/sla-policy-fix
Browse files Browse the repository at this point in the history
Fixing json key on policy metric
  • Loading branch information
nukosuke authored Apr 6, 2020
2 parents 41b74f5 + d9215b1 commit 46a12a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 13 additions & 1 deletion zendesk/sla_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ type SLAPolicyFilter struct {
Value string `json:"value"`
}

// SLA Policy metric values
//
// ref: https://developer.zendesk.com/rest_api/docs/support/sla_policies#metrics
const (
AgentWorkTimeMetric = "agent_work_time"
FirstReplyTimeMetric = "first_reply_time"
NextReplyTimeMetric = "next_reply_time"
PausableUpdateTimeMetric = "pausable_update_time"
PeriodicUpdateTimeMetric = "periodic_update_time"
RequesterWaitTimeMetric = "requester_wait_time"
)

type SLAPolicyMetric struct {
Priority string `json:"priority"`
Metric string `json:"metric"`
Expand All @@ -36,7 +48,7 @@ type SLAPolicy struct {
All []SLAPolicyFilter `json:"all"`
Any []SLAPolicyFilter `json:"any"`
} `json:"filter"`
PolicyMetrics []SLAPolicyMetric `json:"policy_metric"`
PolicyMetrics []SLAPolicyMetric `json:"policy_metrics,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
Expand Down
6 changes: 5 additions & 1 deletion zendesk/sla_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ func TestCreateSLAPolicy(t *testing.T) {
client := newTestClient(mockAPI)
defer mockAPI.Close()

_, err := client.CreateSLAPolicy(ctx, SLAPolicy{})
policy, err := client.CreateSLAPolicy(ctx, SLAPolicy{})
if err != nil {
t.Fatalf("Failed to send request to create sla policy: %s", err)
}

if len(policy.PolicyMetrics) == 0 {
t.Fatal("Failed to set the policy metrics from the json response")
}
}

func TestGetSLAPolicy(t *testing.T) {
Expand Down

0 comments on commit 46a12a2

Please sign in to comment.