mirror of
https://github.com/Snawoot/opera-proxy.git
synced 2025-09-02 10:42:07 +00:00
50 lines
747 B
Go
50 lines
747 B
Go
package seclient
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"strconv"
|
|
)
|
|
|
|
const (
|
|
SE_STATUS_OK int64 = 0
|
|
)
|
|
|
|
type SEStatusPair struct {
|
|
Code int64
|
|
Message string
|
|
}
|
|
|
|
func (p *SEStatusPair) UnmarshalJSON(b []byte) error {
|
|
var tmp map[string]string
|
|
err := json.Unmarshal(b, &tmp)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if len(tmp) != 1 {
|
|
return errors.New("ambiguous status")
|
|
}
|
|
|
|
var strCode, strStatus string
|
|
for k, v := range tmp {
|
|
strCode = k
|
|
strStatus = v
|
|
}
|
|
|
|
code, err := strconv.ParseInt(strCode, 10, 64)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
*p = SEStatusPair{
|
|
Code: code,
|
|
Message: strStatus,
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type SERegisterSubscriberResponse struct {
|
|
Data interface{} `json:"data"`
|
|
Status SEStatusPair `json:"return_code"`
|
|
}
|