github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-billing/preview/2020-11-05/models/billing20201105_tax_settings.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  	"context"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/strfmt"
    13  	"github.com/go-openapi/swag"
    14  )
    15  
    16  // Billing20201105TaxSettings TaxSettings contain a Billing Account's settings related to taxation.
    17  //
    18  // These are oriented to Stripe's tax settings:
    19  //
    20  // https://stripe.com/docs/billing/taxes/tax-rates.
    21  //
    22  // swagger:model billing_20201105TaxSettings
    23  type Billing20201105TaxSettings struct {
    24  
    25  	// exemption_status indicates the customer’s tax exemption status which
    26  	// can be one of none, exempt, or reverse.
    27  	ExemptionStatus *TaxSettingsExemptionStatus `json:"exemption_status,omitempty"`
    28  
    29  	// id is the tax ID to include on invoices.
    30  	ID string `json:"id,omitempty"`
    31  
    32  	// id_type is the tax ID type.
    33  	IDType *TaxSettingsIDType `json:"id_type,omitempty"`
    34  }
    35  
    36  // Validate validates this billing 20201105 tax settings
    37  func (m *Billing20201105TaxSettings) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	if err := m.validateExemptionStatus(formats); err != nil {
    41  		res = append(res, err)
    42  	}
    43  
    44  	if err := m.validateIDType(formats); err != nil {
    45  		res = append(res, err)
    46  	}
    47  
    48  	if len(res) > 0 {
    49  		return errors.CompositeValidationError(res...)
    50  	}
    51  	return nil
    52  }
    53  
    54  func (m *Billing20201105TaxSettings) validateExemptionStatus(formats strfmt.Registry) error {
    55  	if swag.IsZero(m.ExemptionStatus) { // not required
    56  		return nil
    57  	}
    58  
    59  	if m.ExemptionStatus != nil {
    60  		if err := m.ExemptionStatus.Validate(formats); err != nil {
    61  			if ve, ok := err.(*errors.Validation); ok {
    62  				return ve.ValidateName("exemption_status")
    63  			} else if ce, ok := err.(*errors.CompositeError); ok {
    64  				return ce.ValidateName("exemption_status")
    65  			}
    66  			return err
    67  		}
    68  	}
    69  
    70  	return nil
    71  }
    72  
    73  func (m *Billing20201105TaxSettings) validateIDType(formats strfmt.Registry) error {
    74  	if swag.IsZero(m.IDType) { // not required
    75  		return nil
    76  	}
    77  
    78  	if m.IDType != nil {
    79  		if err := m.IDType.Validate(formats); err != nil {
    80  			if ve, ok := err.(*errors.Validation); ok {
    81  				return ve.ValidateName("id_type")
    82  			} else if ce, ok := err.(*errors.CompositeError); ok {
    83  				return ce.ValidateName("id_type")
    84  			}
    85  			return err
    86  		}
    87  	}
    88  
    89  	return nil
    90  }
    91  
    92  // ContextValidate validate this billing 20201105 tax settings based on the context it is used
    93  func (m *Billing20201105TaxSettings) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    94  	var res []error
    95  
    96  	if err := m.contextValidateExemptionStatus(ctx, formats); err != nil {
    97  		res = append(res, err)
    98  	}
    99  
   100  	if err := m.contextValidateIDType(ctx, formats); err != nil {
   101  		res = append(res, err)
   102  	}
   103  
   104  	if len(res) > 0 {
   105  		return errors.CompositeValidationError(res...)
   106  	}
   107  	return nil
   108  }
   109  
   110  func (m *Billing20201105TaxSettings) contextValidateExemptionStatus(ctx context.Context, formats strfmt.Registry) error {
   111  
   112  	if m.ExemptionStatus != nil {
   113  		if err := m.ExemptionStatus.ContextValidate(ctx, formats); err != nil {
   114  			if ve, ok := err.(*errors.Validation); ok {
   115  				return ve.ValidateName("exemption_status")
   116  			} else if ce, ok := err.(*errors.CompositeError); ok {
   117  				return ce.ValidateName("exemption_status")
   118  			}
   119  			return err
   120  		}
   121  	}
   122  
   123  	return nil
   124  }
   125  
   126  func (m *Billing20201105TaxSettings) contextValidateIDType(ctx context.Context, formats strfmt.Registry) error {
   127  
   128  	if m.IDType != nil {
   129  		if err := m.IDType.ContextValidate(ctx, formats); err != nil {
   130  			if ve, ok := err.(*errors.Validation); ok {
   131  				return ve.ValidateName("id_type")
   132  			} else if ce, ok := err.(*errors.CompositeError); ok {
   133  				return ce.ValidateName("id_type")
   134  			}
   135  			return err
   136  		}
   137  	}
   138  
   139  	return nil
   140  }
   141  
   142  // MarshalBinary interface implementation
   143  func (m *Billing20201105TaxSettings) MarshalBinary() ([]byte, error) {
   144  	if m == nil {
   145  		return nil, nil
   146  	}
   147  	return swag.WriteJSON(m)
   148  }
   149  
   150  // UnmarshalBinary interface implementation
   151  func (m *Billing20201105TaxSettings) UnmarshalBinary(b []byte) error {
   152  	var res Billing20201105TaxSettings
   153  	if err := swag.ReadJSON(b, &res); err != nil {
   154  		return err
   155  	}
   156  	*m = res
   157  	return nil
   158  }