github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/billing_information.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  // BillingInformation billing information
    18  //
    19  // swagger:model BillingInformation
    20  type BillingInformation struct {
    21  
    22  	// address
    23  	Address *AddressInfo `json:"address,omitempty"`
    24  
    25  	// billing date
    26  	// Format: date
    27  	BillingDate *strfmt.Date `json:"billingDate,omitempty"`
    28  
    29  	// cc exp month
    30  	CcExpMonth *string `json:"ccExpMonth,omitempty"`
    31  
    32  	// cc exp year
    33  	CcExpYear *string `json:"ccExpYear,omitempty"`
    34  
    35  	// cc last4
    36  	CcLast4 *string `json:"ccLast4,omitempty"`
    37  
    38  	// customer ID
    39  	CustomerID *string `json:"customerID,omitempty"`
    40  
    41  	// email
    42  	Email *string `json:"email,omitempty"`
    43  
    44  	// external URL
    45  	ExternalURL string `json:"externalURL,omitempty"`
    46  
    47  	// has ever had trial
    48  	HasEverHadTrial bool `json:"hasEverHadTrial,omitempty"`
    49  
    50  	// is stripe customer
    51  	IsStripeCustomer bool `json:"isStripeCustomer,omitempty"`
    52  
    53  	// name
    54  	Name *string `json:"name,omitempty"`
    55  
    56  	// reseller managed
    57  	ResellerManaged bool `json:"resellerManaged,omitempty"`
    58  
    59  	// self serve
    60  	SelfServe bool `json:"selfServe,omitempty"`
    61  }
    62  
    63  // Validate validates this billing information
    64  func (m *BillingInformation) Validate(formats strfmt.Registry) error {
    65  	var res []error
    66  
    67  	if err := m.validateAddress(formats); err != nil {
    68  		res = append(res, err)
    69  	}
    70  
    71  	if err := m.validateBillingDate(formats); err != nil {
    72  		res = append(res, err)
    73  	}
    74  
    75  	if len(res) > 0 {
    76  		return errors.CompositeValidationError(res...)
    77  	}
    78  	return nil
    79  }
    80  
    81  func (m *BillingInformation) validateAddress(formats strfmt.Registry) error {
    82  	if swag.IsZero(m.Address) { // not required
    83  		return nil
    84  	}
    85  
    86  	if m.Address != nil {
    87  		if err := m.Address.Validate(formats); err != nil {
    88  			if ve, ok := err.(*errors.Validation); ok {
    89  				return ve.ValidateName("address")
    90  			}
    91  			return err
    92  		}
    93  	}
    94  
    95  	return nil
    96  }
    97  
    98  func (m *BillingInformation) validateBillingDate(formats strfmt.Registry) error {
    99  	if swag.IsZero(m.BillingDate) { // not required
   100  		return nil
   101  	}
   102  
   103  	if err := validate.FormatOf("billingDate", "body", "date", m.BillingDate.String(), formats); err != nil {
   104  		return err
   105  	}
   106  
   107  	return nil
   108  }
   109  
   110  // ContextValidate validate this billing information based on the context it is used
   111  func (m *BillingInformation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   112  	var res []error
   113  
   114  	if err := m.contextValidateAddress(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 *BillingInformation) contextValidateAddress(ctx context.Context, formats strfmt.Registry) error {
   125  
   126  	if m.Address != nil {
   127  		if err := m.Address.ContextValidate(ctx, formats); err != nil {
   128  			if ve, ok := err.(*errors.Validation); ok {
   129  				return ve.ValidateName("address")
   130  			}
   131  			return err
   132  		}
   133  	}
   134  
   135  	return nil
   136  }
   137  
   138  // MarshalBinary interface implementation
   139  func (m *BillingInformation) 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 *BillingInformation) UnmarshalBinary(b []byte) error {
   148  	var res BillingInformation
   149  	if err := swag.ReadJSON(b, &res); err != nil {
   150  		return err
   151  	}
   152  	*m = res
   153  	return nil
   154  }