github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/tax_options.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  	"github.com/go-openapi/validate"
    15  )
    16  
    17  // TaxOptions tax options
    18  //
    19  // swagger:model TaxOptions
    20  type TaxOptions struct {
    21  
    22  	// active runtimes
    23  	// Required: true
    24  	ActiveRuntimes int64 `json:"activeRuntimes"`
    25  
    26  	// org URL name
    27  	// Required: true
    28  	OrgURLName string `json:"orgURLName"`
    29  
    30  	// shipping address
    31  	// Required: true
    32  	ShippingAddress *AddressInfo `json:"shippingAddress"`
    33  
    34  	// tier name
    35  	// Required: true
    36  	TierName string `json:"tierName"`
    37  }
    38  
    39  // Validate validates this tax options
    40  func (m *TaxOptions) Validate(formats strfmt.Registry) error {
    41  	var res []error
    42  
    43  	if err := m.validateActiveRuntimes(formats); err != nil {
    44  		res = append(res, err)
    45  	}
    46  
    47  	if err := m.validateOrgURLName(formats); err != nil {
    48  		res = append(res, err)
    49  	}
    50  
    51  	if err := m.validateShippingAddress(formats); err != nil {
    52  		res = append(res, err)
    53  	}
    54  
    55  	if err := m.validateTierName(formats); err != nil {
    56  		res = append(res, err)
    57  	}
    58  
    59  	if len(res) > 0 {
    60  		return errors.CompositeValidationError(res...)
    61  	}
    62  	return nil
    63  }
    64  
    65  func (m *TaxOptions) validateActiveRuntimes(formats strfmt.Registry) error {
    66  
    67  	if err := validate.Required("activeRuntimes", "body", int64(m.ActiveRuntimes)); err != nil {
    68  		return err
    69  	}
    70  
    71  	return nil
    72  }
    73  
    74  func (m *TaxOptions) validateOrgURLName(formats strfmt.Registry) error {
    75  
    76  	if err := validate.RequiredString("orgURLName", "body", m.OrgURLName); err != nil {
    77  		return err
    78  	}
    79  
    80  	return nil
    81  }
    82  
    83  func (m *TaxOptions) validateShippingAddress(formats strfmt.Registry) error {
    84  
    85  	if err := validate.Required("shippingAddress", "body", m.ShippingAddress); err != nil {
    86  		return err
    87  	}
    88  
    89  	if m.ShippingAddress != nil {
    90  		if err := m.ShippingAddress.Validate(formats); err != nil {
    91  			if ve, ok := err.(*errors.Validation); ok {
    92  				return ve.ValidateName("shippingAddress")
    93  			}
    94  			return err
    95  		}
    96  	}
    97  
    98  	return nil
    99  }
   100  
   101  func (m *TaxOptions) validateTierName(formats strfmt.Registry) error {
   102  
   103  	if err := validate.RequiredString("tierName", "body", m.TierName); err != nil {
   104  		return err
   105  	}
   106  
   107  	return nil
   108  }
   109  
   110  // ContextValidate validate this tax options based on the context it is used
   111  func (m *TaxOptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   112  	var res []error
   113  
   114  	if err := m.contextValidateShippingAddress(ctx, formats); err != nil {
   115  		res = append(res, err)
   116  	}
   117  
   118  	if len(res) > 0 {
   119  		return errors.CompositeValidationError(res...)
   120  	}
   121  	return nil
   122  }
   123  
   124  func (m *TaxOptions) contextValidateShippingAddress(ctx context.Context, formats strfmt.Registry) error {
   125  
   126  	if m.ShippingAddress != nil {
   127  		if err := m.ShippingAddress.ContextValidate(ctx, formats); err != nil {
   128  			if ve, ok := err.(*errors.Validation); ok {
   129  				return ve.ValidateName("shippingAddress")
   130  			}
   131  			return err
   132  		}
   133  	}
   134  
   135  	return nil
   136  }
   137  
   138  // MarshalBinary interface implementation
   139  func (m *TaxOptions) MarshalBinary() ([]byte, error) {
   140  	if m == nil {
   141  		return nil, nil
   142  	}
   143  	return swag.WriteJSON(m)
   144  }
   145  
   146  // UnmarshalBinary interface implementation
   147  func (m *TaxOptions) UnmarshalBinary(b []byte) error {
   148  	var res TaxOptions
   149  	if err := swag.ReadJSON(b, &res); err != nil {
   150  		return err
   151  	}
   152  	*m = res
   153  	return nil
   154  }