unexport api response/message in cloudflare store

This commit is contained in:
Asim Aslam 2019-10-23 21:54:37 +01:00
parent 4e5a568063
commit ecac392dbe

View File

@ -80,7 +80,7 @@ func (w *workersKV) Sync() ([]*store.Record, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
a := &APIResponse{} a := &apiResponse{}
if err := json.Unmarshal(response, a); err != nil { if err := json.Unmarshal(response, a); err != nil {
return nil, err return nil, err
} }
@ -151,7 +151,7 @@ func (w *workersKV) Write(records ...*store.Record) error {
if err != nil { if err != nil {
return err return err
} }
a := &APIResponse{} a := &apiResponse{}
if err := json.Unmarshal(resp, a); err != nil { if err := json.Unmarshal(resp, a); err != nil {
return err return err
} }
@ -180,7 +180,7 @@ func (w *workersKV) Delete(keys ...string) error {
return err return err
} }
a := &APIResponse{} a := &apiResponse{}
if err := json.Unmarshal(resp, a); err != nil { if err := json.Unmarshal(resp, a); err != nil {
return err return err
} }
@ -237,8 +237,8 @@ func (w *workersKV) request(ctx context.Context, method, path string, body inter
return respBody, resp.Header, resp.StatusCode, nil return respBody, resp.Header, resp.StatusCode, nil
} }
// APIResponse is a cloudflare v4 api response // apiResponse is a cloudflare v4 api response
type APIResponse struct { type apiResponse struct {
Result []struct { Result []struct {
ID string `json:"id"` ID string `json:"id"`
Type string `json:"type"` Type string `json:"type"`
@ -256,9 +256,9 @@ type APIResponse struct {
CreatedOn time.Time `json:"created_on"` CreatedOn time.Time `json:"created_on"`
} `json:"result"` } `json:"result"`
Success bool `json:"success"` Success bool `json:"success"`
Errors []APIMessage `json:"errors"` Errors []apiMessage `json:"errors"`
// not sure Messages is ever populated? // not sure Messages is ever populated?
Messages []APIMessage `json:"messages"` Messages []apiMessage `json:"messages"`
ResultInfo struct { ResultInfo struct {
Page int `json:"page"` Page int `json:"page"`
PerPage int `json:"per_page"` PerPage int `json:"per_page"`
@ -267,8 +267,8 @@ type APIResponse struct {
} `json:"result_info"` } `json:"result_info"`
} }
// APIMessage is a Cloudflare v4 API Error // apiMessage is a Cloudflare v4 API Error
type APIMessage struct { type apiMessage struct {
Code int `json:"code"` Code int `json:"code"`
Message string `json:"message"` Message string `json:"message"`
} }