server

package
v0.0.0-...-64e7420 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const CurrencyCustomer = CurrencyEUR

CurrencyShop is the currency used by the customer

View Source
const CurrencyEUR = "EUR"
View Source
const CurrencyShop = CurrencyEUR

CurrencyShop is the currency used by the customer

View Source
const CurrencyUSD = "USD"
View Source
const RETURN_ID = "return-1"
View Source
const SingleOrderWithVariantsID = "simple_order_2"

SingleOrderWithVariantsID is the ID of the order that returns a simple order with variants, the t-shirt

View Source
const SingleOrderWithoutVariantsID = "simple_order_1"

SingleOrderWithoutVariantsID is the ID of the order that returns a simple order without variants, the sunglasses

Variables

View Source
var (
	// ErrTypeAssertionError is thrown when type an interface does not match the asserted type
	ErrTypeAssertionError = errors.New("unable to assert type")
)

Functions

func AssertAddNoteToOrderRequestRequired

func AssertAddNoteToOrderRequestRequired(obj AddNoteToOrderRequest) error

AssertAddNoteToOrderRequestRequired checks if the required fields are not zero-ed

func AssertAddressRequired

func AssertAddressRequired(obj Address) error

AssertAddressRequired checks if the required fields are not zero-ed

func AssertCategoryRequired

func AssertCategoryRequired(obj Category) error

AssertCategoryRequired checks if the required fields are not zero-ed

func AssertCreateReturn200ResponseRequired

func AssertCreateReturn200ResponseRequired(obj CreateReturn200Response) error

AssertCreateReturn200ResponseRequired checks if the required fields are not zero-ed

func AssertCustomerRequired

func AssertCustomerRequired(obj Customer) error

AssertCustomerRequired checks if the required fields are not zero-ed

func AssertFulfillmentOrderRequired

func AssertFulfillmentOrderRequired(obj FulfillmentOrder) error

AssertFulfillmentOrderRequired checks if the required fields are not zero-ed

func AssertFulfillmentRequired

func AssertFulfillmentRequired(obj Fulfillment) error

AssertFulfillmentRequired checks if the required fields are not zero-ed

func AssertIdentificationRequired

func AssertIdentificationRequired(obj Identification) error

AssertIdentificationRequired checks if the required fields are not zero-ed

func AssertImageRequired

func AssertImageRequired(obj Image) error

AssertImageRequired checks if the required fields are not zero-ed

func AssertLineItemRequired

func AssertLineItemRequired(obj LineItem) error

AssertLineItemRequired checks if the required fields are not zero-ed

func AssertMoneyRequired

func AssertMoneyRequired(obj Money) error

AssertMoneyRequired checks if the required fields are not zero-ed

func AssertMultiMoneyAmountCustomerRequired

func AssertMultiMoneyAmountCustomerRequired(obj MultiMoneyAmountCustomer) error

AssertMultiMoneyAmountCustomerRequired checks if the required fields are not zero-ed

func AssertMultiMoneyAmountShopRequired

func AssertMultiMoneyAmountShopRequired(obj MultiMoneyAmountShop) error

AssertMultiMoneyAmountShopRequired checks if the required fields are not zero-ed

func AssertMultiMoneyRequired

func AssertMultiMoneyRequired(obj MultiMoney) error

AssertMultiMoneyRequired checks if the required fields are not zero-ed

func AssertNoteRequired

func AssertNoteRequired(obj Note) error

AssertNoteRequired checks if the required fields are not zero-ed

func AssertOptionRequired

func AssertOptionRequired(obj Option) error

AssertOptionRequired checks if the required fields are not zero-ed

func AssertOrderRequired

func AssertOrderRequired(obj Order) error

AssertOrderRequired checks if the required fields are not zero-ed

func AssertOrderWithVariants

func AssertOrderWithVariants(t *testing.T, order *Order)

AssertOrderWithVariants validates order with multiple `line_items`, referring products/services **with variants**. Product variants are a requirement for supporting exchange orders as compensation method. The order must have a positive amount in EUR, with taxes and shipping costs. Regarding the payment method, must be paid with a non-cash, non-cash on delivery, non-BNPL payment method. It should have a discount applied. It must be associated with a valid customer. It must be fulfilled and paid

func AssertOrderWithoutVariants

func AssertOrderWithoutVariants(t *testing.T, order *Order)

AssertOrderWithoutVariants checks a valid order with multiple `line_items`, referring products/services **without variants**. Implement this case if your e-commerce supports products but has no support for Variants. Product variants are a requirement for supporting exchange orders as compensation method. The order must have a positive amount in EUR, with taxes and shipping costs. Regarding the payment method, must be paid with a non-cash, non-cash on delivery, non-BNPL payment method. It should have a discount applied. It must be associated with a valid customer. It must be fulfilled and paid

func AssertPaymentRequired

func AssertPaymentRequired(obj Payment) error

AssertPaymentRequired checks if the required fields are not zero-ed

func AssertProductRequired

func AssertProductRequired(obj Product) error

AssertProductRequired checks if the required fields are not zero-ed

func AssertProductUnitPriceRequired

func AssertProductUnitPriceRequired(obj ProductUnitPrice) error

AssertProductUnitPriceRequired checks if the required fields are not zero-ed

func AssertRecurseAddNoteToOrderRequestRequired

func AssertRecurseAddNoteToOrderRequestRequired(objSlice interface{}) error

AssertRecurseAddNoteToOrderRequestRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of AddNoteToOrderRequest (e.g. [][]AddNoteToOrderRequest), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseAddressRequired

func AssertRecurseAddressRequired(objSlice interface{}) error

AssertRecurseAddressRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Address (e.g. [][]Address), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseCategoryRequired

func AssertRecurseCategoryRequired(objSlice interface{}) error

AssertRecurseCategoryRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Category (e.g. [][]Category), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseCreateReturn200ResponseRequired

func AssertRecurseCreateReturn200ResponseRequired(objSlice interface{}) error

AssertRecurseCreateReturn200ResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of CreateReturn200Response (e.g. [][]CreateReturn200Response), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseCustomerRequired

func AssertRecurseCustomerRequired(objSlice interface{}) error

AssertRecurseCustomerRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Customer (e.g. [][]Customer), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseFulfillmentOrderRequired

func AssertRecurseFulfillmentOrderRequired(objSlice interface{}) error

AssertRecurseFulfillmentOrderRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of FulfillmentOrder (e.g. [][]FulfillmentOrder), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseFulfillmentRequired

func AssertRecurseFulfillmentRequired(objSlice interface{}) error

AssertRecurseFulfillmentRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Fulfillment (e.g. [][]Fulfillment), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseIdentificationRequired

func AssertRecurseIdentificationRequired(objSlice interface{}) error

AssertRecurseIdentificationRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Identification (e.g. [][]Identification), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseImageRequired

func AssertRecurseImageRequired(objSlice interface{}) error

AssertRecurseImageRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Image (e.g. [][]Image), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseInterfaceRequired

func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error

AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback. This method traverse nested slices in a preorder fashion.

func AssertRecurseLineItemRequired

func AssertRecurseLineItemRequired(objSlice interface{}) error

AssertRecurseLineItemRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of LineItem (e.g. [][]LineItem), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseMoneyRequired

func AssertRecurseMoneyRequired(objSlice interface{}) error

AssertRecurseMoneyRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Money (e.g. [][]Money), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseMultiMoneyAmountCustomerRequired

func AssertRecurseMultiMoneyAmountCustomerRequired(objSlice interface{}) error

AssertRecurseMultiMoneyAmountCustomerRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of MultiMoneyAmountCustomer (e.g. [][]MultiMoneyAmountCustomer), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseMultiMoneyAmountShopRequired

func AssertRecurseMultiMoneyAmountShopRequired(objSlice interface{}) error

AssertRecurseMultiMoneyAmountShopRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of MultiMoneyAmountShop (e.g. [][]MultiMoneyAmountShop), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseMultiMoneyRequired

func AssertRecurseMultiMoneyRequired(objSlice interface{}) error

AssertRecurseMultiMoneyRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of MultiMoney (e.g. [][]MultiMoney), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseNoteRequired

func AssertRecurseNoteRequired(objSlice interface{}) error

AssertRecurseNoteRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Note (e.g. [][]Note), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseOptionRequired

func AssertRecurseOptionRequired(objSlice interface{}) error

AssertRecurseOptionRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Option (e.g. [][]Option), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseOrderRequired

func AssertRecurseOrderRequired(objSlice interface{}) error

AssertRecurseOrderRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Order (e.g. [][]Order), otherwise ErrTypeAssertionError is thrown.

func AssertRecursePaymentRequired

func AssertRecursePaymentRequired(objSlice interface{}) error

AssertRecursePaymentRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Payment (e.g. [][]Payment), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseProductRequired

func AssertRecurseProductRequired(objSlice interface{}) error

AssertRecurseProductRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Product (e.g. [][]Product), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseProductUnitPriceRequired

func AssertRecurseProductUnitPriceRequired(objSlice interface{}) error

AssertRecurseProductUnitPriceRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ProductUnitPrice (e.g. [][]ProductUnitPrice), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRefundErrorRequired

func AssertRecurseRefundErrorRequired(objSlice interface{}) error

AssertRecurseRefundErrorRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RefundError (e.g. [][]RefundError), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRefundOrderAmountRequired

func AssertRecurseRefundOrderAmountRequired(objSlice interface{}) error

AssertRecurseRefundOrderAmountRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RefundOrderAmount (e.g. [][]RefundOrderAmount), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRefundOrderRequired

func AssertRecurseRefundOrderRequired(objSlice interface{}) error

AssertRecurseRefundOrderRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RefundOrder (e.g. [][]RefundOrder), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRefundRequestItemAmountRequired

func AssertRecurseRefundRequestItemAmountRequired(objSlice interface{}) error

AssertRecurseRefundRequestItemAmountRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RefundRequestItemAmount (e.g. [][]RefundRequestItemAmount), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRefundRequestItemRequired

func AssertRecurseRefundRequestItemRequired(objSlice interface{}) error

AssertRecurseRefundRequestItemRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RefundRequestItem (e.g. [][]RefundRequestItem), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRefundRequestRequired

func AssertRecurseRefundRequestRequired(objSlice interface{}) error

AssertRecurseRefundRequestRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RefundRequest (e.g. [][]RefundRequest), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRefundRequired

func AssertRecurseRefundRequired(objSlice interface{}) error

AssertRecurseRefundRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Refund (e.g. [][]Refund), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRefundResponseRequired

func AssertRecurseRefundResponseRequired(objSlice interface{}) error

AssertRecurseRefundResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RefundResponse (e.g. [][]RefundResponse), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseReturnOrderRequired

func AssertRecurseReturnOrderRequired(objSlice interface{}) error

AssertRecurseReturnOrderRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ReturnOrder (e.g. [][]ReturnOrder), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseReturnRequestItemRequired

func AssertRecurseReturnRequestItemRequired(objSlice interface{}) error

AssertRecurseReturnRequestItemRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ReturnRequestItem (e.g. [][]ReturnRequestItem), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseReturnRequestRequired

func AssertRecurseReturnRequestRequired(objSlice interface{}) error

AssertRecurseReturnRequestRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ReturnRequest (e.g. [][]ReturnRequest), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseReturnRequired

func AssertRecurseReturnRequired(objSlice interface{}) error

AssertRecurseReturnRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Return (e.g. [][]Return), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseReturnStatusRequired

func AssertRecurseReturnStatusRequired(objSlice interface{}) error

AssertRecurseReturnStatusRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ReturnStatus (e.g. [][]ReturnStatus), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseShippingRequired

func AssertRecurseShippingRequired(objSlice interface{}) error

AssertRecurseShippingRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Shipping (e.g. [][]Shipping), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseStatusRequired

func AssertRecurseStatusRequired(objSlice interface{}) error

AssertRecurseStatusRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Status (e.g. [][]Status), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseTagRequired

func AssertRecurseTagRequired(objSlice interface{}) error

AssertRecurseTagRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Tag (e.g. [][]Tag), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseTransactionAmountRequired

func AssertRecurseTransactionAmountRequired(objSlice interface{}) error

AssertRecurseTransactionAmountRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of TransactionAmount (e.g. [][]TransactionAmount), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseTransactionRequired

func AssertRecurseTransactionRequired(objSlice interface{}) error

AssertRecurseTransactionRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Transaction (e.g. [][]Transaction), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseValueRequired

func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error

AssertRecurseValueRequired checks each struct in the nested slice against the callback. This method traverse nested slices in a preorder fashion.

func AssertRecurseVariantRequired

func AssertRecurseVariantRequired(objSlice interface{}) error

AssertRecurseVariantRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Variant (e.g. [][]Variant), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseVariantUnitPriceRequired

func AssertRecurseVariantUnitPriceRequired(objSlice interface{}) error

AssertRecurseVariantUnitPriceRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of VariantUnitPrice (e.g. [][]VariantUnitPrice), otherwise ErrTypeAssertionError is thrown.

func AssertRefundErrorRequired

func AssertRefundErrorRequired(obj RefundError) error

AssertRefundErrorRequired checks if the required fields are not zero-ed

func AssertRefundOrderAmountRequired

func AssertRefundOrderAmountRequired(obj RefundOrderAmount) error

AssertRefundOrderAmountRequired checks if the required fields are not zero-ed

func AssertRefundOrderRequired

func AssertRefundOrderRequired(obj RefundOrder) error

AssertRefundOrderRequired checks if the required fields are not zero-ed

func AssertRefundRequestItemAmountRequired

func AssertRefundRequestItemAmountRequired(obj RefundRequestItemAmount) error

AssertRefundRequestItemAmountRequired checks if the required fields are not zero-ed

func AssertRefundRequestItemRequired

func AssertRefundRequestItemRequired(obj RefundRequestItem) error

AssertRefundRequestItemRequired checks if the required fields are not zero-ed

func AssertRefundRequestRequired

func AssertRefundRequestRequired(obj RefundRequest) error

AssertRefundRequestRequired checks if the required fields are not zero-ed

func AssertRefundRequired

func AssertRefundRequired(obj Refund) error

AssertRefundRequired checks if the required fields are not zero-ed

func AssertRefundResponseRequired

func AssertRefundResponseRequired(obj RefundResponse) error

AssertRefundResponseRequired checks if the required fields are not zero-ed

func AssertReturnOrderRequired

func AssertReturnOrderRequired(obj ReturnOrder) error

AssertReturnOrderRequired checks if the required fields are not zero-ed

func AssertReturnRequestItemRequired

func AssertReturnRequestItemRequired(obj ReturnRequestItem) error

AssertReturnRequestItemRequired checks if the required fields are not zero-ed

func AssertReturnRequestRequired

func AssertReturnRequestRequired(obj ReturnRequest) error

AssertReturnRequestRequired checks if the required fields are not zero-ed

func AssertReturnRequired

func AssertReturnRequired(obj Return) error

AssertReturnRequired checks if the required fields are not zero-ed

func AssertReturnStatusRequired

func AssertReturnStatusRequired(obj ReturnStatus) error

AssertReturnStatusRequired checks if the required fields are not zero-ed

func AssertSanity

func AssertSanity(t *testing.T, order *Order)

AssertSanity asserts that the order has data that complies with basic requirements

func AssertShippingRequired

func AssertShippingRequired(obj Shipping) error

AssertShippingRequired checks if the required fields are not zero-ed

func AssertStatusRequired

func AssertStatusRequired(obj Status) error

AssertStatusRequired checks if the required fields are not zero-ed

func AssertTagRequired

func AssertTagRequired(obj Tag) error

AssertTagRequired checks if the required fields are not zero-ed

func AssertTransactionAmountRequired

func AssertTransactionAmountRequired(obj TransactionAmount) error

AssertTransactionAmountRequired checks if the required fields are not zero-ed

func AssertTransactionRequired

func AssertTransactionRequired(obj Transaction) error

AssertTransactionRequired checks if the required fields are not zero-ed

func AssertVariantRequired

func AssertVariantRequired(obj Variant) error

AssertVariantRequired checks if the required fields are not zero-ed

func AssertVariantUnitPriceRequired

func AssertVariantUnitPriceRequired(obj VariantUnitPrice) error

AssertVariantUnitPriceRequired checks if the required fields are not zero-ed

func DefaultErrorHandler

func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)

DefaultErrorHandler defines the default logic on how to handle errors from the controller. Any errors from parsing request params will return a StatusBadRequest. Otherwise, the error code originating from the servicer will be used.

func EncodeJSONResponse

func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func IsZeroValue

func IsZeroValue(val interface{}) bool

IsZeroValue checks if the val is the zero-ed value.

func Logger

func Logger(inner http.Handler, name string) http.Handler

func NewRouter

func NewRouter(routers ...Router) *mux.Router

NewRouter creates a new router for any number of api routers

func ReadFormFileToTempFile

func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)

ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file

func ReadFormFilesToTempFiles

func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)

ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files

Types

type AddNoteToOrderRequest

type AddNoteToOrderRequest struct {

	// The text to be associated to the order
	Note string `json:"note,omitempty"`
}

type Address

type Address struct {

	// Main address line. Usually the street and number. Should not be larger than 15 characters
	AddressLine1 string `json:"address_line_1"`

	// Secondary address line. Usually the floor, door, etc. Should not be larger than 15 characters
	AddressLine2 string `json:"address_line_2,omitempty"`

	City string `json:"city"`

	Company string `json:"company,omitempty"`

	// The name of the country as it is usually used in the language of the e-commerce
	Country string `json:"country"`

	// the 2-letter country code (alpha-2) from the ISO 3166
	CountryCode string `json:"country_code"`

	Email string `json:"email,omitempty"`

	FirstName string `json:"first_name"`

	LastName string `json:"last_name"`

	Phone string `json:"phone"`

	Postcode string `json:"postcode"`

	StateProvince string `json:"state_province,omitempty"`
}

Address - Address for invoicing (not shipping, though it can be the same)

type Category

type Category struct {
	Id string `json:"id"`
}

Category - A category from the e-commerce catalog. It can be used to filter products or decide if a product is returnable or not.

type CreateReturn200Response

type CreateReturn200Response struct {

	// the id of the return generated in the platform
	ReturnId string `json:"return_id"`
}

type Customer

type Customer struct {

	// two-letter code as per the ISO 639-1 codes, preferred by the customer
	PreferredLang string `json:"preferred_lang,omitempty"`

	// Email address of the customer. This field will be used to match the customer when starting a return process
	Email string `json:"email"`

	FirstName string `json:"first_name,omitempty"`

	LastName string `json:"last_name,omitempty"`
}

Customer - Customer associated to the order

type Decimal

type Decimal = decimal.Decimal

type ErrorHandler

type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)

ErrorHandler defines the required method for handling error. You may implement it and inject this into a controller if you would like errors to be handled differently from the DefaultErrorHandler

type Fulfillment

type Fulfillment struct {

	// ID of the line item being fulfilled. Must exist in the `line_items` array of the order.
	LineItemId string `json:"line_item_id"`

	// Number of products fulfilled. The sum of quantities per `line_item_id` must match the total quantity of the line item.
	Quantity int32 `json:"quantity"`
}

Fulfillment - Line item fulfilled in an order

type FulfillmentOrder

type FulfillmentOrder struct {

	// An identifier of the e-commerce location that shipped the items in this fulfillment order.
	LocationId string `json:"location_id"`

	// Date when the fulfillment was executed
	Date time.Time `json:"date"`

	// Information of the `line_items` fulfilled in this order
	Fulfillments []Fulfillment `json:"fulfillments"`
}

FulfillmentOrder - Represents either an item or a group of items in an order that are to be fulfilled from the same location. There can be more than one fulfillment order for an order at a given location

type Identification

type Identification struct {

	// This is the `order_id` as seen by the customer (for example, in the email confirmation)
	CustomerPrintedOrderId string `json:"customer_printed_order_id"`

	// Unique identifier in the origin platform. Might not be customer-friendly. It can be the same as the `customer_printed_order_id“
	Id string `json:"id,omitempty"`
}

Identification - Extended data for identifying an order in any e-commerce

type Image

type Image struct {

	// Image alternative text
	Alt string `json:"alt,omitempty"`

	// Image name
	Name string `json:"name,omitempty"`

	// Image URL
	Src string `json:"src"`
}

Image - An image from the e-commerce catalog

type ImplResponse

type ImplResponse struct {
	Code int
	Body interface{}
}

ImplResponse response defines an error code with the associated body

func Response

func Response(code int, body interface{}) ImplResponse

Response return a ImplResponse struct filled

type IntegrationApiController

type IntegrationApiController struct {
	// contains filtered or unexported fields
}

IntegrationApiController binds http requests to an api service and writes the service results to the http response

func (*IntegrationApiController) AddNoteToOrder

func (c *IntegrationApiController) AddNoteToOrder(w http.ResponseWriter, r *http.Request)

AddNoteToOrder - Adds a note (text) to an existing order

func (*IntegrationApiController) CreateRefund

func (c *IntegrationApiController) CreateRefund(w http.ResponseWriter, r *http.Request)

CreateRefund - Creates a refund for an existing order

func (*IntegrationApiController) CreateReturn

func (c *IntegrationApiController) CreateReturn(w http.ResponseWriter, r *http.Request)

CreateReturn - Creates return in the ecommerce portal for an existing order

func (*IntegrationApiController) FindOrderByCustomerPrintedOrderId

func (c *IntegrationApiController) FindOrderByCustomerPrintedOrderId(w http.ResponseWriter, r *http.Request)

FindOrderByCustomerPrintedOrderId - Find Order by `customer_printed_order_id`

func (*IntegrationApiController) Routes

func (c *IntegrationApiController) Routes() Routes

Routes returns all the api routes for the IntegrationApiController

func (*IntegrationApiController) UpdateReturn

func (c *IntegrationApiController) UpdateReturn(w http.ResponseWriter, r *http.Request)

type IntegrationApiOption

type IntegrationApiOption func(*IntegrationApiController)

IntegrationApiOption for how the controller is set up.

func WithIntegrationApiErrorHandler

func WithIntegrationApiErrorHandler(h ErrorHandler) IntegrationApiOption

WithIntegrationApiErrorHandler inject ErrorHandler into controller

type IntegrationApiRouter

type IntegrationApiRouter interface {
	AddNoteToOrder(http.ResponseWriter, *http.Request)
	CreateRefund(http.ResponseWriter, *http.Request)
	CreateReturn(http.ResponseWriter, *http.Request)
	FindOrderByCustomerPrintedOrderId(http.ResponseWriter, *http.Request)
}

IntegrationApiRouter defines the required methods for binding the api requests to a responses for the IntegrationApi The IntegrationApiRouter implementation should parse necessary information from the http request, pass the data to a IntegrationApiServicer to perform the required actions, then write the service results to the http response.

type IntegrationApiService

type IntegrationApiService struct {
	// contains filtered or unexported fields
}

IntegrationApiService is a service that implements the logic for the IntegrationApiServicer This service should implement the business logic for every endpoint for the IntegrationApi API. Include any external packages or services that will be required by this service.

func (*IntegrationApiService) AddNoteToOrder

func (s *IntegrationApiService) AddNoteToOrder(ctx context.Context, orderID string, req AddNoteToOrderRequest) (ImplResponse, error)

func (*IntegrationApiService) CreateRefund

func (s *IntegrationApiService) CreateRefund(ctx context.Context, orderID string, req RefundRequest) (ImplResponse, error)

func (*IntegrationApiService) CreateReturn

func (s *IntegrationApiService) CreateReturn(ctx context.Context, orderID string, req ReturnRequest) (ImplResponse, error)

func (*IntegrationApiService) FindOrderByCustomerPrintedOrderId

func (s *IntegrationApiService) FindOrderByCustomerPrintedOrderId(ctx context.Context, customerOrderPrintedId string) (ImplResponse, error)

FindOrderByCustomerPrintedOrderId - Find Order by customer_order_id

func (*IntegrationApiService) UpdateReturn

func (s *IntegrationApiService) UpdateReturn(ctx context.Context, orderID string, returnID string,
	req ReturnRequest) (ImplResponse, error)

type IntegrationApiServicer

type IntegrationApiServicer interface {
	AddNoteToOrder(context.Context, string, AddNoteToOrderRequest) (ImplResponse, error)
	CreateRefund(context.Context, string, RefundRequest) (ImplResponse, error)
	CreateReturn(context.Context, string, ReturnRequest) (ImplResponse, error)
	UpdateReturn(context.Context, string, string, ReturnRequest) (ImplResponse, error)
	FindOrderByCustomerPrintedOrderId(context.Context, string) (ImplResponse, error)
}

IntegrationApiServicer defines the api actions for the IntegrationApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

func NewIntegrationApiService

func NewIntegrationApiService(refundManager refund.RefundManager) IntegrationApiServicer

NewIntegrationApiService creates a default api service

type LineItem

type LineItem struct {

	// Optional customer comments/notes for the line item
	Comment string `json:"comment,omitempty"`

	// Id of the line item in the source platform. Must be unique within the order.
	Id string `json:"id"`

	// Name of the line item (not necessarily the name of the product). If possible, in the customer `preferred_lang`
	Name string `json:"name"`

	Product Product `json:"product"`

	// number of items of the same product and variant
	Quantity int32 `json:"quantity"`

	Subtotal MultiMoney `json:"subtotal"`

	Total MultiMoney `json:"total"`

	TotalDiscounts MultiMoney `json:"total_discounts"`

	TotalTaxes MultiMoney `json:"total_taxes"`

	UnitPrice MultiMoney `json:"unit_price"`

	// Variant ID of the product. The same Product ID can have different variants but they  must be listed in a different line item. A Variant can be the size: S, M, L, XL, etc. Only one variant ia allowed at the moment (one dimension). The `variant_id` must exist in the `variants` array of the `product` object.
	VariantId string `json:"variant_id,omitempty"`

	// Name of the variant, in the customer preferred language
	VariantName string `json:"variant_name,omitempty"`

	// weight for products from the order, measured in grams
	Weight int32 `json:"weight,omitempty"`
}

LineItem - One of the line items from the Order. Consist of a quantity of a product or a product variant, with the associated price, taxes and discounts. For the properties of the item sold, the property `product` should be used. If the item sold is a variant of a product, the property `variant` should be filled additionally, with the variant information, and the properties in there will override the properties in the `product` object.

type Money

type Money struct {

	// amount (optionally with decimals), without currency symbol and thousands separator
	Amount float64 `json:"amount"`

	// three-letter code as ISO 4217 currency code.  Examples: EUR, USD, JPY, GBP... The currency must be supported by REVER.
	Currency string `json:"currency"`
}

Money - Model for an amount plus the currency in which it is expressed.

type MultiMoney

type MultiMoney struct {
	AmountShop MultiMoneyAmountShop `json:"amount_shop"`

	AmountCustomer MultiMoneyAmountCustomer `json:"amount_customer"`
}

MultiMoney - unit price of a single item (product as listed, no discounts, no taxes, quantity = 1)

func NewMultiMoney

func NewMultiMoney(amountShop float64, currencyShop string,
	amountCustomer float64, currencyCustomer string) MultiMoney

NewMultiMoney is an auxiliary function to help with the stubs and create a MultiMoney with the given amount and currency

type MultiMoneyAmountCustomer

type MultiMoneyAmountCustomer struct {

	// amount (optionally with decimals), without currency symbol and thousands separator
	Amount float64 `json:"amount"`

	// three-letter code as ISO 4217 currency code.  Examples: EUR, USD, JPY, GBP... The currency must be supported by REVER.
	Currency string `json:"currency"`
}

MultiMoneyAmountCustomer - Amount in the customer currency. Used as the amount + currency that the customer is really going to use for paying, the currency that the customer selected in the website. Usually, this comes from applying a conversion rate to the shop currency.

type MultiMoneyAmountShop

type MultiMoneyAmountShop struct {

	// amount (optionally with decimals), without currency symbol and thousands separator
	Amount float64 `json:"amount"`

	// three-letter code as ISO 4217 currency code.  Examples: EUR, USD, JPY, GBP... The currency must be supported by REVER.
	Currency string `json:"currency"`
}

MultiMoneyAmountShop - Amount in the shop currency. Useful for accounting purposes, to provide reporting in this currency. Usually, the shop currency is the same for every order within the e-commerce.

type Note

type Note struct {

	// Date when the note was added to the order
	Date time.Time `json:"date"`

	// User that added the note. Can be the customer or a third-party, like REVER. This is optional, but it's recommended. Integrators can guess the name of the app through the usage of the API key.
	User string `json:"user,omitempty"`

	// Arbitrary text associated to the order
	Text string `json:"text"`
}

Note - Note (text) associated to an order

type Option

type Option struct {

	// Name of the option
	Name string `json:"name"`

	// Value of the option
	Value string `json:"value"`
}

type Order

type Order struct {

	// Date when the Order was created in the e-commerce
	Date time.Time `json:"date"`

	// Indicates if the taxes should be displayed as included in the total amount of the order or separated
	TaxesIncluded bool `json:"taxes_included"`

	TotalAmount MultiMoney `json:"total_amount"`

	TotalTaxes MultiMoney `json:"total_taxes"`

	// List of fulfillment orders per items or groups of items in the order.
	FulfillmentOrders []FulfillmentOrder `json:"fulfillment_orders"`

	// List of returns already associated to the order
	Returns []ReturnOrder `json:"returns"`

	// List of refunds already associated to the order. Optional, only if OPM is supported.
	Refunds []RefundOrder `json:"refunds,omitempty"`

	Payment Payment `json:"payment"`

	Customer Customer `json:"customer"`

	Identification Identification `json:"identification,omitempty"`

	Shipping Shipping `json:"shipping"`

	// List of items in the order. It should only include products or services,  not shipping costs. When working with international orders, the customer currency and shop currency might be different. As REVER supports multicurrency, 2 currencies  can be specified per `line_item`. However, all of the `line_items` must have the same shop and  customer currency.
	LineItems []LineItem `json:"line_items"`

	ShippingAddress Address `json:"shipping_address"`

	BillingAddress Address `json:"billing_address"`

	// List of notes added to the order. The notes are ordered by date, the most recent one first. They can include orders from the customer or from other third-parties, like REVER.
	Notes []Note `json:"notes,omitempty"`
}

Order - Model for an Order returned by a custom REVER supports multi-currency with the following restrictions: * the shop currency must be the same for every order within the same e-commerce * there must be only one customer currency per order (it can be the same or not than the shop currency) In addition, discounts are supported as pre-tax calculations. Gift cards are not considered discounts but a payment method.

func FindOrderFor

func FindOrderFor(id string) *Order

FindOrderFor returns the order corresponding to the given id

func FindOrderWithRefunds

func FindOrderWithRefunds(id string, refunds refund.Refund) *Order

func OrderWithSingleProduct

func OrderWithSingleProduct(orderID string) *Order

OrderWithSingleProduct returns a simple order without variants, the vampire sunglasses

func SimpleOrderWithVariants

func SimpleOrderWithVariants(orderID string) *Order

SimpleOrderWithVariants returns the order corresponding to the given id

type ParsingError

type ParsingError struct {
	Err error
}

ParsingError indicates that an error has occurred when parsing request parameters

func (*ParsingError) Error

func (e *ParsingError) Error() string

func (*ParsingError) Unwrap

func (e *ParsingError) Unwrap() error

type Payment

type Payment struct {

	// Date when the payment for the whole order was made. This field should be present with a valid value if the order has been fully paid (not just partially).
	Date time.Time `json:"date"`

	// List of transactions executed as payment for the order.  If the order is `fully_paid`, then this list should have at least one element.
	Transactions []Transaction `json:"transactions"`
}

Payment - Payment information for the order

type Product

type Product struct {
	Categories []Category `json:"categories,omitempty"`

	// Product description
	Description string `json:"description,omitempty"`

	// Unique identifier for this resource in the source platform
	Id string `json:"id"`

	// Images associated to the product
	Images []Image `json:"images,omitempty"`

	// Product name
	Name string `json:"name"`

	UnitPrice ProductUnitPrice `json:"unit_price"`

	// Product short description
	ShortDescription string `json:"short_description,omitempty"`

	// stock-keeping unit (SKU) is a scannable bar code, most often seen printed on product labels in a retail store. Should be present if there are no variants.
	Sku string `json:"sku,omitempty"`

	// Optional inventory quantity. Overridden if there are variants defined. This field is not in use yet but it will be in the future for offering exchanges not based in  variants.
	InventoryQuantity int32 `json:"inventory_quantity,omitempty"`

	// Optional tags associated to the product. They can be used to mark it as non-returnable.
	Tags []Tag `json:"tags,omitempty"`

	// All of the available product variations (if any). This is useful for offering exchanges of variants. If a `line_item“ references a variation, the attributes of the variation have to be used instead of the ones of the product
	Variants []Variant `json:"variants,omitempty"`
}

Product - A product from the e-commerce catalog (enabled or not). Products that are removed from the catalog should still be available in the orders.

type ProductUnitPrice

type ProductUnitPrice struct {

	// amount (optionally with decimals), without currency symbol and thousands separator
	Amount float64 `json:"amount"`

	// three-letter code as ISO 4217 currency code.  Examples: EUR, USD, JPY, GBP... The currency must be supported by REVER.
	Currency string `json:"currency"`
}

ProductUnitPrice - Price per unit of the product in the shop currency. Must be present if there are no variants. Does not include taxes nor discounts. Those will be applied later on.

type Refund

type Refund struct {

	// ID of the line item returned. Must exist in the `line_items` array of the order.
	LineItemId string `json:"line_item_id"`

	// Number of products returned. The sum of quantities per `line_item_id` must match the total quantity of the line item.
	Quantity int32 `json:"quantity"`
}

Refund - A refund operation executed over one or more items of an order

type RefundError

type RefundError struct {

	// The error message.
	Error string `json:"error"`
}

RefundError - Error response for the method CreateRefund.

type RefundOrder

type RefundOrder struct {

	// An optional text associated to the refund order
	Description string `json:"description,omitempty"`

	// Date when the refund was executed
	Date time.Time `json:"date"`

	// Unique identifier of the refund order in the e-commerce
	RefundId string `json:"refund_id"`

	// Optional identifier of the gateway transaction associated (payment refund)
	TransactionId string `json:"transaction_id,omitempty"`

	Amount RefundOrderAmount `json:"amount"`

	// List of items refunded in this refund order
	Refunds []Refund `json:"refunds"`
}

RefundOrder - A refund operation executed over one or more items of an order.

type RefundOrderAmount

type RefundOrderAmount struct {

	// amount (optionally with decimals), without currency symbol and thousands separator
	Amount float64 `json:"amount"`

	// three-letter code as ISO 4217 currency code.  Examples: EUR, USD, JPY, GBP... The currency must be supported by REVER.
	Currency string `json:"currency"`
}

RefundOrderAmount - Amount of the refund, with currency associated. Must match the customer currency given in the `Order` object

type RefundRequest

type RefundRequest struct {

	// List of items to be refunded.
	Items []RefundRequestItem `json:"items"`
}

RefundRequest - Payload for the method CreateRefund.

type RefundRequestItem

type RefundRequestItem struct {

	// The unique identifier for the line item in the order.
	LineItemId string `json:"line_item_id"`

	// The quantity of the item to be refunded.
	Quantity int32 `json:"quantity"`

	Amount RefundRequestItemAmount `json:"amount"`
}

RefundRequestItem - Items from an order being to be refunded.

type RefundRequestItemAmount

type RefundRequestItemAmount struct {

	// amount (optionally with decimals), without currency symbol and thousands separator
	Amount float64 `json:"amount"`

	// three-letter code as ISO 4217 currency code.  Examples: EUR, USD, JPY, GBP... The currency must be supported by REVER.
	Currency string `json:"currency"`
}

RefundRequestItemAmount - The total amount to be refunded for this line item.

type RefundResponse

type RefundResponse struct {

	// The unique identifier for the refund in the e-commerce.
	RefundId string `json:"refund_id"`

	// The unique identifier for the transaction in the e-commerce.
	TransactionId string `json:"transaction_id,omitempty"`

	// List of items to be refunded.
	Items []RefundRequestItem `json:"items"`
}

RefundResponse - Items from an order being to be refunded.

type RequiredError

type RequiredError struct {
	Field string
}

RequiredError indicates that an error has occurred when parsing request parameters

func (*RequiredError) Error

func (e *RequiredError) Error() string

type Return

type Return struct {

	// ID of the line item returned. Must exist in the `line_items` array of the order.
	LineItemId string `json:"line_item_id"`

	// Number of products returned. The sum of quantities per `line_item_id` must match the total quantity of the line item.
	Quantity int32 `json:"quantity"`

	Status Status `json:"status"`
}

Return - A return operation executed over one or more items of an order. It might be in progress or successfully completed.

type ReturnOrder

type ReturnOrder struct {

	// An optional text associated to the return order
	Description string `json:"description,omitempty"`

	// Date when the return was executed
	Date time.Time `json:"date"`

	// Unique identifier of the return order
	ReturnId string `json:"return_id"`

	// List of items returned in this return order
	Returns []Return `json:"returns"`
}

ReturnOrder - A return operation executed over one or more items of an order. It might be in progress or successfully completed.

type ReturnRequest

type ReturnRequest struct {

	// List of items to mark (or unmark) as returned. Can't be empty.
	Returns []ReturnRequestItem `json:"returns"`
}

ReturnRequest - Payload for the method CreateReturn.

type ReturnRequestItem

type ReturnRequestItem struct {

	// The id of the line item from the order, corresponding to the product/variant being returned List of items to mark (or unmark) as returned
	LineItemId string `json:"line_item_id"`

	// Number of items from that line item being returned. It should be positive integer.
	Quantity int32 `json:"quantity"`

	Status Status `json:"status"`
}

ReturnRequestItem - Items from an order being marked as returned

type ReturnStatus

type ReturnStatus struct {

	// Status of the return which could be set to accepted or rejected by the ecommerce after the review.
	ReturnStatus string `json:"return_status,omitempty"`
}

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

A Route defines the parameters for an api endpoint

type Router

type Router interface {
	Routes() Routes
}

Router defines the required methods for retrieving api routes

func NewIntegrationApiController

func NewIntegrationApiController(s IntegrationApiServicer, opts ...IntegrationApiOption) Router

NewIntegrationApiController creates a default api controller

type Routes

type Routes []Route

Routes are a collection of defined api endpoints

type Shipping

type Shipping struct {

	// Text associated to the shipping line.
	Description string `json:"description,omitempty"`

	Taxes MultiMoney `json:"taxes"`

	Amount MultiMoney `json:"amount"`
}

Shipping - Shipping information

type Status

type Status struct {

	// Status of the return which could be set to accepted, rejected or missing by the ecommerce after the review.
	Status string `json:"status,omitempty"`
}

type Tag

type Tag struct {
	Name string `json:"name"`
}

Tag - a tag (string) associated to one resource

type Transaction

type Transaction struct {

	// Payment method used for this transaction. Any string can be returned in here, but some do have a special meaning and should have be preferred if possible:   - `manual`: the payment was made manually, outside of the e-commerce   - `cash-on-delivery`: the payment was made in cash when the order was delivered   - `bnpl`: the payment was made using a Buy Now Pay Later method   - `credit-card`: the payment was made using a credit card   - `debit-card`: the payment was made using a debit card   - `paypal`: the payment was made using PayPal   - `gift`: the payment was made using a gift card
	PaymentMethodType string `json:"payment_method_type"`

	// Identifier of the transaction in the payment gateway
	TransactionId string `json:"transaction_id"`

	Amount TransactionAmount `json:"amount"`

	// Date when the transaction was executed
	Date time.Time `json:"date"`
}

Transaction - Transaction executed as payment for an order

type TransactionAmount

type TransactionAmount struct {

	// amount (optionally with decimals), without currency symbol and thousands separator
	Amount float64 `json:"amount"`

	// three-letter code as ISO 4217 currency code.  Examples: EUR, USD, JPY, GBP... The currency must be supported by REVER.
	Currency string `json:"currency"`
}

TransactionAmount - Amount of the transaction, with currency associated. Must match the customer currency given in the `Order` object

type Variant

type Variant struct {

	// Variant description
	Description string `json:"description,omitempty"`

	// If this product variant should be selectable by the customer
	Enabled bool `json:"enabled"`

	// Unique identifier for the resource in the source platform
	Id string `json:"id"`

	// Images associated to the variant
	Images []Image `json:"images,omitempty"`

	// Optional inventory quantity. Replaces the one from the product. This information must be provided for offering exchanges based in variants. If you don't provide this information, it will be assumed that the variant is not available.
	InventoryQuantity int32 `json:"inventory_quantity,omitempty"`

	// Name of the variant
	Name string `json:"name"`

	// The list of options that conforms this variant
	Options []Option `json:"options"`

	UnitPrice VariantUnitPrice `json:"unit_price"`

	// Variant short description
	ShortDescription string `json:"short_description,omitempty"`

	// Optional unique identifier of the product as SKU. Replaces the one from the product.
	Sku string `json:"sku,omitempty"`

	// weight for this product variant, measured in grams. Replaces the one from the product.
	Weight int32 `json:"weight,omitempty"`
}

Variant - A variant of a product from the e-commerce catalog. It's the combination of one or more option values (e.g. size or size + color)

type VariantUnitPrice

type VariantUnitPrice struct {

	// amount (optionally with decimals), without currency symbol and thousands separator
	Amount float64 `json:"amount"`

	// three-letter code as ISO 4217 currency code.  Examples: EUR, USD, JPY, GBP... The currency must be supported by REVER.
	Currency string `json:"currency"`
}

VariantUnitPrice - Unit price in the shop currency. Does not include taxes nor discounts. Those will be applied later on.

Jump to

Keyboard shortcuts

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