aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2018-02-07 19:33:36 +0100
committerStefan Majewsky <majewsky@gmx.net>2018-02-07 19:33:36 +0100
commit801b5207dcbf3438e7612e1f7edc9de32ce0780c (patch)
tree6f0454ec49bf769e361cfa393290efc68583ca67 /account.go
parent8bddda344201d9f034b5e9c2e9c37a25caeb80cb (diff)
downloadgo-schwift-801b5207dcbf3438e7612e1f7edc9de32ce0780c.tar.gz
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.
Diffstat (limited to 'account.go')
-rw-r--r--account.go9
1 files changed, 3 insertions, 6 deletions
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)