Skip to content

Commit 115c6b8

Browse files
author
Diwaker Gupta
committed
Fix #32: handling of inherited unions
Also update API spec.
1 parent 91af748 commit 115c6b8

File tree

11 files changed

+805
-82
lines changed

11 files changed

+805
-82
lines changed

dropbox/async/types.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,40 @@ func (u *LaunchResultBase) UnmarshalJSON(body []byte) error {
7272
// the job, no additional information is returned.
7373
type LaunchEmptyResult struct {
7474
dropbox.Tagged
75+
// AsyncJobId : This response indicates that the processing is asynchronous.
76+
// The string is an id that can be used to obtain the status of the
77+
// asynchronous job.
78+
AsyncJobId string `json:"async_job_id,omitempty"`
7579
}
7680

7781
// Valid tag values for LaunchEmptyResult
7882
const (
79-
LaunchEmptyResultComplete = "complete"
83+
LaunchEmptyResultAsyncJobId = "async_job_id"
84+
LaunchEmptyResultComplete = "complete"
8085
)
8186

87+
// UnmarshalJSON deserializes into a LaunchEmptyResult instance
88+
func (u *LaunchEmptyResult) UnmarshalJSON(body []byte) error {
89+
type wrap struct {
90+
dropbox.Tagged
91+
}
92+
var w wrap
93+
var err error
94+
if err = json.Unmarshal(body, &w); err != nil {
95+
return err
96+
}
97+
u.Tag = w.Tag
98+
switch u.Tag {
99+
case "async_job_id":
100+
err = json.Unmarshal(body, &u.AsyncJobId)
101+
102+
if err != nil {
103+
return err
104+
}
105+
}
106+
return nil
107+
}
108+
82109
// PollArg : Arguments for methods that poll the status of an asynchronous job.
83110
type PollArg struct {
84111
// AsyncJobId : Id of the asynchronous job. This is the value of a response
@@ -115,7 +142,8 @@ type PollEmptyResult struct {
115142

116143
// Valid tag values for PollEmptyResult
117144
const (
118-
PollEmptyResultComplete = "complete"
145+
PollEmptyResultInProgress = "in_progress"
146+
PollEmptyResultComplete = "complete"
119147
)
120148

121149
// PollError : Error returned by methods for polling the status of asynchronous

dropbox/file_properties/types.go

Lines changed: 167 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,17 @@ func (u *TemplateError) UnmarshalJSON(body []byte) error {
9595
// PropertiesError : has no documentation (yet)
9696
type PropertiesError struct {
9797
dropbox.Tagged
98+
// TemplateNotFound : Template does not exist for the given identifier.
99+
TemplateNotFound string `json:"template_not_found,omitempty"`
98100
// Path : has no documentation (yet)
99101
Path *LookupError `json:"path,omitempty"`
100102
}
101103

102104
// Valid tag values for PropertiesError
103105
const (
106+
PropertiesErrorTemplateNotFound = "template_not_found"
107+
PropertiesErrorRestrictedContent = "restricted_content"
108+
PropertiesErrorOther = "other"
104109
PropertiesErrorPath = "path"
105110
PropertiesErrorUnsupportedFolder = "unsupported_folder"
106111
)
@@ -119,6 +124,12 @@ func (u *PropertiesError) UnmarshalJSON(body []byte) error {
119124
}
120125
u.Tag = w.Tag
121126
switch u.Tag {
127+
case "template_not_found":
128+
err = json.Unmarshal(body, &u.TemplateNotFound)
129+
130+
if err != nil {
131+
return err
132+
}
122133
case "path":
123134
err = json.Unmarshal(w.Path, &u.Path)
124135

@@ -132,24 +143,104 @@ func (u *PropertiesError) UnmarshalJSON(body []byte) error {
132143
// InvalidPropertyGroupError : has no documentation (yet)
133144
type InvalidPropertyGroupError struct {
134145
dropbox.Tagged
146+
// TemplateNotFound : Template does not exist for the given identifier.
147+
TemplateNotFound string `json:"template_not_found,omitempty"`
148+
// Path : has no documentation (yet)
149+
Path *LookupError `json:"path,omitempty"`
135150
}
136151

137152
// Valid tag values for InvalidPropertyGroupError
138153
const (
154+
InvalidPropertyGroupErrorTemplateNotFound = "template_not_found"
155+
InvalidPropertyGroupErrorRestrictedContent = "restricted_content"
156+
InvalidPropertyGroupErrorOther = "other"
157+
InvalidPropertyGroupErrorPath = "path"
158+
InvalidPropertyGroupErrorUnsupportedFolder = "unsupported_folder"
139159
InvalidPropertyGroupErrorPropertyFieldTooLarge = "property_field_too_large"
140160
InvalidPropertyGroupErrorDoesNotFitTemplate = "does_not_fit_template"
141161
)
142162

163+
// UnmarshalJSON deserializes into a InvalidPropertyGroupError instance
164+
func (u *InvalidPropertyGroupError) UnmarshalJSON(body []byte) error {
165+
type wrap struct {
166+
dropbox.Tagged
167+
// Path : has no documentation (yet)
168+
Path json.RawMessage `json:"path,omitempty"`
169+
}
170+
var w wrap
171+
var err error
172+
if err = json.Unmarshal(body, &w); err != nil {
173+
return err
174+
}
175+
u.Tag = w.Tag
176+
switch u.Tag {
177+
case "template_not_found":
178+
err = json.Unmarshal(body, &u.TemplateNotFound)
179+
180+
if err != nil {
181+
return err
182+
}
183+
case "path":
184+
err = json.Unmarshal(w.Path, &u.Path)
185+
186+
if err != nil {
187+
return err
188+
}
189+
}
190+
return nil
191+
}
192+
143193
// AddPropertiesError : has no documentation (yet)
144194
type AddPropertiesError struct {
145195
dropbox.Tagged
196+
// TemplateNotFound : Template does not exist for the given identifier.
197+
TemplateNotFound string `json:"template_not_found,omitempty"`
198+
// Path : has no documentation (yet)
199+
Path *LookupError `json:"path,omitempty"`
146200
}
147201

148202
// Valid tag values for AddPropertiesError
149203
const (
204+
AddPropertiesErrorTemplateNotFound = "template_not_found"
205+
AddPropertiesErrorRestrictedContent = "restricted_content"
206+
AddPropertiesErrorOther = "other"
207+
AddPropertiesErrorPath = "path"
208+
AddPropertiesErrorUnsupportedFolder = "unsupported_folder"
209+
AddPropertiesErrorPropertyFieldTooLarge = "property_field_too_large"
210+
AddPropertiesErrorDoesNotFitTemplate = "does_not_fit_template"
150211
AddPropertiesErrorPropertyGroupAlreadyExists = "property_group_already_exists"
151212
)
152213

214+
// UnmarshalJSON deserializes into a AddPropertiesError instance
215+
func (u *AddPropertiesError) UnmarshalJSON(body []byte) error {
216+
type wrap struct {
217+
dropbox.Tagged
218+
// Path : has no documentation (yet)
219+
Path json.RawMessage `json:"path,omitempty"`
220+
}
221+
var w wrap
222+
var err error
223+
if err = json.Unmarshal(body, &w); err != nil {
224+
return err
225+
}
226+
u.Tag = w.Tag
227+
switch u.Tag {
228+
case "template_not_found":
229+
err = json.Unmarshal(body, &u.TemplateNotFound)
230+
231+
if err != nil {
232+
return err
233+
}
234+
case "path":
235+
err = json.Unmarshal(w.Path, &u.Path)
236+
237+
if err != nil {
238+
return err
239+
}
240+
}
241+
return nil
242+
}
243+
153244
// PropertyGroupTemplate : Defines how a property group may be structured.
154245
type PropertyGroupTemplate struct {
155246
// Name : Display name for the template. Template names can be up to 256
@@ -306,16 +397,43 @@ func (u *LookupError) UnmarshalJSON(body []byte) error {
306397
// ModifyTemplateError : has no documentation (yet)
307398
type ModifyTemplateError struct {
308399
dropbox.Tagged
400+
// TemplateNotFound : Template does not exist for the given identifier.
401+
TemplateNotFound string `json:"template_not_found,omitempty"`
309402
}
310403

311404
// Valid tag values for ModifyTemplateError
312405
const (
406+
ModifyTemplateErrorTemplateNotFound = "template_not_found"
407+
ModifyTemplateErrorRestrictedContent = "restricted_content"
408+
ModifyTemplateErrorOther = "other"
313409
ModifyTemplateErrorConflictingPropertyNames = "conflicting_property_names"
314410
ModifyTemplateErrorTooManyProperties = "too_many_properties"
315411
ModifyTemplateErrorTooManyTemplates = "too_many_templates"
316412
ModifyTemplateErrorTemplateAttributeTooLarge = "template_attribute_too_large"
317413
)
318414

415+
// UnmarshalJSON deserializes into a ModifyTemplateError instance
416+
func (u *ModifyTemplateError) UnmarshalJSON(body []byte) error {
417+
type wrap struct {
418+
dropbox.Tagged
419+
}
420+
var w wrap
421+
var err error
422+
if err = json.Unmarshal(body, &w); err != nil {
423+
return err
424+
}
425+
u.Tag = w.Tag
426+
switch u.Tag {
427+
case "template_not_found":
428+
err = json.Unmarshal(body, &u.TemplateNotFound)
429+
430+
if err != nil {
431+
return err
432+
}
433+
}
434+
return nil
435+
}
436+
319437
// OverwritePropertyGroupArg : has no documentation (yet)
320438
type OverwritePropertyGroupArg struct {
321439
// Path : A unique identifier for the file or folder.
@@ -584,19 +702,30 @@ func NewRemovePropertiesArg(Path string, PropertyTemplateIds []string) *RemovePr
584702
// RemovePropertiesError : has no documentation (yet)
585703
type RemovePropertiesError struct {
586704
dropbox.Tagged
705+
// TemplateNotFound : Template does not exist for the given identifier.
706+
TemplateNotFound string `json:"template_not_found,omitempty"`
707+
// Path : has no documentation (yet)
708+
Path *LookupError `json:"path,omitempty"`
587709
// PropertyGroupLookup : has no documentation (yet)
588710
PropertyGroupLookup *LookUpPropertiesError `json:"property_group_lookup,omitempty"`
589711
}
590712

591713
// Valid tag values for RemovePropertiesError
592714
const (
715+
RemovePropertiesErrorTemplateNotFound = "template_not_found"
716+
RemovePropertiesErrorRestrictedContent = "restricted_content"
717+
RemovePropertiesErrorOther = "other"
718+
RemovePropertiesErrorPath = "path"
719+
RemovePropertiesErrorUnsupportedFolder = "unsupported_folder"
593720
RemovePropertiesErrorPropertyGroupLookup = "property_group_lookup"
594721
)
595722

596723
// UnmarshalJSON deserializes into a RemovePropertiesError instance
597724
func (u *RemovePropertiesError) UnmarshalJSON(body []byte) error {
598725
type wrap struct {
599726
dropbox.Tagged
727+
// Path : has no documentation (yet)
728+
Path json.RawMessage `json:"path,omitempty"`
600729
// PropertyGroupLookup : has no documentation (yet)
601730
PropertyGroupLookup json.RawMessage `json:"property_group_lookup,omitempty"`
602731
}
@@ -607,6 +736,18 @@ func (u *RemovePropertiesError) UnmarshalJSON(body []byte) error {
607736
}
608737
u.Tag = w.Tag
609738
switch u.Tag {
739+
case "template_not_found":
740+
err = json.Unmarshal(body, &u.TemplateNotFound)
741+
742+
if err != nil {
743+
return err
744+
}
745+
case "path":
746+
err = json.Unmarshal(w.Path, &u.Path)
747+
748+
if err != nil {
749+
return err
750+
}
610751
case "property_group_lookup":
611752
err = json.Unmarshal(w.PropertyGroupLookup, &u.PropertyGroupLookup)
612753

@@ -688,19 +829,32 @@ func NewUpdatePropertiesArg(Path string, UpdatePropertyGroups []*PropertyGroupUp
688829
// UpdatePropertiesError : has no documentation (yet)
689830
type UpdatePropertiesError struct {
690831
dropbox.Tagged
832+
// TemplateNotFound : Template does not exist for the given identifier.
833+
TemplateNotFound string `json:"template_not_found,omitempty"`
834+
// Path : has no documentation (yet)
835+
Path *LookupError `json:"path,omitempty"`
691836
// PropertyGroupLookup : has no documentation (yet)
692837
PropertyGroupLookup *LookUpPropertiesError `json:"property_group_lookup,omitempty"`
693838
}
694839

695840
// Valid tag values for UpdatePropertiesError
696841
const (
697-
UpdatePropertiesErrorPropertyGroupLookup = "property_group_lookup"
842+
UpdatePropertiesErrorTemplateNotFound = "template_not_found"
843+
UpdatePropertiesErrorRestrictedContent = "restricted_content"
844+
UpdatePropertiesErrorOther = "other"
845+
UpdatePropertiesErrorPath = "path"
846+
UpdatePropertiesErrorUnsupportedFolder = "unsupported_folder"
847+
UpdatePropertiesErrorPropertyFieldTooLarge = "property_field_too_large"
848+
UpdatePropertiesErrorDoesNotFitTemplate = "does_not_fit_template"
849+
UpdatePropertiesErrorPropertyGroupLookup = "property_group_lookup"
698850
)
699851

700852
// UnmarshalJSON deserializes into a UpdatePropertiesError instance
701853
func (u *UpdatePropertiesError) UnmarshalJSON(body []byte) error {
702854
type wrap struct {
703855
dropbox.Tagged
856+
// Path : has no documentation (yet)
857+
Path json.RawMessage `json:"path,omitempty"`
704858
// PropertyGroupLookup : has no documentation (yet)
705859
PropertyGroupLookup json.RawMessage `json:"property_group_lookup,omitempty"`
706860
}
@@ -711,6 +865,18 @@ func (u *UpdatePropertiesError) UnmarshalJSON(body []byte) error {
711865
}
712866
u.Tag = w.Tag
713867
switch u.Tag {
868+
case "template_not_found":
869+
err = json.Unmarshal(body, &u.TemplateNotFound)
870+
871+
if err != nil {
872+
return err
873+
}
874+
case "path":
875+
err = json.Unmarshal(w.Path, &u.Path)
876+
877+
if err != nil {
878+
return err
879+
}
714880
case "property_group_lookup":
715881
err = json.Unmarshal(w.PropertyGroupLookup, &u.PropertyGroupLookup)
716882

0 commit comments

Comments
 (0)