first commit
This commit is contained in:
63
client/response.go
Normal file
63
client/response.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type PagerGroup struct {
|
||||
ID string `json:"_id"`
|
||||
SubscriberID int `json:"subscriberId"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
ToneTolerance float64 `json:"tone_tolerance"`
|
||||
GapLength int `json:"gaplength"`
|
||||
IgnoreAfter int `json:"ignore_after"`
|
||||
RecordDelay int `json:"record_delay"`
|
||||
RecordSeconds int `json:"record_seconds"`
|
||||
ReleaseTime int `json:"release_time"`
|
||||
PlaybackDuringRecord int `json:"playback_during_record"`
|
||||
PostEmailCommand string `json:"post_email_command"`
|
||||
AlertCommand string `json:"alert_command"`
|
||||
ATone float64 `json:"atone"`
|
||||
BTone float64 `json:"btone"`
|
||||
AToneLength float64 `json:"atonelength"`
|
||||
BToneLength float64 `json:"btonelength"`
|
||||
LongTone *float64 `json:"longtone"`
|
||||
LongToneLength *float64 `json:"longtonelength"`
|
||||
CreateDate string `json:"createDate"`
|
||||
}
|
||||
|
||||
type TTDSetting struct {
|
||||
KeySetting string `json:"keySetting"`
|
||||
KeyValue string `json:"keyValue"`
|
||||
}
|
||||
|
||||
type AddAlert struct {
|
||||
ID string `json:"_id"`
|
||||
TextAlert string `json:"textAlert"`
|
||||
PagerGroup string `json:"pagerGroup"`
|
||||
AudioUrl *string `json:"audioUrl,omitempty"`
|
||||
SubscriberID int `json:"subscriberId"`
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
GetMutualPagerGroupsList []PagerGroup `json:"getMutualPagerGroupsList,omitempty"`
|
||||
GetTTDSetting TTDSetting `json:"getTTDSetting,omitempty"`
|
||||
AddAlert AddAlert `json:"addAlert,omitempty"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Data Data `json:"data"`
|
||||
}
|
||||
|
||||
func (r *Response) Unmarshal(data []byte) (*Response, error) {
|
||||
if data == nil {
|
||||
return nil, errors.New("response data is nil")
|
||||
}
|
||||
var resp Response
|
||||
if err := json.Unmarshal(data, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
Reference in New Issue
Block a user