-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added notification rules,fix: fields in integrations
Added error message for API call Added contact method and notification rules module
- Loading branch information
Showing
9 changed files
with
189 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
type ContactMethodService service | ||
|
||
type ContactMethod struct { | ||
UniqueID string `json:"unique_id"` | ||
Name string `json:"name"` | ||
ContactType int `json:"contact_type"` | ||
Value string `json:"value"` | ||
CreationDate string `json:"creation_date"` | ||
} | ||
|
||
func (c *ContactMethodService) GetContactMethods(username string) ([]ContactMethod, error) { | ||
path := fmt.Sprintf("/api/account/users/%s/contacts/", username) | ||
body, err := c.client.newRequestDo("GET", path, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s []ContactMethod | ||
err = json.Unmarshal(body.BodyBytes, &s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return s, nil | ||
} | ||
|
||
func (c *ContactMethodService) GetContactMethodByID(username string, contactMethodID string) (*ContactMethod, error) { | ||
path := fmt.Sprintf("/api/account/users/%s/contacts/%s/", username, contactMethodID) | ||
body, err := c.client.newRequestDo("GET", path, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s1 ContactMethod | ||
err = json.Unmarshal(body.BodyBytes, &s1) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &s1, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
type NotificationRulesService service | ||
|
||
type NotificationRules struct { | ||
UniqueID string `json:"unique_id"` | ||
StartDelay int `json:"start_delay"` | ||
Type string `json:"type"` | ||
Contact string `json:"contact"` | ||
Urgency int `json:"urgency"` | ||
} | ||
|
||
type CreateNotificationRules struct { | ||
Contact string `json:"contact"` | ||
StartDelay int `json:"start_delay"` | ||
Urgency int `json:"urgency"` | ||
} | ||
|
||
func (c *NotificationRulesService) CreateNotificationRules(username string, notificationRule *CreateNotificationRules) (*NotificationRules, error) { | ||
path := fmt.Sprintf("/api/account/users/%s/notification_rules/", username) | ||
body, err := c.client.newRequestDo("POST", path, notificationRule) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s NotificationRules | ||
err = json.Unmarshal(body.BodyBytes, &s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &s, nil | ||
} | ||
|
||
func (c *NotificationRulesService) GetNotificationRules(username string) ([]NotificationRules, error) { | ||
path := fmt.Sprintf("/api/account/users/%s/notification_rules/", username) | ||
body, err := c.client.newRequestDo("GET", path, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s []NotificationRules | ||
err = json.Unmarshal(body.BodyBytes, &s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return s, nil | ||
} | ||
|
||
func (c *NotificationRulesService) GetNotificationRulesByID(username, notificationRuleID string) (*NotificationRules, error) { | ||
path := fmt.Sprintf("/api/account/users/%s/notification_rules/%s/", username, notificationRuleID) | ||
body, err := c.client.newRequestDo("GET", path, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s NotificationRules | ||
err = json.Unmarshal(body.BodyBytes, &s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &s, nil | ||
} | ||
|
||
func (c *NotificationRulesService) DeleteNotificationRules(username string, notificationRuleID string) error { | ||
path := fmt.Sprintf("/api/account/users/%s/notification_rules/%s/", username, notificationRuleID) | ||
_, err := c.client.newRequestDo("DELETE", path, nil) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (c *NotificationRulesService) UpdateNotificationRules(username string, notificationRuleID string, notificationRule *NotificationRules) (*NotificationRules, error) { | ||
path := fmt.Sprintf("/api/account/users/%s/notification_rules/%s/", username, notificationRuleID) | ||
body, err := c.client.newRequestDo("PUT", path, notificationRule) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var s NotificationRules | ||
err = json.Unmarshal(body.BodyBytes, &s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &s, nil | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters