github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/tier_pricing.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package mono_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  	"context"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/strfmt"
    13  	"github.com/go-openapi/swag"
    14  )
    15  
    16  // TierPricing tier pricing
    17  //
    18  // swagger:model TierPricing
    19  type TierPricing struct {
    20  	Tier
    21  
    22  	// included runtime count
    23  	IncludedRuntimeCount int64 `json:"includedRuntimeCount,omitempty"`
    24  
    25  	// price per runtime
    26  	PricePerRuntime float64 `json:"pricePerRuntime,omitempty"`
    27  
    28  	// tier price
    29  	TierPrice float64 `json:"tierPrice,omitempty"`
    30  }
    31  
    32  // UnmarshalJSON unmarshals this object from a JSON structure
    33  func (m *TierPricing) UnmarshalJSON(raw []byte) error {
    34  	// AO0
    35  	var aO0 Tier
    36  	if err := swag.ReadJSON(raw, &aO0); err != nil {
    37  		return err
    38  	}
    39  	m.Tier = aO0
    40  
    41  	// AO1
    42  	var dataAO1 struct {
    43  		IncludedRuntimeCount int64 `json:"includedRuntimeCount,omitempty"`
    44  
    45  		PricePerRuntime float64 `json:"pricePerRuntime,omitempty"`
    46  
    47  		TierPrice float64 `json:"tierPrice,omitempty"`
    48  	}
    49  	if err := swag.ReadJSON(raw, &dataAO1); err != nil {
    50  		return err
    51  	}
    52  
    53  	m.IncludedRuntimeCount = dataAO1.IncludedRuntimeCount
    54  
    55  	m.PricePerRuntime = dataAO1.PricePerRuntime
    56  
    57  	m.TierPrice = dataAO1.TierPrice
    58  
    59  	return nil
    60  }
    61  
    62  // MarshalJSON marshals this object to a JSON structure
    63  func (m TierPricing) MarshalJSON() ([]byte, error) {
    64  	_parts := make([][]byte, 0, 2)
    65  
    66  	aO0, err := swag.WriteJSON(m.Tier)
    67  	if err != nil {
    68  		return nil, err
    69  	}
    70  	_parts = append(_parts, aO0)
    71  	var dataAO1 struct {
    72  		IncludedRuntimeCount int64 `json:"includedRuntimeCount,omitempty"`
    73  
    74  		PricePerRuntime float64 `json:"pricePerRuntime,omitempty"`
    75  
    76  		TierPrice float64 `json:"tierPrice,omitempty"`
    77  	}
    78  
    79  	dataAO1.IncludedRuntimeCount = m.IncludedRuntimeCount
    80  
    81  	dataAO1.PricePerRuntime = m.PricePerRuntime
    82  
    83  	dataAO1.TierPrice = m.TierPrice
    84  
    85  	jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1)
    86  	if errAO1 != nil {
    87  		return nil, errAO1
    88  	}
    89  	_parts = append(_parts, jsonDataAO1)
    90  	return swag.ConcatJSON(_parts...), nil
    91  }
    92  
    93  // Validate validates this tier pricing
    94  func (m *TierPricing) Validate(formats strfmt.Registry) error {
    95  	var res []error
    96  
    97  	// validation for a type composition with Tier
    98  	if err := m.Tier.Validate(formats); err != nil {
    99  		res = append(res, err)
   100  	}
   101  
   102  	if len(res) > 0 {
   103  		return errors.CompositeValidationError(res...)
   104  	}
   105  	return nil
   106  }
   107  
   108  // ContextValidate validate this tier pricing based on the context it is used
   109  func (m *TierPricing) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   110  	var res []error
   111  
   112  	// validation for a type composition with Tier
   113  	if err := m.Tier.ContextValidate(ctx, formats); err != nil {
   114  		res = append(res, err)
   115  	}
   116  
   117  	if len(res) > 0 {
   118  		return errors.CompositeValidationError(res...)
   119  	}
   120  	return nil
   121  }
   122  
   123  // MarshalBinary interface implementation
   124  func (m *TierPricing) MarshalBinary() ([]byte, error) {
   125  	if m == nil {
   126  		return nil, nil
   127  	}
   128  	return swag.WriteJSON(m)
   129  }
   130  
   131  // UnmarshalBinary interface implementation
   132  func (m *TierPricing) UnmarshalBinary(b []byte) error {
   133  	var res TierPricing
   134  	if err := swag.ReadJSON(b, &res); err != nil {
   135  		return err
   136  	}
   137  	*m = res
   138  	return nil
   139  }