mirror of https://github.com/vernonkeenan/lib
369 lines
8.7 KiB
Go
369 lines
8.7 KiB
Go
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
// (c) 2012-2020 by Taxnexus, Inc.
|
|
// All rights reserved worldwide.
|
|
// Proprietary product; unlicensed use is not allowed
|
|
|
|
package members_models
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/strfmt"
|
|
"github.com/go-openapi/swag/jsonutils"
|
|
"github.com/go-openapi/swag/typeutils"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// Transaction Tenant-owned commercial transaction metadata. PaymentMethodID and processor material are deliberately absent. TenantID, identity, audit fields, amount, currency, and transaction date become server-owned after creation.
|
|
//
|
|
// swagger:model Transaction
|
|
type Transaction struct {
|
|
|
|
// Exact non-negative DECIMAL(10,2) text; never represented as float64.
|
|
// Pattern: ^(0|[1-9][0-9]{0,7})(\.[0-9]{1,2})?$
|
|
Amount string `json:"Amount,omitempty"`
|
|
|
|
// created by ID
|
|
// Read Only: true
|
|
// Format: uuid
|
|
CreatedByID *strfmt.UUID `json:"CreatedByID,omitempty"`
|
|
|
|
// created date
|
|
// Read Only: true
|
|
// Format: date-time
|
|
CreatedDate *strfmt.DateTime `json:"CreatedDate,omitempty"`
|
|
|
|
// currency
|
|
// Pattern: ^[A-Z]{3}$
|
|
Currency string `json:"Currency,omitempty"`
|
|
|
|
// ID
|
|
// Read Only: true
|
|
// Format: uuid
|
|
ID strfmt.UUID `json:"ID,omitempty"`
|
|
|
|
// last modified by ID
|
|
// Read Only: true
|
|
// Format: uuid
|
|
LastModifiedByID *strfmt.UUID `json:"LastModifiedByID,omitempty"`
|
|
|
|
// last modified date
|
|
// Format: date-time
|
|
LastModifiedDate *strfmt.DateTime `json:"LastModifiedDate,omitempty"`
|
|
|
|
// status
|
|
// Enum: ["pending","completed","failed","refunded"]
|
|
Status *string `json:"Status,omitempty"`
|
|
|
|
// tenant ID
|
|
// Read Only: true
|
|
// Format: uuid
|
|
TenantID *strfmt.UUID `json:"TenantID,omitempty"`
|
|
|
|
// transaction date
|
|
// Format: date-time
|
|
TransactionDate *strfmt.DateTime `json:"TransactionDate,omitempty"`
|
|
}
|
|
|
|
// Validate validates this transaction
|
|
func (m *Transaction) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateAmount(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateCreatedByID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateCreatedDate(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateCurrency(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateLastModifiedByID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateLastModifiedDate(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateStatus(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateTenantID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateTransactionDate(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateAmount(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.Amount) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.Pattern("Amount", "body", m.Amount, `^(0|[1-9][0-9]{0,7})(\.[0-9]{1,2})?$`); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateCreatedByID(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.CreatedByID) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("CreatedByID", "body", "uuid", m.CreatedByID.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateCreatedDate(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.CreatedDate) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("CreatedDate", "body", "date-time", m.CreatedDate.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateCurrency(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.Currency) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.Pattern("Currency", "body", m.Currency, `^[A-Z]{3}$`); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateID(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.ID) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("ID", "body", "uuid", m.ID.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateLastModifiedByID(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.LastModifiedByID) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("LastModifiedByID", "body", "uuid", m.LastModifiedByID.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateLastModifiedDate(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.LastModifiedDate) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("LastModifiedDate", "body", "date-time", m.LastModifiedDate.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
var transactionTypeStatusPropEnum []any
|
|
|
|
func init() {
|
|
var res []string
|
|
if err := json.Unmarshal([]byte(`["pending","completed","failed","refunded"]`), &res); err != nil {
|
|
panic(err)
|
|
}
|
|
for _, v := range res {
|
|
transactionTypeStatusPropEnum = append(transactionTypeStatusPropEnum, v)
|
|
}
|
|
}
|
|
|
|
const (
|
|
|
|
// TransactionStatusPending captures enum value "pending"
|
|
TransactionStatusPending string = "pending"
|
|
|
|
// TransactionStatusCompleted captures enum value "completed"
|
|
TransactionStatusCompleted string = "completed"
|
|
|
|
// TransactionStatusFailed captures enum value "failed"
|
|
TransactionStatusFailed string = "failed"
|
|
|
|
// TransactionStatusRefunded captures enum value "refunded"
|
|
TransactionStatusRefunded string = "refunded"
|
|
)
|
|
|
|
// prop value enum
|
|
func (m *Transaction) validateStatusEnum(path, location string, value string) error {
|
|
if err := validate.EnumCase(path, location, value, transactionTypeStatusPropEnum, true); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateStatus(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.Status) { // not required
|
|
return nil
|
|
}
|
|
|
|
// value enum
|
|
if err := m.validateStatusEnum("Status", "body", *m.Status); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateTenantID(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.TenantID) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("TenantID", "body", "uuid", m.TenantID.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) validateTransactionDate(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.TransactionDate) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("TransactionDate", "body", "date-time", m.TransactionDate.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ContextValidate validate this transaction based on the context it is used
|
|
func (m *Transaction) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.contextValidateCreatedByID(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateCreatedDate(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateID(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateLastModifiedByID(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateTenantID(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) contextValidateCreatedByID(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if err := validate.ReadOnly(ctx, "CreatedByID", "body", m.CreatedByID); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) contextValidateCreatedDate(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if err := validate.ReadOnly(ctx, "CreatedDate", "body", m.CreatedDate); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if err := validate.ReadOnly(ctx, "ID", "body", m.ID); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) contextValidateLastModifiedByID(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if err := validate.ReadOnly(ctx, "LastModifiedByID", "body", m.LastModifiedByID); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Transaction) contextValidateTenantID(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if err := validate.ReadOnly(ctx, "TenantID", "body", m.TenantID); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *Transaction) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return jsonutils.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *Transaction) UnmarshalBinary(b []byte) error {
|
|
var res Transaction
|
|
if err := jsonutils.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|