openapi

package
v0.0.0-...-8a3887a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package openapi provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Package openapi provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Package openapi provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Package openapi provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func NewCreateShipmentRequest

func NewCreateShipmentRequest(server string, body CreateShipmentJSONRequestBody) (*http.Request, error)

NewCreateShipmentRequest calls the generic CreateShipment builder with application/json body

func NewCreateShipmentRequestWithBody

func NewCreateShipmentRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewCreateShipmentRequestWithBody generates requests for CreateShipment with any type of body

func NewGetDocumentRequest

func NewGetDocumentRequest(server string, trackingNo string) (*http.Request, error)

NewGetDocumentRequest generates requests for GetDocument

func NewVoidShipmentRequest

func NewVoidShipmentRequest(server string, trackingNo string) (*http.Request, error)

NewVoidShipmentRequest generates requests for VoidShipment

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router gin.IRouter, si ServerInterface)

RegisterHandlers creates http.Handler with routing matching OpenAPI spec.

func RegisterHandlersWithOptions

func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)

RegisterHandlersWithOptions creates http.Handler with additional options

Types

type Address

type Address struct {
	Name         string  `json:"name" validate:"max=30"`
	Company      *string `json:"company,omitempty" validate:"max=20"`
	StreetNumber string  `json:"streetNumber" validate:"max=6"`
	StreetName   string  `json:"streetName" validate:"max=30"`
	City         string  `json:"city" validate:"max=30"`
	Province     string  `json:"province"`
	Country      string  `json:"country"`
	PostalCode   string  `json:"postalCode"`
	PhoneNumber  struct {
		CountryCode *string `json:"countryCode,omitempty"`
		AreaCode    *string `json:"areaCode,omitempty"`
		Phone       *string `json:"phone,omitempty"`
	} `json:"phoneNumber"`
}

Address defines model for Address.

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) CreateShipment

func (c *Client) CreateShipment(ctx context.Context, body CreateShipmentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) CreateShipmentWithBody

func (c *Client) CreateShipmentWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetDocument

func (c *Client) GetDocument(ctx context.Context, trackingNo string, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) VoidShipment

func (c *Client) VoidShipment(ctx context.Context, trackingNo string, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// CreateShipmentWithBody request with any body
	CreateShipmentWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	CreateShipment(ctx context.Context, body CreateShipmentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// VoidShipment request
	VoidShipment(ctx context.Context, trackingNo string, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetDocument request
	GetDocument(ctx context.Context, trackingNo string, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) CreateShipmentWithBodyWithResponse

func (c *ClientWithResponses) CreateShipmentWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateShipmentResponse, error)

CreateShipmentWithBodyWithResponse request with arbitrary body returning *CreateShipmentResponse

func (*ClientWithResponses) CreateShipmentWithResponse

func (c *ClientWithResponses) CreateShipmentWithResponse(ctx context.Context, body CreateShipmentJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateShipmentResponse, error)

func (*ClientWithResponses) GetDocumentWithResponse

func (c *ClientWithResponses) GetDocumentWithResponse(ctx context.Context, trackingNo string, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error)

GetDocumentWithResponse request returning *GetDocumentResponse

func (*ClientWithResponses) VoidShipmentWithResponse

func (c *ClientWithResponses) VoidShipmentWithResponse(ctx context.Context, trackingNo string, reqEditors ...RequestEditorFn) (*VoidShipmentResponse, error)

VoidShipmentWithResponse request returning *VoidShipmentResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// CreateShipmentWithBodyWithResponse request with any body
	CreateShipmentWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateShipmentResponse, error)

	CreateShipmentWithResponse(ctx context.Context, body CreateShipmentJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateShipmentResponse, error)

	// VoidShipmentWithResponse request
	VoidShipmentWithResponse(ctx context.Context, trackingNo string, reqEditors ...RequestEditorFn) (*VoidShipmentResponse, error)

	// GetDocumentWithResponse request
	GetDocumentWithResponse(ctx context.Context, trackingNo string, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type CreateShipmentJSONRequestBody

type CreateShipmentJSONRequestBody = CreateShipmentRequest

CreateShipmentJSONRequestBody defines body for CreateShipment for application/json ContentType.

type CreateShipmentRequest

type CreateShipmentRequest struct {
	Shipment struct {
		SenderInformation struct {
			Address   Address `json:"address"`
			TaxNumber *string `json:"taxNumber,omitempty" validate:"max=11"`
		} `json:"senderInformation"`
		ReceiverInformation struct {
			Address   Address `json:"address"`
			TaxNumber *string `json:"taxNumber,omitempty" validate:"max=11"`
		} `json:"receiverInformation"`
		ShipmentDate       string `json:"shipmentDate"`
		PackageInformation struct {
			ServiceID         string `json:"serviceID"`
			Description       string `json:"description"`
			TotalWeight       Weight `json:"totalWeight"`
			TotalPieces       int32  `json:"totalPieces"`
			PiecesInformation *struct {
				Pieces []Piece `json:"pieces" xml:"Piece"`
			} `json:"piecesInformation,omitempty"`
		} `json:"packageInformation"`
		PaymentInformation struct {
			PaymentType             *CreateShipmentRequestShipmentPaymentInformationPaymentType `json:"paymentType,omitempty"`
			RegisteredAccountNumber *string                                                     `json:"registeredAccountNumber,omitempty"`
			BillingAccountNumber    *string                                                     `json:"billingAccountNumber,omitempty"`
		} `json:"paymentInformation"`
		PickupInformation struct {
			PickupType *CreateShipmentRequestShipmentPickupInformationPickupType `json:"pickupType,omitempty"`
		} `json:"pickupInformation"`
		TrackingReferenceInformation *struct {
			Reference1 *string `json:"reference1,omitempty"`
			Reference2 *string `json:"reference2,omitempty"`
			Reference3 *string `json:"reference3,omitempty"`
			Reference4 *string `json:"reference4,omitempty"`
		} `json:"trackingReferenceInformation,omitempty"`
	} `json:"shipment"`
	PrinterType CreateShipmentRequestPrinterType `json:"printerType"`
}

CreateShipmentRequest defines model for CreateShipmentRequest.

type CreateShipmentRequestPrinterType

type CreateShipmentRequestPrinterType string

CreateShipmentRequestPrinterType defines model for CreateShipmentRequest.PrinterType.

const (
	Regular CreateShipmentRequestPrinterType = "Regular"
	Thermal CreateShipmentRequestPrinterType = "Thermal"
)

Defines values for CreateShipmentRequestPrinterType.

type CreateShipmentRequestShipmentPaymentInformationPaymentType

type CreateShipmentRequestShipmentPaymentInformationPaymentType string

CreateShipmentRequestShipmentPaymentInformationPaymentType defines model for CreateShipmentRequest.Shipment.PaymentInformation.PaymentType.

Defines values for CreateShipmentRequestShipmentPaymentInformationPaymentType.

type CreateShipmentRequestShipmentPickupInformationPickupType

type CreateShipmentRequestShipmentPickupInformationPickupType string

CreateShipmentRequestShipmentPickupInformationPickupType defines model for CreateShipmentRequest.Shipment.PickupInformation.PickupType.

Defines values for CreateShipmentRequestShipmentPickupInformationPickupType.

type CreateShipmentRes

type CreateShipmentRes struct {
	MasterTrackingNo string   `json:"masterTrackingNo"`
	TrackingNOs      []string `json:"trackingNOs"`
}

CreateShipmentRes defines model for CreateShipmentRes.

type CreateShipmentResponse

type CreateShipmentResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON201      *CreateShipmentRes
	JSONDefault  *Error
}

func ParseCreateShipmentResponse

func ParseCreateShipmentResponse(rsp *http.Response) (*CreateShipmentResponse, error)

ParseCreateShipmentResponse parses an HTTP response from a CreateShipmentWithResponse call

func (CreateShipmentResponse) Status

func (r CreateShipmentResponse) Status() string

Status returns HTTPResponse.Status

func (CreateShipmentResponse) StatusCode

func (r CreateShipmentResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Dimension

type Dimension struct {
	Value         int32                   `json:"value"`
	DimensionUnit *DimensionDimensionUnit `json:"dimensionUnit,omitempty"`
}

Dimension defines model for Dimension.

type DimensionDimensionUnit

type DimensionDimensionUnit string

DimensionDimensionUnit defines model for Dimension.DimensionUnit.

const (
	Cm DimensionDimensionUnit = "cm"
	In DimensionDimensionUnit = "in"
)

Defines values for DimensionDimensionUnit.

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error defines model for Error.

type GetDocumentResponse

type GetDocumentResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSONDefault  *Error
}

func ParseGetDocumentResponse

func ParseGetDocumentResponse(rsp *http.Response) (*GetDocumentResponse, error)

ParseGetDocumentResponse parses an HTTP response from a GetDocumentWithResponse call

func (GetDocumentResponse) Status

func (r GetDocumentResponse) Status() string

Status returns HTTPResponse.Status

func (GetDocumentResponse) StatusCode

func (r GetDocumentResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GinServerOptions

type GinServerOptions struct {
	BaseURL      string
	Middlewares  []MiddlewareFunc
	ErrorHandler func(*gin.Context, error, int)
}

GinServerOptions provides options for the Gin server.

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type MiddlewareFunc

type MiddlewareFunc func(c *gin.Context)

type Piece

type Piece struct {
	Weight Weight    `json:"weight"`
	Height Dimension `json:"height"`
	Length Dimension `json:"length"`
	Width  Dimension `json:"width"`
}

Piece defines model for Piece.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type ServerInterface

type ServerInterface interface {

	// (POST /shipments)
	CreateShipment(c *gin.Context)

	// (DELETE /shipments/{trackingNo})
	VoidShipment(c *gin.Context, trackingNo string)

	// (GET /shipments/{trackingNo})
	GetDocument(c *gin.Context, trackingNo string)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandler       func(*gin.Context, error, int)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateShipment

func (siw *ServerInterfaceWrapper) CreateShipment(c *gin.Context)

CreateShipment operation middleware

func (*ServerInterfaceWrapper) GetDocument

func (siw *ServerInterfaceWrapper) GetDocument(c *gin.Context)

GetDocument operation middleware

func (*ServerInterfaceWrapper) VoidShipment

func (siw *ServerInterfaceWrapper) VoidShipment(c *gin.Context)

VoidShipment operation middleware

type VoidShipmentResponse

type VoidShipmentResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSONDefault  *Error
}

func ParseVoidShipmentResponse

func ParseVoidShipmentResponse(rsp *http.Response) (*VoidShipmentResponse, error)

ParseVoidShipmentResponse parses an HTTP response from a VoidShipmentWithResponse call

func (VoidShipmentResponse) Status

func (r VoidShipmentResponse) Status() string

Status returns HTTPResponse.Status

func (VoidShipmentResponse) StatusCode

func (r VoidShipmentResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Weight

type Weight struct {
	Value      int32            `json:"value"`
	WeightUnit WeightWeightUnit `json:"weightUnit"`
}

Weight defines model for Weight.

type WeightWeightUnit

type WeightWeightUnit string

WeightWeightUnit defines model for Weight.WeightUnit.

const (
	Kg WeightWeightUnit = "kg"
	Lb WeightWeightUnit = "lb"
)

Defines values for WeightWeightUnit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL