Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent data type issue for port, sub_type and KeywordType #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/exileed/uptimerobotapi
module github.com/bigdatasourav/uptimerobotapi

go 1.15

Expand Down
11 changes: 7 additions & 4 deletions m_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type GetMWindowParams struct {
Value string `url:"value"`
StartTime string `url:"start_time"`
Duration string `url:"duration"`
Offset int `url:"offset,omitempty"`
Limit *int `url:"limit,omitempty"`
}

type NewMWindowParams struct {
Expand Down Expand Up @@ -68,10 +70,11 @@ type MWindow struct {
User int `json:"user"`
Type int `json:"type"`
FriendlyName string `json:"friendly_name"`
StartTime int `json:"start_time"`
Duration int `json:"duration"`
Value string `json:"value"`
Status int `json:"status"`
// StartTime comes from API as a string value with a format like “18:20.”
StartTime string `json:"start_time"`
Duration int `json:"duration"`
Value string `json:"value"`
Status int `json:"status"`
}

// GetMWindows Get https://uptimerobot.com/#getMWindows
Expand Down
2 changes: 1 addition & 1 deletion m_window_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestGetMWindows(t *testing.T) {

require.NoError(t, err)

mwindows := []MWindow{{Id: 111, User: 1, Type: 1, FriendlyName: "Once Backup", StartTime: 1461024000, Duration: 12, Value: "", Status: 1}}
mwindows := []MWindow{{Id: 111, User: 1, Type: 1, FriendlyName: "Once Backup", StartTime: "18:20", Duration: 12, Value: "", Status: 1}}

want := &MWindowsResp{Stat: StatOk, Pagination: Pagination{Total: 1, Limit: 10, Offset: 0}, MWindows: mwindows}

Expand Down
16 changes: 9 additions & 7 deletions monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ type AlertContactMonitor struct {
}

type Monitor struct {
Id int `json:"id"`
FriendlyName string `json:"friendly_name"`
Url string `json:"url"`
Type int `json:"type"`
SubType string `json:"sub_type"`
Port string `json:"port"`
KeywordType *int `json:"keyword_type"`
Id int `json:"id"`
FriendlyName string `json:"friendly_name"`
Url string `json:"url"`
Type int `json:"type"`
// sub_type, port and keyword_type are returned as either an integer or an empty string,
// which Go doesn't allow: https://github.com/golang/go/issues/22182
SubType interface{} `json:"sub_type"`
Port interface{} `json:"port"`
KeywordType interface{} `json:"keyword_type"`
KeywordCaseType *int `json:"keyword_case_type"`
KeywordValue string `json:"keyword_value"`
HttpUsername string `json:"http_username"`
Expand Down