github.com/Files-com/files-sdk-go/v2@v2.1.2/bundlerecipient.go (about)

     1  package files_sdk
     2  
     3  import (
     4  	"encoding/json"
     5  	"time"
     6  
     7  	lib "github.com/Files-com/files-sdk-go/v2/lib"
     8  )
     9  
    10  type BundleRecipient struct {
    11  	Company          string     `json:"company,omitempty" path:"company,omitempty" url:"company,omitempty"`
    12  	Name             string     `json:"name,omitempty" path:"name,omitempty" url:"name,omitempty"`
    13  	Note             string     `json:"note,omitempty" path:"note,omitempty" url:"note,omitempty"`
    14  	Recipient        string     `json:"recipient,omitempty" path:"recipient,omitempty" url:"recipient,omitempty"`
    15  	SentAt           *time.Time `json:"sent_at,omitempty" path:"sent_at,omitempty" url:"sent_at,omitempty"`
    16  	UserId           int64      `json:"user_id,omitempty" path:"user_id,omitempty" url:"user_id,omitempty"`
    17  	BundleId         int64      `json:"bundle_id,omitempty" path:"bundle_id,omitempty" url:"bundle_id,omitempty"`
    18  	ShareAfterCreate *bool      `json:"share_after_create,omitempty" path:"share_after_create,omitempty" url:"share_after_create,omitempty"`
    19  }
    20  
    21  // Identifier no path or id
    22  
    23  type BundleRecipientCollection []BundleRecipient
    24  
    25  type BundleRecipientListParams struct {
    26  	UserId   int64                  `url:"user_id,omitempty" required:"false" json:"user_id,omitempty" path:"user_id"`
    27  	SortBy   map[string]interface{} `url:"sort_by,omitempty" required:"false" json:"sort_by,omitempty" path:"sort_by"`
    28  	Filter   BundleRecipient        `url:"filter,omitempty" required:"false" json:"filter,omitempty" path:"filter"`
    29  	BundleId int64                  `url:"bundle_id,omitempty" required:"true" json:"bundle_id,omitempty" path:"bundle_id"`
    30  	ListParams
    31  }
    32  
    33  type BundleRecipientCreateParams struct {
    34  	UserId           int64  `url:"user_id,omitempty" required:"false" json:"user_id,omitempty" path:"user_id"`
    35  	BundleId         int64  `url:"bundle_id,omitempty" required:"true" json:"bundle_id,omitempty" path:"bundle_id"`
    36  	Recipient        string `url:"recipient,omitempty" required:"true" json:"recipient,omitempty" path:"recipient"`
    37  	Name             string `url:"name,omitempty" required:"false" json:"name,omitempty" path:"name"`
    38  	Company          string `url:"company,omitempty" required:"false" json:"company,omitempty" path:"company"`
    39  	Note             string `url:"note,omitempty" required:"false" json:"note,omitempty" path:"note"`
    40  	ShareAfterCreate *bool  `url:"share_after_create,omitempty" required:"false" json:"share_after_create,omitempty" path:"share_after_create"`
    41  }
    42  
    43  func (b *BundleRecipient) UnmarshalJSON(data []byte) error {
    44  	type bundleRecipient BundleRecipient
    45  	var v bundleRecipient
    46  	if err := json.Unmarshal(data, &v); err != nil {
    47  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    48  	}
    49  
    50  	*b = BundleRecipient(v)
    51  	return nil
    52  }
    53  
    54  func (b *BundleRecipientCollection) UnmarshalJSON(data []byte) error {
    55  	type bundleRecipients BundleRecipientCollection
    56  	var v bundleRecipients
    57  	if err := json.Unmarshal(data, &v); err != nil {
    58  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    59  	}
    60  
    61  	*b = BundleRecipientCollection(v)
    62  	return nil
    63  }
    64  
    65  func (b *BundleRecipientCollection) ToSlice() *[]interface{} {
    66  	ret := make([]interface{}, len(*b))
    67  	for i, v := range *b {
    68  		ret[i] = v
    69  	}
    70  
    71  	return &ret
    72  }