forked from labd/commercetools-go-sdk
/
client_search_by_project_key_orders_search_head.go
71 lines (63 loc) · 1.32 KB
/
client_search_by_project_key_orders_search_head.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package platform
// Generated file, please do not change!!!
import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
"net/url"
)
type ByProjectKeyOrdersSearchRequestMethodHead struct {
url string
client *Client
headers http.Header
}
func (r *ByProjectKeyOrdersSearchRequestMethodHead) Dump() map[string]interface{} {
return map[string]interface{}{
"url": r.url,
}
}
func (rb *ByProjectKeyOrdersSearchRequestMethodHead) WithHeaders(headers http.Header) *ByProjectKeyOrdersSearchRequestMethodHead {
rb.headers = headers
return rb
}
/**
* Checks whether a search index for the Project's Orders exists.
*/
func (rb *ByProjectKeyOrdersSearchRequestMethodHead) Execute(ctx context.Context) error {
queryParams := url.Values{}
resp, err := rb.client.head(
ctx,
rb.url,
queryParams,
rb.headers,
)
if err != nil {
return err
}
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
defer resp.Body.Close()
switch resp.StatusCode {
case 200:
return nil
case 404:
return ErrNotFound
case 400, 401, 403, 500, 502, 503:
errorObj := ErrorResponse{}
err = json.Unmarshal(content, &errorObj)
if err != nil {
return err
}
return errorObj
default:
result := GenericRequestError{
StatusCode: resp.StatusCode,
Content: content,
Response: resp,
}
return result
}
}