github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/models/channel_force_progress_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  	"bytes"
    10  	"encoding/json"
    11  	"io"
    12  
    13  	strfmt "github.com/go-openapi/strfmt"
    14  
    15  	"github.com/go-openapi/errors"
    16  	"github.com/go-openapi/runtime"
    17  	"github.com/go-openapi/swag"
    18  	"github.com/go-openapi/validate"
    19  
    20  	utils "github.com/aeternity/aepp-sdk-go/utils"
    21  )
    22  
    23  // ChannelForceProgressTx channel force progress tx
    24  // swagger:model ChannelForceProgressTx
    25  type ChannelForceProgressTx struct {
    26  
    27  	// channel id
    28  	// Required: true
    29  	ChannelID *string `json:"channel_id"`
    30  
    31  	// fee
    32  	// Required: true
    33  	Fee utils.BigInt `json:"fee"`
    34  
    35  	// from id
    36  	// Required: true
    37  	FromID *string `json:"from_id"`
    38  
    39  	// nonce
    40  	Nonce uint64 `json:"nonce,omitempty"`
    41  
    42  	// The whole set of off-chain state trees
    43  	OffchainTrees string `json:"offchain_trees,omitempty"`
    44  
    45  	// payload
    46  	// Required: true
    47  	Payload *string `json:"payload"`
    48  
    49  	// Channel's next round
    50  	// Required: true
    51  	Round *uint64 `json:"round"`
    52  
    53  	// Channel's next state_hash
    54  	// Required: true
    55  	StateHash *string `json:"state_hash"`
    56  
    57  	// ttl
    58  	TTL uint64 `json:"ttl,omitempty"`
    59  
    60  	updateField OffChainUpdate
    61  }
    62  
    63  // Update gets the update of this base type
    64  func (m *ChannelForceProgressTx) Update() OffChainUpdate {
    65  	return m.updateField
    66  }
    67  
    68  // SetUpdate sets the update of this base type
    69  func (m *ChannelForceProgressTx) SetUpdate(val OffChainUpdate) {
    70  	m.updateField = val
    71  }
    72  
    73  // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure
    74  func (m *ChannelForceProgressTx) UnmarshalJSON(raw []byte) error {
    75  	var data struct {
    76  		ChannelID *string `json:"channel_id"`
    77  
    78  		Fee utils.BigInt `json:"fee"`
    79  
    80  		FromID *string `json:"from_id"`
    81  
    82  		Nonce uint64 `json:"nonce,omitempty"`
    83  
    84  		OffchainTrees string `json:"offchain_trees,omitempty"`
    85  
    86  		Payload *string `json:"payload"`
    87  
    88  		Round *uint64 `json:"round"`
    89  
    90  		StateHash *string `json:"state_hash"`
    91  
    92  		TTL uint64 `json:"ttl,omitempty"`
    93  
    94  		Update json.RawMessage `json:"update"`
    95  	}
    96  	buf := bytes.NewBuffer(raw)
    97  	dec := json.NewDecoder(buf)
    98  	dec.UseNumber()
    99  
   100  	if err := dec.Decode(&data); err != nil {
   101  		return err
   102  	}
   103  
   104  	propUpdate, err := UnmarshalOffChainUpdate(bytes.NewBuffer(data.Update), runtime.JSONConsumer())
   105  	if err != nil && err != io.EOF {
   106  		return err
   107  	}
   108  
   109  	var result ChannelForceProgressTx
   110  
   111  	// channel_id
   112  	result.ChannelID = data.ChannelID
   113  
   114  	// fee
   115  	result.Fee = data.Fee
   116  
   117  	// from_id
   118  	result.FromID = data.FromID
   119  
   120  	// nonce
   121  	result.Nonce = data.Nonce
   122  
   123  	// offchain_trees
   124  	result.OffchainTrees = data.OffchainTrees
   125  
   126  	// payload
   127  	result.Payload = data.Payload
   128  
   129  	// round
   130  	result.Round = data.Round
   131  
   132  	// state_hash
   133  	result.StateHash = data.StateHash
   134  
   135  	// ttl
   136  	result.TTL = data.TTL
   137  
   138  	// update
   139  	result.updateField = propUpdate
   140  
   141  	*m = result
   142  
   143  	return nil
   144  }
   145  
   146  // MarshalJSON marshals this object with a polymorphic type to a JSON structure
   147  func (m ChannelForceProgressTx) MarshalJSON() ([]byte, error) {
   148  	var b1, b2, b3 []byte
   149  	var err error
   150  	b1, err = json.Marshal(struct {
   151  		ChannelID *string `json:"channel_id"`
   152  
   153  		Fee utils.BigInt `json:"fee"`
   154  
   155  		FromID *string `json:"from_id"`
   156  
   157  		Nonce uint64 `json:"nonce,omitempty"`
   158  
   159  		OffchainTrees string `json:"offchain_trees,omitempty"`
   160  
   161  		Payload *string `json:"payload"`
   162  
   163  		Round *uint64 `json:"round"`
   164  
   165  		StateHash *string `json:"state_hash"`
   166  
   167  		TTL uint64 `json:"ttl,omitempty"`
   168  	}{
   169  
   170  		ChannelID: m.ChannelID,
   171  
   172  		Fee: m.Fee,
   173  
   174  		FromID: m.FromID,
   175  
   176  		Nonce: m.Nonce,
   177  
   178  		OffchainTrees: m.OffchainTrees,
   179  
   180  		Payload: m.Payload,
   181  
   182  		Round: m.Round,
   183  
   184  		StateHash: m.StateHash,
   185  
   186  		TTL: m.TTL,
   187  	},
   188  	)
   189  	if err != nil {
   190  		return nil, err
   191  	}
   192  	b2, err = json.Marshal(struct {
   193  		Update OffChainUpdate `json:"update"`
   194  	}{
   195  
   196  		Update: m.updateField,
   197  	},
   198  	)
   199  	if err != nil {
   200  		return nil, err
   201  	}
   202  
   203  	return swag.ConcatJSON(b1, b2, b3), nil
   204  }
   205  
   206  // Validate validates this channel force progress tx
   207  func (m *ChannelForceProgressTx) Validate(formats strfmt.Registry) error {
   208  	var res []error
   209  
   210  	if err := m.validateChannelID(formats); err != nil {
   211  		res = append(res, err)
   212  	}
   213  
   214  	if err := m.validateFee(formats); err != nil {
   215  		res = append(res, err)
   216  	}
   217  
   218  	if err := m.validateFromID(formats); err != nil {
   219  		res = append(res, err)
   220  	}
   221  
   222  	if err := m.validatePayload(formats); err != nil {
   223  		res = append(res, err)
   224  	}
   225  
   226  	if err := m.validateRound(formats); err != nil {
   227  		res = append(res, err)
   228  	}
   229  
   230  	if err := m.validateStateHash(formats); err != nil {
   231  		res = append(res, err)
   232  	}
   233  
   234  	if err := m.validateUpdate(formats); err != nil {
   235  		res = append(res, err)
   236  	}
   237  
   238  	if len(res) > 0 {
   239  		return errors.CompositeValidationError(res...)
   240  	}
   241  	return nil
   242  }
   243  
   244  func (m *ChannelForceProgressTx) validateChannelID(formats strfmt.Registry) error {
   245  
   246  	if err := validate.Required("channel_id", "body", m.ChannelID); err != nil {
   247  		return err
   248  	}
   249  
   250  	return nil
   251  }
   252  
   253  func (m *ChannelForceProgressTx) validateFee(formats strfmt.Registry) error {
   254  
   255  	if err := m.Fee.Validate(formats); err != nil {
   256  		if ve, ok := err.(*errors.Validation); ok {
   257  			return ve.ValidateName("fee")
   258  		}
   259  		return err
   260  	}
   261  
   262  	return nil
   263  }
   264  
   265  func (m *ChannelForceProgressTx) validateFromID(formats strfmt.Registry) error {
   266  
   267  	if err := validate.Required("from_id", "body", m.FromID); err != nil {
   268  		return err
   269  	}
   270  
   271  	return nil
   272  }
   273  
   274  func (m *ChannelForceProgressTx) validatePayload(formats strfmt.Registry) error {
   275  
   276  	if err := validate.Required("payload", "body", m.Payload); err != nil {
   277  		return err
   278  	}
   279  
   280  	return nil
   281  }
   282  
   283  func (m *ChannelForceProgressTx) validateRound(formats strfmt.Registry) error {
   284  
   285  	if err := validate.Required("round", "body", m.Round); err != nil {
   286  		return err
   287  	}
   288  
   289  	return nil
   290  }
   291  
   292  func (m *ChannelForceProgressTx) validateStateHash(formats strfmt.Registry) error {
   293  
   294  	if err := validate.Required("state_hash", "body", m.StateHash); err != nil {
   295  		return err
   296  	}
   297  
   298  	return nil
   299  }
   300  
   301  func (m *ChannelForceProgressTx) validateUpdate(formats strfmt.Registry) error {
   302  
   303  	if err := m.Update().Validate(formats); err != nil {
   304  		if ve, ok := err.(*errors.Validation); ok {
   305  			return ve.ValidateName("update")
   306  		}
   307  		return err
   308  	}
   309  
   310  	return nil
   311  }
   312  
   313  // MarshalBinary interface implementation
   314  func (m *ChannelForceProgressTx) MarshalBinary() ([]byte, error) {
   315  	if m == nil {
   316  		return nil, nil
   317  	}
   318  	return swag.WriteJSON(m)
   319  }
   320  
   321  // UnmarshalBinary interface implementation
   322  func (m *ChannelForceProgressTx) UnmarshalBinary(b []byte) error {
   323  	var res ChannelForceProgressTx
   324  	if err := swag.ReadJSON(b, &res); err != nil {
   325  		return err
   326  	}
   327  	*m = res
   328  	return nil
   329  }