Rename authorize to authorize-session (#531)

As pointed out by Rob, this makes it clearer what the action actually
is. We were sort of torn on it before, but I've definitely come around
to it.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-10-05 11:02:23 -04:00
1 parent 0f7444a690
commit 9237d6f787
13 files changed
+52 -52

No files matched your search

+6 -6
View File
@@ -25,9 +25,9 @@ func (n SessionAuthorizationResult) GetResponseMap() map[string]interface{} {
return n.responseMap
}
func (c *Client) Authorize(ctx context.Context, targetId string, opt ...Option) (*SessionAuthorizationResult, error) {
func (c *Client) AuthorizeSession(ctx context.Context, targetId string, opt ...Option) (*SessionAuthorizationResult, error) {
if targetId == "" {
return nil, fmt.Errorf("empty targetId value passed into Authorize request")
return nil, fmt.Errorf("empty targetId value passed into AuthorizeSession request")
}
opts, apiOpts := getOpts(opt...)
@@ -36,9 +36,9 @@ func (c *Client) Authorize(ctx context.Context, targetId string, opt ...Option)
return nil, fmt.Errorf("nil client")
}
req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("targets/%s:authorize", targetId), opts.postMap, apiOpts...)
req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("targets/%s:authorize-session", targetId), opts.postMap, apiOpts...)
if err != nil {
return nil, fmt.Errorf("error creating Authorize request: %w", err)
return nil, fmt.Errorf("error creating AuthorizeSession request: %w", err)
}
if len(opts.queryMap) > 0 {
@@ -51,14 +51,14 @@ func (c *Client) Authorize(ctx context.Context, targetId string, opt ...Option)
resp, err := c.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error performing client request during Authorize call: %w", err)
return nil, fmt.Errorf("error performing client request during AuthorizeSession call: %w", err)
}
sar := new(SessionAuthorizationResult)
sar.Item = new(SessionAuthorization)
apiErr, err := resp.Decode(sar.Item)
if err != nil {
return nil, fmt.Errorf("error decoding Authorize response: %w", err)
return nil, fmt.Errorf("error decoding AuthorizeSession response: %w", err)
}
if apiErr != nil {
return nil, apiErr