// Code generated by go-swagger; DO NOT EDIT.

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// CreditStatus credit status
//
// swagger:model CreditStatus
type CreditStatus struct {

	// account ID
	AccountID string `json:"AccountID,omitempty" gorm:"primary_key"`

	// available cash
	AvailableCash float64 `json:"AvailableCash,omitempty" gorm:"type:numeric(23,13);default:0.0"`

	// available credit
	AvailableCredit float64 `json:"AvailableCredit,omitempty" gorm:"type:numeric(23,13);default:0.0"`

	// last update
	// Format: datetime
	LastUpdate strfmt.DateTime `json:"LastUpdate,omitempty" gorm:"type:timestamptz"`
}

// Validate validates this credit status
func (m *CreditStatus) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateLastUpdate(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *CreditStatus) validateLastUpdate(formats strfmt.Registry) error {

	if swag.IsZero(m.LastUpdate) { // not required
		return nil
	}

	if err := validate.FormatOf("LastUpdate", "body", "datetime", m.LastUpdate.String(), formats); err != nil {
		return err
	}

	return nil
}

// MarshalBinary interface implementation
func (m *CreditStatus) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *CreditStatus) UnmarshalBinary(b []byte) error {
	var res CreditStatus
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
