github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-billing/preview/2020-11-05/models/billing20201105_card_details.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 // Billing20201105CardDetails CardDetails contains credit/debit card details. 17 // 18 // swagger:model billing_20201105CardDetails 19 type Billing20201105CardDetails struct { 20 21 // brand of the card. 22 Brand *CardDetailsBrand `json:"brand,omitempty"` 23 24 // exp_month is the two-digit month part of the card's expiration date. 25 ExpMonth int32 `json:"exp_month,omitempty"` 26 27 // exp_year is the four-digit year part of the card's expiration date. 28 ExpYear int32 `json:"exp_year,omitempty"` 29 30 // last4 is the last four digits of the card's PAN (long number). 31 Last4 string `json:"last4,omitempty"` 32 } 33 34 // Validate validates this billing 20201105 card details 35 func (m *Billing20201105CardDetails) Validate(formats strfmt.Registry) error { 36 var res []error 37 38 if err := m.validateBrand(formats); err != nil { 39 res = append(res, err) 40 } 41 42 if len(res) > 0 { 43 return errors.CompositeValidationError(res...) 44 } 45 return nil 46 } 47 48 func (m *Billing20201105CardDetails) validateBrand(formats strfmt.Registry) error { 49 if swag.IsZero(m.Brand) { // not required 50 return nil 51 } 52 53 if m.Brand != nil { 54 if err := m.Brand.Validate(formats); err != nil { 55 if ve, ok := err.(*errors.Validation); ok { 56 return ve.ValidateName("brand") 57 } else if ce, ok := err.(*errors.CompositeError); ok { 58 return ce.ValidateName("brand") 59 } 60 return err 61 } 62 } 63 64 return nil 65 } 66 67 // ContextValidate validate this billing 20201105 card details based on the context it is used 68 func (m *Billing20201105CardDetails) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 69 var res []error 70 71 if err := m.contextValidateBrand(ctx, 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 *Billing20201105CardDetails) contextValidateBrand(ctx context.Context, formats strfmt.Registry) error { 82 83 if m.Brand != nil { 84 if err := m.Brand.ContextValidate(ctx, formats); err != nil { 85 if ve, ok := err.(*errors.Validation); ok { 86 return ve.ValidateName("brand") 87 } else if ce, ok := err.(*errors.CompositeError); ok { 88 return ce.ValidateName("brand") 89 } 90 return err 91 } 92 } 93 94 return nil 95 } 96 97 // MarshalBinary interface implementation 98 func (m *Billing20201105CardDetails) MarshalBinary() ([]byte, error) { 99 if m == nil { 100 return nil, nil 101 } 102 return swag.WriteJSON(m) 103 } 104 105 // UnmarshalBinary interface implementation 106 func (m *Billing20201105CardDetails) UnmarshalBinary(b []byte) error { 107 var res Billing20201105CardDetails 108 if err := swag.ReadJSON(b, &res); err != nil { 109 return err 110 } 111 *m = res 112 return nil 113 }