From 801b5207dcbf3438e7612e1f7edc9de32ce0780c Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Wed, 7 Feb 2018 19:33:36 +0100 Subject: switch from reflection to code generation This allows me to make the API much simpler. More simplification forthcoming in the following commit; I just want to make a cut since `make test` is happy right now. --- account.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'account.go') diff --git a/account.go b/account.go index f4e8c07..5586a16 100644 --- a/account.go +++ b/account.go @@ -96,8 +96,7 @@ func (a *Account) Headers() (AccountHeaders, error) { return AccountHeaders{}, err } - headers := NewAccountHeaders() - headers.FromHTTP(resp.Header) + headers := AccountHeaders(headersFromHTTP(resp.Header)) err = headers.Validate() if err != nil { return headers, err @@ -117,10 +116,9 @@ func (a *Account) Invalidate() { // //A successful POST request implies Invalidate() since it may change metadata. func (a *Account) Update(headers AccountHeaders, opts *RequestOptions) error { - ensureInitializedByReflection(headers) _, err := Request{ Method: "POST", - Headers: headers.ToHTTP(), + Headers: headersToHTTP(headers), Options: opts, ExpectStatusCodes: []int{204}, }.Do(a.client) @@ -138,10 +136,9 @@ func (a *Account) Update(headers AccountHeaders, opts *RequestOptions) error { // //A successful PUT request implies Invalidate() since it may change metadata. func (a *Account) Create(headers AccountHeaders, opts *RequestOptions) error { - ensureInitializedByReflection(headers) _, err := Request{ Method: "PUT", - Headers: headers.ToHTTP(), + Headers: headersToHTTP(headers), Options: opts, ExpectStatusCodes: []int{201, 202}, }.Do(a.client) -- cgit v1.2.3