mirror of
https://github.com/hanzoai/go-fulfillment.git
synced 2026-10-30 18:36:06 +00:00
194 lines
4.6 KiB
Go
194 lines
4.6 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 (
|
|
"encoding/json"
|
|
|
|
strfmt "github.com/go-openapi/strfmt"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/swag"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// AccessTokenRequest access token request
|
|
// swagger:model accessTokenRequest
|
|
type AccessTokenRequest struct {
|
|
|
|
// Id and secret provided by FDC
|
|
// Required: true
|
|
ClientID *string `json:"client_id"`
|
|
|
|
// client secret
|
|
// Required: true
|
|
ClientSecret *string `json:"client_secret"`
|
|
|
|
// Indicates how you're authenticating your request, see `username`, `password`, and `refresh_token` below
|
|
// Required: true
|
|
// Enum: [password refresh_token]
|
|
GrantType *string `json:"grant_type"`
|
|
|
|
// See above
|
|
Password string `json:"password,omitempty"`
|
|
|
|
// You may request future tokens with the `refresh_token` from your previous `/oauth/access_token` request
|
|
RefreshToken string `json:"refresh_token,omitempty"`
|
|
|
|
// Currently limited to Order Management System
|
|
// Required: true
|
|
// Enum: [oms]
|
|
Scope *string `json:"scope"`
|
|
|
|
// Required along with `password` if not "refreshing" the token
|
|
Username string `json:"username,omitempty"`
|
|
}
|
|
|
|
// Validate validates this access token request
|
|
func (m *AccessTokenRequest) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateClientID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateClientSecret(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateGrantType(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateScope(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *AccessTokenRequest) validateClientID(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("client_id", "body", m.ClientID); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *AccessTokenRequest) validateClientSecret(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("client_secret", "body", m.ClientSecret); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
var accessTokenRequestTypeGrantTypePropEnum []interface{}
|
|
|
|
func init() {
|
|
var res []string
|
|
if err := json.Unmarshal([]byte(`["password","refresh_token"]`), &res); err != nil {
|
|
panic(err)
|
|
}
|
|
for _, v := range res {
|
|
accessTokenRequestTypeGrantTypePropEnum = append(accessTokenRequestTypeGrantTypePropEnum, v)
|
|
}
|
|
}
|
|
|
|
const (
|
|
|
|
// AccessTokenRequestGrantTypePassword captures enum value "password"
|
|
AccessTokenRequestGrantTypePassword string = "password"
|
|
|
|
// AccessTokenRequestGrantTypeRefreshToken captures enum value "refresh_token"
|
|
AccessTokenRequestGrantTypeRefreshToken string = "refresh_token"
|
|
)
|
|
|
|
// prop value enum
|
|
func (m *AccessTokenRequest) validateGrantTypeEnum(path, location string, value string) error {
|
|
if err := validate.Enum(path, location, value, accessTokenRequestTypeGrantTypePropEnum); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *AccessTokenRequest) validateGrantType(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("grant_type", "body", m.GrantType); err != nil {
|
|
return err
|
|
}
|
|
|
|
// value enum
|
|
if err := m.validateGrantTypeEnum("grant_type", "body", *m.GrantType); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
var accessTokenRequestTypeScopePropEnum []interface{}
|
|
|
|
func init() {
|
|
var res []string
|
|
if err := json.Unmarshal([]byte(`["oms"]`), &res); err != nil {
|
|
panic(err)
|
|
}
|
|
for _, v := range res {
|
|
accessTokenRequestTypeScopePropEnum = append(accessTokenRequestTypeScopePropEnum, v)
|
|
}
|
|
}
|
|
|
|
const (
|
|
|
|
// AccessTokenRequestScopeOms captures enum value "oms"
|
|
AccessTokenRequestScopeOms string = "oms"
|
|
)
|
|
|
|
// prop value enum
|
|
func (m *AccessTokenRequest) validateScopeEnum(path, location string, value string) error {
|
|
if err := validate.Enum(path, location, value, accessTokenRequestTypeScopePropEnum); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *AccessTokenRequest) validateScope(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("scope", "body", m.Scope); err != nil {
|
|
return err
|
|
}
|
|
|
|
// value enum
|
|
if err := m.validateScopeEnum("scope", "body", *m.Scope); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *AccessTokenRequest) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *AccessTokenRequest) UnmarshalBinary(b []byte) error {
|
|
var res AccessTokenRequest
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|