mirror of
https://github.com/hanzoai/go-fulfillment.git
synced 2026-10-30 18:36:06 +00:00
152 lines
3.1 KiB
Go
152 lines
3.1 KiB
Go
// 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 (
|
|
"strconv"
|
|
|
|
strfmt "github.com/go-openapi/strfmt"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/swag"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// NewOrder new order
|
|
// swagger:model newOrder
|
|
type NewOrder struct {
|
|
|
|
// integrator
|
|
Integrator string `json:"integrator,omitempty"`
|
|
|
|
// items
|
|
// Required: true
|
|
Items []*NewOrderItem `json:"items"`
|
|
|
|
// Necessary if you have a multitenancy account, otherwise we will associate the order with your account
|
|
MerchantID int64 `json:"merchantId,omitempty"`
|
|
|
|
// Unique ID provided by the merchant
|
|
// Required: true
|
|
MerchantOrderID *string `json:"merchantOrderId"`
|
|
|
|
// notes
|
|
Notes string `json:"notes,omitempty"`
|
|
|
|
// recipient
|
|
// Required: true
|
|
Recipient *NewContactInfo `json:"recipient"`
|
|
|
|
// shipping method
|
|
// Required: true
|
|
ShippingMethod *string `json:"shippingMethod"`
|
|
}
|
|
|
|
// Validate validates this new order
|
|
func (m *NewOrder) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateItems(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateMerchantOrderID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateRecipient(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateShippingMethod(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *NewOrder) validateItems(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("items", "body", m.Items); err != nil {
|
|
return err
|
|
}
|
|
|
|
for i := 0; i < len(m.Items); i++ {
|
|
if swag.IsZero(m.Items[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Items[i] != nil {
|
|
if err := m.Items[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("items" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *NewOrder) validateMerchantOrderID(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("merchantOrderId", "body", m.MerchantOrderID); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *NewOrder) validateRecipient(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("recipient", "body", m.Recipient); err != nil {
|
|
return err
|
|
}
|
|
|
|
if m.Recipient != nil {
|
|
if err := m.Recipient.Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("recipient")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *NewOrder) validateShippingMethod(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("shippingMethod", "body", m.ShippingMethod); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *NewOrder) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *NewOrder) UnmarshalBinary(b []byte) error {
|
|
var res NewOrder
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|