Skip to content

Commit 5ea6cfa

Browse files
author
Diwaker Gupta
committed
Update API spec to eb70e69.
1 parent 8b48024 commit 5ea6cfa

File tree

8 files changed

+444
-20
lines changed

8 files changed

+444
-20
lines changed

dropbox/contacts/client.go

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
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 contacts
22+
23+
import (
24+
"bytes"
25+
"encoding/json"
26+
"io/ioutil"
27+
"net/http"
28+
29+
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
30+
)
31+
32+
// Client interface describes all routes in this namespace
33+
type Client interface {
34+
// DeleteManualContacts : Removes all manually added contacts. You'll still
35+
// keep contacts who are on your team or who you imported. New contacts will
36+
// be added when you share.
37+
DeleteManualContacts() (err error)
38+
// DeleteManualContactsBatch : Removes manually added contacts from the
39+
// given list.
40+
DeleteManualContactsBatch(arg *DeleteManualContactsArg) (err error)
41+
}
42+
43+
type apiImpl dropbox.Context
44+
45+
//DeleteManualContactsAPIError is an error-wrapper for the delete_manual_contacts route
46+
type DeleteManualContactsAPIError struct {
47+
dropbox.APIError
48+
EndpointError struct{} `json:"error"`
49+
}
50+
51+
func (dbx *apiImpl) DeleteManualContacts() (err error) {
52+
cli := dbx.Client
53+
54+
headers := map[string]string{}
55+
if dbx.Config.AsMemberID != "" {
56+
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
57+
}
58+
59+
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "contacts", "delete_manual_contacts", headers, nil)
60+
if err != nil {
61+
return
62+
}
63+
dbx.Config.LogInfo("req: %v", req)
64+
65+
resp, err := cli.Do(req)
66+
if err != nil {
67+
return
68+
}
69+
70+
dbx.Config.LogInfo("resp: %v", resp)
71+
defer resp.Body.Close()
72+
body, err := ioutil.ReadAll(resp.Body)
73+
if err != nil {
74+
return
75+
}
76+
77+
dbx.Config.LogDebug("body: %v", body)
78+
if resp.StatusCode == http.StatusOK {
79+
return
80+
}
81+
if resp.StatusCode == http.StatusConflict {
82+
var apiError DeleteManualContactsAPIError
83+
err = json.Unmarshal(body, &apiError)
84+
if err != nil {
85+
return
86+
}
87+
err = apiError
88+
return
89+
}
90+
err = dropbox.HandleCommonAPIErrors(resp, body)
91+
return
92+
}
93+
94+
//DeleteManualContactsBatchAPIError is an error-wrapper for the delete_manual_contacts_batch route
95+
type DeleteManualContactsBatchAPIError struct {
96+
dropbox.APIError
97+
EndpointError *DeleteManualContactsError `json:"error"`
98+
}
99+
100+
func (dbx *apiImpl) DeleteManualContactsBatch(arg *DeleteManualContactsArg) (err error) {
101+
cli := dbx.Client
102+
103+
dbx.Config.LogDebug("arg: %v", arg)
104+
b, err := json.Marshal(arg)
105+
if err != nil {
106+
return
107+
}
108+
109+
headers := map[string]string{
110+
"Content-Type": "application/json",
111+
}
112+
if dbx.Config.AsMemberID != "" {
113+
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
114+
}
115+
116+
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "contacts", "delete_manual_contacts_batch", headers, bytes.NewReader(b))
117+
if err != nil {
118+
return
119+
}
120+
dbx.Config.LogInfo("req: %v", req)
121+
122+
resp, err := cli.Do(req)
123+
if err != nil {
124+
return
125+
}
126+
127+
dbx.Config.LogInfo("resp: %v", resp)
128+
defer resp.Body.Close()
129+
body, err := ioutil.ReadAll(resp.Body)
130+
if err != nil {
131+
return
132+
}
133+
134+
dbx.Config.LogDebug("body: %v", body)
135+
if resp.StatusCode == http.StatusOK {
136+
return
137+
}
138+
if resp.StatusCode == http.StatusConflict {
139+
var apiError DeleteManualContactsBatchAPIError
140+
err = json.Unmarshal(body, &apiError)
141+
if err != nil {
142+
return
143+
}
144+
err = apiError
145+
return
146+
}
147+
err = dropbox.HandleCommonAPIErrors(resp, body)
148+
return
149+
}
150+
151+
// New returns a Client implementation for this namespace
152+
func New(c dropbox.Config) Client {
153+
ctx := apiImpl(dropbox.NewContext(c))
154+
return &ctx
155+
}

dropbox/contacts/types.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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 contacts : has no documentation (yet)
22+
package contacts
23+
24+
import (
25+
"encoding/json"
26+
27+
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
28+
)
29+
30+
// DeleteManualContactsArg : has no documentation (yet)
31+
type DeleteManualContactsArg struct {
32+
// EmailAddresses : List of manually added contacts to be deleted.
33+
EmailAddresses []string `json:"email_addresses"`
34+
}
35+
36+
// NewDeleteManualContactsArg returns a new DeleteManualContactsArg instance
37+
func NewDeleteManualContactsArg(EmailAddresses []string) *DeleteManualContactsArg {
38+
s := new(DeleteManualContactsArg)
39+
s.EmailAddresses = EmailAddresses
40+
return s
41+
}
42+
43+
// DeleteManualContactsError : has no documentation (yet)
44+
type DeleteManualContactsError struct {
45+
dropbox.Tagged
46+
// ContactsNotFound : Can't delete contacts from this list. Make sure the
47+
// list only has manually added contacts. The deletion was cancelled.
48+
ContactsNotFound []string `json:"contacts_not_found,omitempty"`
49+
}
50+
51+
// Valid tag values for DeleteManualContactsError
52+
const (
53+
DeleteManualContactsErrorContactsNotFound = "contacts_not_found"
54+
DeleteManualContactsErrorOther = "other"
55+
)
56+
57+
// UnmarshalJSON deserializes into a DeleteManualContactsError instance
58+
func (u *DeleteManualContactsError) UnmarshalJSON(body []byte) error {
59+
type wrap struct {
60+
dropbox.Tagged
61+
// ContactsNotFound : Can't delete contacts from this list. Make sure
62+
// the list only has manually added contacts. The deletion was
63+
// cancelled.
64+
ContactsNotFound json.RawMessage `json:"contacts_not_found,omitempty"`
65+
}
66+
var w wrap
67+
var err error
68+
if err = json.Unmarshal(body, &w); err != nil {
69+
return err
70+
}
71+
u.Tag = w.Tag
72+
switch u.Tag {
73+
case "contacts_not_found":
74+
err = json.Unmarshal(body, &u.ContactsNotFound)
75+
76+
if err != nil {
77+
return err
78+
}
79+
}
80+
return nil
81+
}

dropbox/sdk.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const (
3737
hostAPI = "api"
3838
hostContent = "content"
3939
hostNotify = "notify"
40-
sdkVersion = "5.0.0"
41-
specVersion = "eb85489"
40+
sdkVersion = "5.1.0"
41+
specVersion = "eb70e69"
4242
)
4343

4444
// Version returns the current SDK version and API Spec version

dropbox/sharing/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,6 +1757,7 @@ type LinkAudience struct {
17571757
const (
17581758
LinkAudiencePublic = "public"
17591759
LinkAudienceTeam = "team"
1760+
LinkAudienceNoOne = "no_one"
17601761
LinkAudienceMembers = "members"
17611762
LinkAudienceOther = "other"
17621763
)

dropbox/team/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2978,7 +2978,7 @@ func (dbx *apiImpl) MembersUnsuspend(arg *MembersUnsuspendArg) (err error) {
29782978
//NamespacesListAPIError is an error-wrapper for the namespaces/list route
29792979
type NamespacesListAPIError struct {
29802980
dropbox.APIError
2981-
EndpointError struct{} `json:"error"`
2981+
EndpointError *TeamNamespacesListError `json:"error"`
29822982
}
29832983

29842984
func (dbx *apiImpl) NamespacesList(arg *TeamNamespacesListArg) (res *TeamNamespacesListResult, err error) {

dropbox/team/types.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,12 +2927,16 @@ func (u *RemoveCustomQuotaResult) UnmarshalJSON(body []byte) error {
29272927
type RemovedStatus struct {
29282928
// IsRecoverable : True if the removed team member is recoverable.
29292929
IsRecoverable bool `json:"is_recoverable"`
2930+
// IsDisconnected : True if the team member's account was converted to
2931+
// individual account.
2932+
IsDisconnected bool `json:"is_disconnected"`
29302933
}
29312934

29322935
// NewRemovedStatus returns a new RemovedStatus instance
2933-
func NewRemovedStatus(IsRecoverable bool) *RemovedStatus {
2936+
func NewRemovedStatus(IsRecoverable bool, IsDisconnected bool) *RemovedStatus {
29342937
s := new(RemovedStatus)
29352938
s.IsRecoverable = IsRecoverable
2939+
s.IsDisconnected = IsDisconnected
29362940
return s
29372941
}
29382942

@@ -4081,15 +4085,27 @@ func NewTeamNamespacesListContinueArg(Cursor string) *TeamNamespacesListContinue
40814085
return s
40824086
}
40834087

4088+
// TeamNamespacesListError : has no documentation (yet)
4089+
type TeamNamespacesListError struct {
4090+
dropbox.Tagged
4091+
}
4092+
4093+
// Valid tag values for TeamNamespacesListError
4094+
const (
4095+
TeamNamespacesListErrorInvalidArg = "invalid_arg"
4096+
TeamNamespacesListErrorOther = "other"
4097+
)
4098+
40844099
// TeamNamespacesListContinueError : has no documentation (yet)
40854100
type TeamNamespacesListContinueError struct {
40864101
dropbox.Tagged
40874102
}
40884103

40894104
// Valid tag values for TeamNamespacesListContinueError
40904105
const (
4091-
TeamNamespacesListContinueErrorInvalidCursor = "invalid_cursor"
4106+
TeamNamespacesListContinueErrorInvalidArg = "invalid_arg"
40924107
TeamNamespacesListContinueErrorOther = "other"
4108+
TeamNamespacesListContinueErrorInvalidCursor = "invalid_cursor"
40934109
)
40944110

40954111
// TeamNamespacesListResult : Result for `namespacesList`.

0 commit comments

Comments
 (0)