Skip to content

Commit

Permalink
Update SDK to latest stone spec (#57)
Browse files Browse the repository at this point in the history
* full patch with tests:

* simplified

* fix fmt_type to get things compiling

* drop missing import

* simpler union decoding

* update sdk version

* update api spec to latest version (#2)

* force SDK version update

* fix basd commit in types
  • Loading branch information
aaronstaley authored and karandeep-johar committed Nov 13, 2019
1 parent 302f2cc commit 3eae5e5
Show file tree
Hide file tree
Showing 12 changed files with 3,778 additions and 759 deletions.
39 changes: 39 additions & 0 deletions dropbox/auth/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (u *AccessError) UnmarshalJSON(body []byte) error {
// AuthError : Errors occurred during authentication.
type AuthError struct {
dropbox.Tagged
// MissingScope : The access token does not have the required scope to
// access the route.
MissingScope *TokenScopeError `json:"missing_scope,omitempty"`
}

// Valid tag values for AuthError
Expand All @@ -88,9 +91,32 @@ const (
AuthErrorInvalidSelectAdmin = "invalid_select_admin"
AuthErrorUserSuspended = "user_suspended"
AuthErrorExpiredAccessToken = "expired_access_token"
AuthErrorMissingScope = "missing_scope"
AuthErrorOther = "other"
)

// UnmarshalJSON deserializes into a AuthError instance
func (u *AuthError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "missing_scope":
err = json.Unmarshal(body, &u.MissingScope)

if err != nil {
return err
}
}
return nil
}

// InvalidAccountTypeError : has no documentation (yet)
type InvalidAccountTypeError struct {
dropbox.Tagged
Expand Down Expand Up @@ -186,3 +212,16 @@ func NewTokenFromOAuth1Result(Oauth2Token string) *TokenFromOAuth1Result {
s.Oauth2Token = Oauth2Token
return s
}

// TokenScopeError : has no documentation (yet)
type TokenScopeError struct {
// RequiredScope : The required scope to access the route.
RequiredScope string `json:"required_scope"`
}

// NewTokenScopeError returns a new TokenScopeError instance
func NewTokenScopeError(RequiredScope string) *TokenScopeError {
s := new(TokenScopeError)
s.RequiredScope = RequiredScope
return s
}
Loading

0 comments on commit 3eae5e5

Please sign in to comment.