Skip to content

Commit caca4b4

Browse files
author
Rajat Goel
committed
Add v6 version suffix
1 parent a1e66a2 commit caca4b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+64554
-74
lines changed

generator/generate-sdk.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
#! /usr/bin/env bash
22
set -euo pipefail
33

4-
if [[ $# -gt 1 ]]; then
4+
if [[ $# -ne 1 ]]; then
55
echo "$0: Not expecting more than one command-line argument, got $#." 1>&2
66
exit 1
77
fi
88

9+
version=$(echo $1 | cut -f1 -d'.')
910
loc=$(realpath -e $0)
1011
base_dir=$(dirname "$loc")
1112
spec_dir="$base_dir/dropbox-api-spec"
12-
gen_dir=$(dirname ${base_dir})/dropbox
13+
gen_dir=$(dirname ${base_dir})/v$version/dropbox
1314

1415
stone -v -a :all go_types.stoneg.py "$gen_dir" "$spec_dir"/*.stone
1516
stone -v -a :all go_client.stoneg.py "$gen_dir" "$spec_dir"/*.stone
1617

1718
# Update SDK and API spec versions
18-
sdk_version=${1:-"5.0.0"}
19+
sdk_version=${1}
1920
pushd ${spec_dir}
2021
spec_version=$(git rev-parse --short HEAD)
2122
popd
2223

2324
sed -i.bak -e "s/UNKNOWN SDK VERSION/${sdk_version}/" \
2425
-e "s/UNKNOWN SPEC VERSION/${spec_version}/" ${gen_dir}/sdk.go
2526
rm ${gen_dir}/sdk.go.bak
27+
pushd ${gen_dir}
2628
goimports -l -w ${gen_dir}
29+
popd

v6/dropbox/account/client.go

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// Copyright (c) Dropbox, Inc.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
package account
22+
23+
import (
24+
"bytes"
25+
"encoding/json"
26+
"io/ioutil"
27+
"net/http"
28+
29+
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
30+
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/auth"
31+
)
32+
33+
// Client interface describes all routes in this namespace
34+
type Client interface {
35+
// SetProfilePhoto : Sets a user's profile photo.
36+
SetProfilePhoto(arg *SetProfilePhotoArg) (res *SetProfilePhotoResult, err error)
37+
}
38+
39+
type apiImpl dropbox.Context
40+
41+
//SetProfilePhotoAPIError is an error-wrapper for the set_profile_photo route
42+
type SetProfilePhotoAPIError struct {
43+
dropbox.APIError
44+
EndpointError *SetProfilePhotoError `json:"error"`
45+
}
46+
47+
func (dbx *apiImpl) SetProfilePhoto(arg *SetProfilePhotoArg) (res *SetProfilePhotoResult, err error) {
48+
cli := dbx.Client
49+
50+
dbx.Config.LogDebug("arg: %v", arg)
51+
b, err := json.Marshal(arg)
52+
if err != nil {
53+
return
54+
}
55+
56+
headers := map[string]string{
57+
"Content-Type": "application/json",
58+
}
59+
if dbx.Config.AsMemberID != "" {
60+
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
61+
}
62+
63+
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "account", "set_profile_photo", headers, bytes.NewReader(b))
64+
if err != nil {
65+
return
66+
}
67+
dbx.Config.LogInfo("req: %v", req)
68+
69+
resp, err := cli.Do(req)
70+
if err != nil {
71+
return
72+
}
73+
74+
dbx.Config.LogInfo("resp: %v", resp)
75+
defer resp.Body.Close()
76+
body, err := ioutil.ReadAll(resp.Body)
77+
if err != nil {
78+
return
79+
}
80+
81+
dbx.Config.LogDebug("body: %s", body)
82+
if resp.StatusCode == http.StatusOK {
83+
err = json.Unmarshal(body, &res)
84+
if err != nil {
85+
return
86+
}
87+
88+
return
89+
}
90+
if resp.StatusCode == http.StatusConflict {
91+
var apiError SetProfilePhotoAPIError
92+
err = json.Unmarshal(body, &apiError)
93+
if err != nil {
94+
return
95+
}
96+
err = apiError
97+
return
98+
}
99+
err = auth.HandleCommonAuthErrors(dbx.Config, resp, body)
100+
if err != nil {
101+
return
102+
}
103+
err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body)
104+
return
105+
}
106+
107+
// New returns a Client implementation for this namespace
108+
func New(c dropbox.Config) Client {
109+
ctx := apiImpl(dropbox.NewContext(c))
110+
return &ctx
111+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import (
2626
"io/ioutil"
2727
"net/http"
2828

29-
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
30-
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth"
29+
"github.com/dropbox/dropbox-sdk-go-unofficial/v6dropbox"
30+
"github.com/dropbox/dropbox-sdk-go-unofficial/v6dropbox/auth"
3131
)
3232

3333
// Client interface describes all routes in this namespace

v6/dropbox/account/types.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Copyright (c) Dropbox, Inc.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
// Package account : has no documentation (yet)
22+
package account
23+
24+
import (
25+
"encoding/json"
26+
27+
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
28+
)
29+
30+
// PhotoSourceArg : has no documentation (yet)
31+
type PhotoSourceArg struct {
32+
dropbox.Tagged
33+
// Base64Data : Image data in base64-encoded bytes.
34+
Base64Data string `json:"base64_data,omitempty"`
35+
}
36+
37+
// Valid tag values for PhotoSourceArg
38+
const (
39+
PhotoSourceArgBase64Data = "base64_data"
40+
PhotoSourceArgOther = "other"
41+
)
42+
43+
// UnmarshalJSON deserializes into a PhotoSourceArg instance
44+
func (u *PhotoSourceArg) UnmarshalJSON(body []byte) error {
45+
type wrap struct {
46+
dropbox.Tagged
47+
// Base64Data : Image data in base64-encoded bytes.
48+
Base64Data string `json:"base64_data,omitempty"`
49+
}
50+
var w wrap
51+
var err error
52+
if err = json.Unmarshal(body, &w); err != nil {
53+
return err
54+
}
55+
u.Tag = w.Tag
56+
switch u.Tag {
57+
case "base64_data":
58+
u.Base64Data = w.Base64Data
59+
60+
if err != nil {
61+
return err
62+
}
63+
}
64+
return nil
65+
}
66+
67+
// SetProfilePhotoArg : has no documentation (yet)
68+
type SetProfilePhotoArg struct {
69+
// Photo : Image to set as the user's new profile photo.
70+
Photo *PhotoSourceArg `json:"photo"`
71+
}
72+
73+
// NewSetProfilePhotoArg returns a new SetProfilePhotoArg instance
74+
func NewSetProfilePhotoArg(Photo *PhotoSourceArg) *SetProfilePhotoArg {
75+
s := new(SetProfilePhotoArg)
76+
s.Photo = Photo
77+
return s
78+
}
79+
80+
// SetProfilePhotoError : has no documentation (yet)
81+
type SetProfilePhotoError struct {
82+
dropbox.Tagged
83+
}
84+
85+
// Valid tag values for SetProfilePhotoError
86+
const (
87+
SetProfilePhotoErrorFileTypeError = "file_type_error"
88+
SetProfilePhotoErrorFileSizeError = "file_size_error"
89+
SetProfilePhotoErrorDimensionError = "dimension_error"
90+
SetProfilePhotoErrorThumbnailError = "thumbnail_error"
91+
SetProfilePhotoErrorTransientError = "transient_error"
92+
SetProfilePhotoErrorOther = "other"
93+
)
94+
95+
// SetProfilePhotoResult : has no documentation (yet)
96+
type SetProfilePhotoResult struct {
97+
// ProfilePhotoUrl : URL for the photo representing the user, if one is set.
98+
ProfilePhotoUrl string `json:"profile_photo_url"`
99+
}
100+
101+
// NewSetProfilePhotoResult returns a new SetProfilePhotoResult instance
102+
func NewSetProfilePhotoResult(ProfilePhotoUrl string) *SetProfilePhotoResult {
103+
s := new(SetProfilePhotoResult)
104+
s.ProfilePhotoUrl = ProfilePhotoUrl
105+
return s
106+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ package account
2424
import (
2525
"encoding/json"
2626

27-
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
27+
"github.com/dropbox/dropbox-sdk-go-unofficial/v6dropbox"
2828
)
2929

3030
// PhotoSourceArg : has no documentation (yet)

0 commit comments

Comments
 (0)