Skip to content

Commit

Permalink
Find a way to gracefully avoid one breaking change in #405
Browse files Browse the repository at this point in the history
In #405 I opted to rename one of the types to be more consistent, and in the
moment totally forgot about type aliases. A type alias allows you to rename a
type in a non-breaking way, by converting the old name to be an alias to the new
one.

This change does that, and effectively removes one breaking change from v1.5.0.

I also do the sane thing to unify the Priority type into one.
  • Loading branch information
theckman committed Jan 18, 2022
1 parent 77a73c9 commit 428048d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions priorites.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ import (
"github.com/google/go-querystring/query"
)

// PriorityProperty is a single priorty object returned from the Priorities endpoint
type PriorityProperty struct {
APIObject
Name string `json:"name"`
Description string `json:"description"`
}
// PriorityProperty is the original type name and is retained as an alias for API
// compatibility.
//
// Deprecated: Use type Priority instead; will be removed in V2
type PriorityProperty = Priority

// ListPrioritiesResponse repreents the API response from PagerDuty when listing
// the configured priorities.
type ListPrioritiesResponse struct {
APIListObject
Priorities []PriorityProperty `json:"priorities"`
Priorities []Priority `json:"priorities"`
}

// Priorities is the original type name and is retained as an alias for API
// compatibility.
//
// Deprecated: Use type ListPrioritiesResponse instead; will be removed in V2
type Priorities = ListPrioritiesResponse

// ListPrioritiesOptions is the data structure used when calling the
// ListPriorities API endpoint.
type ListPrioritiesOptions struct {
Expand Down
2 changes: 1 addition & 1 deletion priorities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestPriorities_List(t *testing.T) {

want := &ListPrioritiesResponse{
APIListObject: listObj,
Priorities: []PriorityProperty{
Priorities: []Priority{
{
APIObject: APIObject{
ID: "1",
Expand Down

0 comments on commit 428048d

Please sign in to comment.