github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/models/event.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"strconv"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  
    17  	utils "github.com/aeternity/aepp-sdk-go/utils"
    18  )
    19  
    20  // Event event
    21  // swagger:model Event
    22  type Event struct {
    23  
    24  	// Contract address
    25  	// Required: true
    26  	Address *string `json:"address"`
    27  
    28  	// Log event data (as contract byte array).
    29  	// Required: true
    30  	Data *string `json:"data"`
    31  
    32  	// Event topics
    33  	// Required: true
    34  	Topics []utils.BigInt `json:"topics"`
    35  }
    36  
    37  // Validate validates this event
    38  func (m *Event) Validate(formats strfmt.Registry) error {
    39  	var res []error
    40  
    41  	if err := m.validateAddress(formats); err != nil {
    42  		res = append(res, err)
    43  	}
    44  
    45  	if err := m.validateData(formats); err != nil {
    46  		res = append(res, err)
    47  	}
    48  
    49  	if err := m.validateTopics(formats); err != nil {
    50  		res = append(res, err)
    51  	}
    52  
    53  	if len(res) > 0 {
    54  		return errors.CompositeValidationError(res...)
    55  	}
    56  	return nil
    57  }
    58  
    59  func (m *Event) validateAddress(formats strfmt.Registry) error {
    60  
    61  	if err := validate.Required("address", "body", m.Address); err != nil {
    62  		return err
    63  	}
    64  
    65  	return nil
    66  }
    67  
    68  func (m *Event) validateData(formats strfmt.Registry) error {
    69  
    70  	if err := validate.Required("data", "body", m.Data); err != nil {
    71  		return err
    72  	}
    73  
    74  	return nil
    75  }
    76  
    77  func (m *Event) validateTopics(formats strfmt.Registry) error {
    78  
    79  	if err := validate.Required("topics", "body", m.Topics); err != nil {
    80  		return err
    81  	}
    82  
    83  	for i := 0; i < len(m.Topics); i++ {
    84  
    85  		if err := m.Topics[i].Validate(formats); err != nil {
    86  			if ve, ok := err.(*errors.Validation); ok {
    87  				return ve.ValidateName("topics" + "." + strconv.Itoa(i))
    88  			}
    89  			return err
    90  		}
    91  
    92  	}
    93  
    94  	return nil
    95  }
    96  
    97  // MarshalBinary interface implementation
    98  func (m *Event) MarshalBinary() ([]byte, error) {
    99  	if m == nil {
   100  		return nil, nil
   101  	}
   102  	return swag.WriteJSON(m)
   103  }
   104  
   105  // UnmarshalBinary interface implementation
   106  func (m *Event) UnmarshalBinary(b []byte) error {
   107  	var res Event
   108  	if err := swag.ReadJSON(b, &res); err != nil {
   109  		return err
   110  	}
   111  	*m = res
   112  	return nil
   113  }