github.com/Files-com/files-sdk-go/v3@v3.1.81/bundlepath.go (about)

     1  package files_sdk
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	lib "github.com/Files-com/files-sdk-go/v3/lib"
     7  )
     8  
     9  type BundlePath struct {
    10  	Recursive *bool  `json:"recursive,omitempty" path:"recursive,omitempty" url:"recursive,omitempty"`
    11  	Path      string `json:"path,omitempty" path:"path,omitempty" url:"path,omitempty"`
    12  }
    13  
    14  func (b BundlePath) Identifier() interface{} {
    15  	return b.Path
    16  }
    17  
    18  type BundlePathCollection []BundlePath
    19  
    20  func (b *BundlePath) UnmarshalJSON(data []byte) error {
    21  	type bundlePath BundlePath
    22  	var v bundlePath
    23  	if err := json.Unmarshal(data, &v); err != nil {
    24  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    25  	}
    26  
    27  	*b = BundlePath(v)
    28  	return nil
    29  }
    30  
    31  func (b *BundlePathCollection) UnmarshalJSON(data []byte) error {
    32  	type bundlePaths BundlePathCollection
    33  	var v bundlePaths
    34  	if err := json.Unmarshal(data, &v); err != nil {
    35  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    36  	}
    37  
    38  	*b = BundlePathCollection(v)
    39  	return nil
    40  }
    41  
    42  func (b *BundlePathCollection) ToSlice() *[]interface{} {
    43  	ret := make([]interface{}, len(*b))
    44  	for i, v := range *b {
    45  		ret[i] = v
    46  	}
    47  
    48  	return &ret
    49  }