Skip to content

Commit

Permalink
Merge pull request #12 from hunterlong/routing-type-param
Browse files Browse the repository at this point in the history
Add routing_type param for regex or jinja2 route match
  • Loading branch information
iskhakov authored Jun 23, 2023
2 parents bb83f91 + 4b93b13 commit 75ed784
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
8 changes: 6 additions & 2 deletions route.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Route struct {
EscalationChainId string `json:"escalation_chain_id"`
Position int `json:"position"`
RoutingRegex string `json:"routing_regex"`
RoutingType string `json:"routing_type"`
IsTheLastRoute bool `json:"is_the_last_route"`
SlackRoute *SlackRoute `json:"slack"`
TelegramRoute *TelegramRoute `json:"telegram"`
Expand All @@ -45,17 +46,18 @@ type SlackRoute struct {
}
type TelegramRoute struct {
Id *string `json:"id"`
Enabled bool `json:"enabled"`
Enabled bool `json:"enabled"`
}
type MSTeamsRoute struct {
Id *string `json:"id"`
Enabled bool `json:"enabled"`
Enabled bool `json:"enabled"`
}

type ListRouteOptions struct {
ListOptions
IntegrationId string `url:"integration_id,omitempty" json:"integration_id,omitempty"`
RoutingRegex string `url:"routing_regex,omitempty" json:"routing_regex,omitempty"`
RoutingType string `url:"routing_type,omitempty" json:"routing_type,omitempty"`
}

// ListRoutes fetches all routes for authorized organization
Expand Down Expand Up @@ -106,6 +108,7 @@ type CreateRouteOptions struct {
EscalationChainId string `json:"escalation_chain_id,omitempty"`
Position *int `json:"position,omitempty"`
RoutingRegex string `json:"routing_regex,omitempty"`
RoutingType string `json:"routing_type,omitempty"`
Slack *SlackRoute `json:"slack,omitempty"`
Telegram *TelegramRoute `json:"telegram,omitempty"`
MSTeams *MSTeamsRoute `json:"msteams,omitempty"`
Expand Down Expand Up @@ -141,6 +144,7 @@ type UpdateRouteOptions struct {
Telegram *TelegramRoute `json:"telegram,omitempty"`
MSTeams *MSTeamsRoute `json:"msteams,omitempty"`
RoutingRegex string `json:"routing_regex,omitempty"`
RoutingType string `json:"routing_type,omitempty"`
ManualOrder bool `url:"manual_order,omitempty" json:"manual_order,omitempty"`
}

Expand Down
23 changes: 13 additions & 10 deletions route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@ var testRoute = &Route{
IntegrationId: "CGEXJ922S7TXQ",
Position: 0,
RoutingRegex: "us-west",
RoutingType: "regex",
IsTheLastRoute: false,
SlackRoute: &SlackRoute{
ChannelId: &testSlackChannelId,
Enabled: true,
Enabled: true,
},
TelegramRoute: &TelegramRoute{
Id: &testTelegramChannelId,
Enabled: true,
Id: &testTelegramChannelId,
Enabled: true,
},
MSTeamsRoute: &MSTeamsRoute{
Id: &testMSTeamsChannelId,
Enabled: true,
Id: &testMSTeamsChannelId,
Enabled: true,
},
}

var testRouteBody = `{
"id": "RH2V5FYIPYJ1M",
"integration_id": "CGEXJ922S7TXQ",
"routing_regex": "us-west",
"routing_type": "regex",
"position": 0,
"is_the_last_route": false,
"slack": {
Expand Down Expand Up @@ -63,17 +65,18 @@ func TestCreateRoute(t *testing.T) {
createOptions := &CreateRouteOptions{
IntegrationId: "CGEXJ922S7TXQ",
RoutingRegex: "us-west",
RoutingType: "regex",
Slack: &SlackRoute{
ChannelId: &testSlackChannelId,
Enabled: true,
Enabled: true,
},
Telegram: &TelegramRoute{
Id: &testTelegramChannelId,
Enabled: true,
Id: &testTelegramChannelId,
Enabled: true,
},
MSTeams: &MSTeamsRoute{
Id: &testMSTeamsChannelId,
Enabled: true,
Id: &testMSTeamsChannelId,
Enabled: true,
},
}
route, _, err := client.Routes.CreateRoute(createOptions)
Expand Down

0 comments on commit 75ed784

Please sign in to comment.