github.com/Files-com/files-sdk-go/v2@v2.1.2/bundleregistration.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 BundleRegistration struct {
    11  	Code              string                 `json:"code,omitempty" path:"code,omitempty" url:"code,omitempty"`
    12  	Name              string                 `json:"name,omitempty" path:"name,omitempty" url:"name,omitempty"`
    13  	Company           string                 `json:"company,omitempty" path:"company,omitempty" url:"company,omitempty"`
    14  	Email             string                 `json:"email,omitempty" path:"email,omitempty" url:"email,omitempty"`
    15  	Ip                string                 `json:"ip,omitempty" path:"ip,omitempty" url:"ip,omitempty"`
    16  	InboxCode         string                 `json:"inbox_code,omitempty" path:"inbox_code,omitempty" url:"inbox_code,omitempty"`
    17  	ClickwrapBody     string                 `json:"clickwrap_body,omitempty" path:"clickwrap_body,omitempty" url:"clickwrap_body,omitempty"`
    18  	FormFieldSetId    int64                  `json:"form_field_set_id,omitempty" path:"form_field_set_id,omitempty" url:"form_field_set_id,omitempty"`
    19  	FormFieldData     map[string]interface{} `json:"form_field_data,omitempty" path:"form_field_data,omitempty" url:"form_field_data,omitempty"`
    20  	BundleCode        string                 `json:"bundle_code,omitempty" path:"bundle_code,omitempty" url:"bundle_code,omitempty"`
    21  	BundleId          int64                  `json:"bundle_id,omitempty" path:"bundle_id,omitempty" url:"bundle_id,omitempty"`
    22  	BundleRecipientId int64                  `json:"bundle_recipient_id,omitempty" path:"bundle_recipient_id,omitempty" url:"bundle_recipient_id,omitempty"`
    23  	CreatedAt         *time.Time             `json:"created_at,omitempty" path:"created_at,omitempty" url:"created_at,omitempty"`
    24  }
    25  
    26  // Identifier no path or id
    27  
    28  type BundleRegistrationCollection []BundleRegistration
    29  
    30  type BundleRegistrationListParams struct {
    31  	UserId   int64 `url:"user_id,omitempty" required:"false" json:"user_id,omitempty" path:"user_id"`
    32  	BundleId int64 `url:"bundle_id,omitempty" required:"false" json:"bundle_id,omitempty" path:"bundle_id"`
    33  	ListParams
    34  }
    35  
    36  func (b *BundleRegistration) UnmarshalJSON(data []byte) error {
    37  	type bundleRegistration BundleRegistration
    38  	var v bundleRegistration
    39  	if err := json.Unmarshal(data, &v); err != nil {
    40  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    41  	}
    42  
    43  	*b = BundleRegistration(v)
    44  	return nil
    45  }
    46  
    47  func (b *BundleRegistrationCollection) UnmarshalJSON(data []byte) error {
    48  	type bundleRegistrations BundleRegistrationCollection
    49  	var v bundleRegistrations
    50  	if err := json.Unmarshal(data, &v); err != nil {
    51  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    52  	}
    53  
    54  	*b = BundleRegistrationCollection(v)
    55  	return nil
    56  }
    57  
    58  func (b *BundleRegistrationCollection) ToSlice() *[]interface{} {
    59  	ret := make([]interface{}, len(*b))
    60  	for i, v := range *b {
    61  		ret[i] = v
    62  	}
    63  
    64  	return &ret
    65  }