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

     1  package files_sdk
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	lib "github.com/Files-com/files-sdk-go/v2/lib"
     7  )
     8  
     9  type WebhookTest struct {
    10  	Code            int64                  `json:"code,omitempty" path:"code,omitempty" url:"code,omitempty"`
    11  	Message         string                 `json:"message,omitempty" path:"message,omitempty" url:"message,omitempty"`
    12  	Status          string                 `json:"status,omitempty" path:"status,omitempty" url:"status,omitempty"`
    13  	Data            Auto                   `json:"data,omitempty" path:"data,omitempty" url:"data,omitempty"`
    14  	Success         *bool                  `json:"success,omitempty" path:"success,omitempty" url:"success,omitempty"`
    15  	Url             string                 `json:"url,omitempty" path:"url,omitempty" url:"url,omitempty"`
    16  	Method          string                 `json:"method,omitempty" path:"method,omitempty" url:"method,omitempty"`
    17  	Encoding        string                 `json:"encoding,omitempty" path:"encoding,omitempty" url:"encoding,omitempty"`
    18  	Headers         map[string]interface{} `json:"headers,omitempty" path:"headers,omitempty" url:"headers,omitempty"`
    19  	Body            map[string]interface{} `json:"body,omitempty" path:"body,omitempty" url:"body,omitempty"`
    20  	RawBody         string                 `json:"raw_body,omitempty" path:"raw_body,omitempty" url:"raw_body,omitempty"`
    21  	FileAsBody      *bool                  `json:"file_as_body,omitempty" path:"file_as_body,omitempty" url:"file_as_body,omitempty"`
    22  	FileFormField   string                 `json:"file_form_field,omitempty" path:"file_form_field,omitempty" url:"file_form_field,omitempty"`
    23  	Action          string                 `json:"action,omitempty" path:"action,omitempty" url:"action,omitempty"`
    24  	UseDedicatedIps *bool                  `json:"use_dedicated_ips,omitempty" path:"use_dedicated_ips,omitempty" url:"use_dedicated_ips,omitempty"`
    25  }
    26  
    27  // Identifier no path or id
    28  
    29  type WebhookTestCollection []WebhookTest
    30  
    31  type WebhookTestCreateParams struct {
    32  	Url             string                 `url:"url,omitempty" required:"true" json:"url,omitempty" path:"url"`
    33  	Method          string                 `url:"method,omitempty" required:"false" json:"method,omitempty" path:"method"`
    34  	Encoding        string                 `url:"encoding,omitempty" required:"false" json:"encoding,omitempty" path:"encoding"`
    35  	Headers         map[string]interface{} `url:"headers,omitempty" required:"false" json:"headers,omitempty" path:"headers"`
    36  	Body            map[string]interface{} `url:"body,omitempty" required:"false" json:"body,omitempty" path:"body"`
    37  	RawBody         string                 `url:"raw_body,omitempty" required:"false" json:"raw_body,omitempty" path:"raw_body"`
    38  	FileAsBody      *bool                  `url:"file_as_body,omitempty" required:"false" json:"file_as_body,omitempty" path:"file_as_body"`
    39  	FileFormField   string                 `url:"file_form_field,omitempty" required:"false" json:"file_form_field,omitempty" path:"file_form_field"`
    40  	Action          string                 `url:"action,omitempty" required:"false" json:"action,omitempty" path:"action"`
    41  	UseDedicatedIps *bool                  `url:"use_dedicated_ips,omitempty" required:"false" json:"use_dedicated_ips,omitempty" path:"use_dedicated_ips"`
    42  }
    43  
    44  func (w *WebhookTest) UnmarshalJSON(data []byte) error {
    45  	type webhookTest WebhookTest
    46  	var v webhookTest
    47  	if err := json.Unmarshal(data, &v); err != nil {
    48  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    49  	}
    50  
    51  	*w = WebhookTest(v)
    52  	return nil
    53  }
    54  
    55  func (w *WebhookTestCollection) UnmarshalJSON(data []byte) error {
    56  	type webhookTests WebhookTestCollection
    57  	var v webhookTests
    58  	if err := json.Unmarshal(data, &v); err != nil {
    59  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    60  	}
    61  
    62  	*w = WebhookTestCollection(v)
    63  	return nil
    64  }
    65  
    66  func (w *WebhookTestCollection) ToSlice() *[]interface{} {
    67  	ret := make([]interface{}, len(*w))
    68  	for i, v := range *w {
    69  		ret[i] = v
    70  	}
    71  
    72  	return &ret
    73  }