github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/create_contract_unsigned_tx.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  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  )
    14  
    15  // CreateContractUnsignedTx create contract unsigned tx
    16  // swagger:model CreateContractUnsignedTx
    17  type CreateContractUnsignedTx struct {
    18  	UnsignedTx
    19  
    20  	// Address of the contract to be created
    21  	// Required: true
    22  	ContractID EncodedPubkey `json:"contract_id"`
    23  }
    24  
    25  // UnmarshalJSON unmarshals this object from a JSON structure
    26  func (m *CreateContractUnsignedTx) UnmarshalJSON(raw []byte) error {
    27  	// AO0
    28  	var aO0 UnsignedTx
    29  	if err := swag.ReadJSON(raw, &aO0); err != nil {
    30  		return err
    31  	}
    32  	m.UnsignedTx = aO0
    33  
    34  	// AO1
    35  	var dataAO1 struct {
    36  		ContractID EncodedPubkey `json:"contract_id"`
    37  	}
    38  	if err := swag.ReadJSON(raw, &dataAO1); err != nil {
    39  		return err
    40  	}
    41  
    42  	m.ContractID = dataAO1.ContractID
    43  
    44  	return nil
    45  }
    46  
    47  // MarshalJSON marshals this object to a JSON structure
    48  func (m CreateContractUnsignedTx) MarshalJSON() ([]byte, error) {
    49  	_parts := make([][]byte, 0, 2)
    50  
    51  	aO0, err := swag.WriteJSON(m.UnsignedTx)
    52  	if err != nil {
    53  		return nil, err
    54  	}
    55  	_parts = append(_parts, aO0)
    56  
    57  	var dataAO1 struct {
    58  		ContractID EncodedPubkey `json:"contract_id"`
    59  	}
    60  
    61  	dataAO1.ContractID = m.ContractID
    62  
    63  	jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1)
    64  	if errAO1 != nil {
    65  		return nil, errAO1
    66  	}
    67  	_parts = append(_parts, jsonDataAO1)
    68  
    69  	return swag.ConcatJSON(_parts...), nil
    70  }
    71  
    72  // Validate validates this create contract unsigned tx
    73  func (m *CreateContractUnsignedTx) Validate(formats strfmt.Registry) error {
    74  	var res []error
    75  
    76  	// validation for a type composition with UnsignedTx
    77  	if err := m.UnsignedTx.Validate(formats); err != nil {
    78  		res = append(res, err)
    79  	}
    80  
    81  	if err := m.validateContractID(formats); err != nil {
    82  		res = append(res, err)
    83  	}
    84  
    85  	if len(res) > 0 {
    86  		return errors.CompositeValidationError(res...)
    87  	}
    88  	return nil
    89  }
    90  
    91  func (m *CreateContractUnsignedTx) validateContractID(formats strfmt.Registry) error {
    92  
    93  	if err := m.ContractID.Validate(formats); err != nil {
    94  		if ve, ok := err.(*errors.Validation); ok {
    95  			return ve.ValidateName("contract_id")
    96  		}
    97  		return err
    98  	}
    99  
   100  	return nil
   101  }
   102  
   103  // MarshalBinary interface implementation
   104  func (m *CreateContractUnsignedTx) MarshalBinary() ([]byte, error) {
   105  	if m == nil {
   106  		return nil, nil
   107  	}
   108  	return swag.WriteJSON(m)
   109  }
   110  
   111  // UnmarshalBinary interface implementation
   112  func (m *CreateContractUnsignedTx) UnmarshalBinary(b []byte) error {
   113  	var res CreateContractUnsignedTx
   114  	if err := swag.ReadJSON(b, &res); err != nil {
   115  		return err
   116  	}
   117  	*m = res
   118  	return nil
   119  }