(url string, method string, callback base.ReqCallback, resp interface{})
| 119 | } |
| 120 | |
| 121 | func (d *Onedrive) Request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) { |
| 122 | req := base.RestyClient.R() |
| 123 | req.SetHeader("Authorization", "Bearer "+d.AccessToken) |
| 124 | if callback != nil { |
| 125 | callback(req) |
| 126 | } |
| 127 | if resp != nil { |
| 128 | req.SetResult(resp) |
| 129 | } |
| 130 | var e RespErr |
| 131 | req.SetError(&e) |
| 132 | res, err := req.Execute(method, url) |
| 133 | if err != nil { |
| 134 | return nil, err |
| 135 | } |
| 136 | if e.Error.Code != "" { |
| 137 | if e.Error.Code == "InvalidAuthenticationToken" { |
| 138 | err = d.refreshToken() |
| 139 | if err != nil { |
| 140 | return nil, err |
| 141 | } |
| 142 | return d.Request(url, method, callback, resp) |
| 143 | } |
| 144 | return nil, errors.New(e.Error.Message) |
| 145 | } |
| 146 | return res.Body(), nil |
| 147 | } |
| 148 | |
| 149 | func GetConfig() Onedrive { |
| 150 | config := Onedrive{} |
no test coverage detected