// Package fbaOutbound provides primitives to interact the openapi HTTP API.
//
// Code generated by go-sdk-codegen DO NOT EDIT.
package fbaOutbound

import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	runt "runtime"
	"strings"

	"github.com/amzapi/selling-partner-api-sdk/pkg/runtime"
)

// RequestBeforeFn  is the function signature for the RequestBefore callback function
type RequestBeforeFn func(ctx context.Context, req *http.Request) error

// ResponseAfterFn  is the function signature for the ResponseAfter callback function
type ResponseAfterFn func(ctx context.Context, rsp *http.Response) error

// Doer performs HTTP requests.
//
// The standard http.Client implements this interface.
type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

// Client which conforms to the OpenAPI3 specification for this service.
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.
	Endpoint string

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

	// A callback for modifying requests which are generated before sending over
	// the network.
	RequestBefore RequestBeforeFn

	// A callback for modifying response which are generated before sending over
	// the network.
	ResponseAfter ResponseAfterFn

	// The user agent header identifies your application, its version number, and the platform and programming language you are using.
	// You must include a user agent header in each request submitted to the sales partner API.
	UserAgent string
}

// ClientOption allows setting custom parameters during construction
type ClientOption func(*Client) error

// Creates a new Client, with reasonable defaults
func NewClient(endpoint string, opts ...ClientOption) (*Client, error) {
	// create a client with sane default values
	client := Client{
		Endpoint: endpoint,
	}
	// mutate client and add all optional params
	for _, o := range opts {
		if err := o(&client); err != nil {
			return nil, err
		}
	}
	// ensure the endpoint URL always has a trailing slash
	if !strings.HasSuffix(client.Endpoint, "/") {
		client.Endpoint += "/"
	}
	// create httpClient, if not already present
	if client.Client == nil {
		client.Client = http.DefaultClient
	}
	// setting the default useragent
	if client.UserAgent == "" {
		client.UserAgent = fmt.Sprintf("selling-partner-api-sdk/v1.0 (Language=%s; Platform=%s-%s)", strings.Replace(runt.Version(), "go", "go/", -1), runt.GOOS, runt.GOARCH)
	}
	return &client, nil
}

// WithHTTPClient allows overriding the default Doer, which is
// automatically created using http.Client. This is useful for tests.
func WithHTTPClient(doer HttpRequestDoer) ClientOption {
	return func(c *Client) error {
		c.Client = doer
		return nil
	}
}

// WithUserAgent set up useragent
// add user agent to every request automatically
func WithUserAgent(userAgent string) ClientOption {
	return func(c *Client) error {
		c.UserAgent = userAgent
		return nil
	}
}

// WithRequestBefore allows setting up a callback function, which will be
// called right before sending the request. This can be used to mutate the request.
func WithRequestBefore(fn RequestBeforeFn) ClientOption {
	return func(c *Client) error {
		c.RequestBefore = fn
		return nil
	}
}

// WithResponseAfter allows setting up a callback function, which will be
// called right after get response the request. This can be used to log.
func WithResponseAfter(fn ResponseAfterFn) ClientOption {
	return func(c *Client) error {
		c.ResponseAfter = fn
		return nil
	}
}

// The interface specification for the client above.
type ClientInterface interface {
	// GetFeatures request
	GetFeatures(ctx context.Context, params *GetFeaturesParams) (*http.Response, error)

	// GetFeatureInventory request
	GetFeatureInventory(ctx context.Context, featureName string, params *GetFeatureInventoryParams) (*http.Response, error)

	// GetFeatureSKU request
	GetFeatureSKU(ctx context.Context, featureName string, sellerSku string, params *GetFeatureSKUParams) (*http.Response, error)

	// ListAllFulfillmentOrders request
	ListAllFulfillmentOrders(ctx context.Context, params *ListAllFulfillmentOrdersParams) (*http.Response, error)

	// CreateFulfillmentOrder request  with any body
	CreateFulfillmentOrderWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)

	CreateFulfillmentOrder(ctx context.Context, body CreateFulfillmentOrderJSONRequestBody) (*http.Response, error)

	// GetFulfillmentPreview request  with any body
	GetFulfillmentPreviewWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)

	GetFulfillmentPreview(ctx context.Context, body GetFulfillmentPreviewJSONRequestBody) (*http.Response, error)

	// GetFulfillmentOrder request
	GetFulfillmentOrder(ctx context.Context, sellerFulfillmentOrderId string) (*http.Response, error)

	// UpdateFulfillmentOrder request  with any body
	UpdateFulfillmentOrderWithBody(ctx context.Context, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*http.Response, error)

	UpdateFulfillmentOrder(ctx context.Context, sellerFulfillmentOrderId string, body UpdateFulfillmentOrderJSONRequestBody) (*http.Response, error)

	// CancelFulfillmentOrder request
	CancelFulfillmentOrder(ctx context.Context, sellerFulfillmentOrderId string) (*http.Response, error)

	// CreateFulfillmentReturn request  with any body
	CreateFulfillmentReturnWithBody(ctx context.Context, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*http.Response, error)

	CreateFulfillmentReturn(ctx context.Context, sellerFulfillmentOrderId string, body CreateFulfillmentReturnJSONRequestBody) (*http.Response, error)

	// ListReturnReasonCodes request
	ListReturnReasonCodes(ctx context.Context, params *ListReturnReasonCodesParams) (*http.Response, error)

	// GetPackageTrackingDetails request
	GetPackageTrackingDetails(ctx context.Context, params *GetPackageTrackingDetailsParams) (*http.Response, error)
}

func (c *Client) GetFeatures(ctx context.Context, params *GetFeaturesParams) (*http.Response, error) {
	req, err := NewGetFeaturesRequest(c.Endpoint, params)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) GetFeatureInventory(ctx context.Context, featureName string, params *GetFeatureInventoryParams) (*http.Response, error) {
	req, err := NewGetFeatureInventoryRequest(c.Endpoint, featureName, params)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) GetFeatureSKU(ctx context.Context, featureName string, sellerSku string, params *GetFeatureSKUParams) (*http.Response, error) {
	req, err := NewGetFeatureSKURequest(c.Endpoint, featureName, sellerSku, params)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) ListAllFulfillmentOrders(ctx context.Context, params *ListAllFulfillmentOrdersParams) (*http.Response, error) {
	req, err := NewListAllFulfillmentOrdersRequest(c.Endpoint, params)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) CreateFulfillmentOrderWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error) {
	req, err := NewCreateFulfillmentOrderRequestWithBody(c.Endpoint, contentType, body)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) CreateFulfillmentOrder(ctx context.Context, body CreateFulfillmentOrderJSONRequestBody) (*http.Response, error) {
	req, err := NewCreateFulfillmentOrderRequest(c.Endpoint, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}
	return c.Client.Do(req)
}

func (c *Client) GetFulfillmentPreviewWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error) {
	req, err := NewGetFulfillmentPreviewRequestWithBody(c.Endpoint, contentType, body)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) GetFulfillmentPreview(ctx context.Context, body GetFulfillmentPreviewJSONRequestBody) (*http.Response, error) {
	req, err := NewGetFulfillmentPreviewRequest(c.Endpoint, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}
	return c.Client.Do(req)
}

func (c *Client) GetFulfillmentOrder(ctx context.Context, sellerFulfillmentOrderId string) (*http.Response, error) {
	req, err := NewGetFulfillmentOrderRequest(c.Endpoint, sellerFulfillmentOrderId)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) UpdateFulfillmentOrderWithBody(ctx context.Context, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*http.Response, error) {
	req, err := NewUpdateFulfillmentOrderRequestWithBody(c.Endpoint, sellerFulfillmentOrderId, contentType, body)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) UpdateFulfillmentOrder(ctx context.Context, sellerFulfillmentOrderId string, body UpdateFulfillmentOrderJSONRequestBody) (*http.Response, error) {
	req, err := NewUpdateFulfillmentOrderRequest(c.Endpoint, sellerFulfillmentOrderId, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}
	return c.Client.Do(req)
}

func (c *Client) CancelFulfillmentOrder(ctx context.Context, sellerFulfillmentOrderId string) (*http.Response, error) {
	req, err := NewCancelFulfillmentOrderRequest(c.Endpoint, sellerFulfillmentOrderId)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) CreateFulfillmentReturnWithBody(ctx context.Context, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*http.Response, error) {
	req, err := NewCreateFulfillmentReturnRequestWithBody(c.Endpoint, sellerFulfillmentOrderId, contentType, body)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) CreateFulfillmentReturn(ctx context.Context, sellerFulfillmentOrderId string, body CreateFulfillmentReturnJSONRequestBody) (*http.Response, error) {
	req, err := NewCreateFulfillmentReturnRequest(c.Endpoint, sellerFulfillmentOrderId, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}
	return c.Client.Do(req)
}

func (c *Client) ListReturnReasonCodes(ctx context.Context, params *ListReturnReasonCodesParams) (*http.Response, error) {
	req, err := NewListReturnReasonCodesRequest(c.Endpoint, params)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

func (c *Client) GetPackageTrackingDetails(ctx context.Context, params *GetPackageTrackingDetailsParams) (*http.Response, error) {
	req, err := NewGetPackageTrackingDetailsRequest(c.Endpoint, params)
	if err != nil {
		return nil, err
	}

	req = req.WithContext(ctx)
	req.Header.Set("User-Agent", c.UserAgent)
	if c.RequestBefore != nil {
		err = c.RequestBefore(ctx, req)
		if err != nil {
			return nil, err
		}
	}

	rsp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}

	if c.ResponseAfter != nil {
		err = c.ResponseAfter(ctx, rsp)
		if err != nil {
			return nil, err
		}
	}
	return rsp, nil
}

// NewGetFeaturesRequest generates requests for GetFeatures
func NewGetFeaturesRequest(endpoint string, params *GetFeaturesParams) (*http.Request, error) {
	var err error

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/features")
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	queryValues := queryUrl.Query()

	if queryFrag, err := runtime.StyleParam("form", true, "marketplaceId", params.MarketplaceId); err != nil {
		return nil, err
	} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
		return nil, err
	} else {
		for k, v := range parsed {
			for _, v2 := range v {
				queryValues.Add(k, v2)
			}
		}
	}

	queryUrl.RawQuery = queryValues.Encode()

	req, err := http.NewRequest("GET", queryUrl.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewGetFeatureInventoryRequest generates requests for GetFeatureInventory
func NewGetFeatureInventoryRequest(endpoint string, featureName string, params *GetFeatureInventoryParams) (*http.Request, error) {
	var err error

	var pathParam0 string

	pathParam0, err = runtime.StyleParam("simple", false, "featureName", featureName)
	if err != nil {
		return nil, err
	}

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/features/inventory/%s", pathParam0)
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	queryValues := queryUrl.Query()

	if queryFrag, err := runtime.StyleParam("form", true, "marketplaceId", params.MarketplaceId); err != nil {
		return nil, err
	} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
		return nil, err
	} else {
		for k, v := range parsed {
			for _, v2 := range v {
				queryValues.Add(k, v2)
			}
		}
	}

	if params.NextToken != nil {

		if queryFrag, err := runtime.StyleParam("form", true, "nextToken", *params.NextToken); err != nil {
			return nil, err
		} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
			return nil, err
		} else {
			for k, v := range parsed {
				for _, v2 := range v {
					queryValues.Add(k, v2)
				}
			}
		}

	}

	queryUrl.RawQuery = queryValues.Encode()

	req, err := http.NewRequest("GET", queryUrl.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewGetFeatureSKURequest generates requests for GetFeatureSKU
func NewGetFeatureSKURequest(endpoint string, featureName string, sellerSku string, params *GetFeatureSKUParams) (*http.Request, error) {
	var err error

	var pathParam0 string

	pathParam0, err = runtime.StyleParam("simple", false, "featureName", featureName)
	if err != nil {
		return nil, err
	}

	var pathParam1 string

	pathParam1, err = runtime.StyleParam("simple", false, "sellerSku", sellerSku)
	if err != nil {
		return nil, err
	}

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/features/inventory/%s/%s", pathParam0, pathParam1)
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	queryValues := queryUrl.Query()

	if queryFrag, err := runtime.StyleParam("form", true, "marketplaceId", params.MarketplaceId); err != nil {
		return nil, err
	} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
		return nil, err
	} else {
		for k, v := range parsed {
			for _, v2 := range v {
				queryValues.Add(k, v2)
			}
		}
	}

	queryUrl.RawQuery = queryValues.Encode()

	req, err := http.NewRequest("GET", queryUrl.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewListAllFulfillmentOrdersRequest generates requests for ListAllFulfillmentOrders
func NewListAllFulfillmentOrdersRequest(endpoint string, params *ListAllFulfillmentOrdersParams) (*http.Request, error) {
	var err error

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/fulfillmentOrders")
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	queryValues := queryUrl.Query()

	if params.QueryStartDate != nil {

		if queryFrag, err := runtime.StyleParam("form", true, "queryStartDate", *params.QueryStartDate); err != nil {
			return nil, err
		} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
			return nil, err
		} else {
			for k, v := range parsed {
				for _, v2 := range v {
					queryValues.Add(k, v2)
				}
			}
		}

	}

	if params.NextToken != nil {

		if queryFrag, err := runtime.StyleParam("form", true, "nextToken", *params.NextToken); err != nil {
			return nil, err
		} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
			return nil, err
		} else {
			for k, v := range parsed {
				for _, v2 := range v {
					queryValues.Add(k, v2)
				}
			}
		}

	}

	queryUrl.RawQuery = queryValues.Encode()

	req, err := http.NewRequest("GET", queryUrl.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewCreateFulfillmentOrderRequest calls the generic CreateFulfillmentOrder builder with application/json body
func NewCreateFulfillmentOrderRequest(endpoint string, body CreateFulfillmentOrderJSONRequestBody) (*http.Request, error) {
	var bodyReader io.Reader
	buf, err := json.Marshal(body)
	if err != nil {
		return nil, err
	}
	bodyReader = bytes.NewReader(buf)
	return NewCreateFulfillmentOrderRequestWithBody(endpoint, "application/json", bodyReader)
}

// NewCreateFulfillmentOrderRequestWithBody generates requests for CreateFulfillmentOrder with any type of body
func NewCreateFulfillmentOrderRequestWithBody(endpoint string, contentType string, body io.Reader) (*http.Request, error) {
	var err error

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/fulfillmentOrders")
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("POST", queryUrl.String(), body)
	if err != nil {
		return nil, err
	}

	req.Header.Add("Content-Type", contentType)
	return req, nil
}

// NewGetFulfillmentPreviewRequest calls the generic GetFulfillmentPreview builder with application/json body
func NewGetFulfillmentPreviewRequest(endpoint string, body GetFulfillmentPreviewJSONRequestBody) (*http.Request, error) {
	var bodyReader io.Reader
	buf, err := json.Marshal(body)
	if err != nil {
		return nil, err
	}
	bodyReader = bytes.NewReader(buf)
	return NewGetFulfillmentPreviewRequestWithBody(endpoint, "application/json", bodyReader)
}

// NewGetFulfillmentPreviewRequestWithBody generates requests for GetFulfillmentPreview with any type of body
func NewGetFulfillmentPreviewRequestWithBody(endpoint string, contentType string, body io.Reader) (*http.Request, error) {
	var err error

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/fulfillmentOrders/preview")
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("POST", queryUrl.String(), body)
	if err != nil {
		return nil, err
	}

	req.Header.Add("Content-Type", contentType)
	return req, nil
}

// NewGetFulfillmentOrderRequest generates requests for GetFulfillmentOrder
func NewGetFulfillmentOrderRequest(endpoint string, sellerFulfillmentOrderId string) (*http.Request, error) {
	var err error

	var pathParam0 string

	pathParam0, err = runtime.StyleParam("simple", false, "sellerFulfillmentOrderId", sellerFulfillmentOrderId)
	if err != nil {
		return nil, err
	}

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/fulfillmentOrders/%s", pathParam0)
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("GET", queryUrl.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewUpdateFulfillmentOrderRequest calls the generic UpdateFulfillmentOrder builder with application/json body
func NewUpdateFulfillmentOrderRequest(endpoint string, sellerFulfillmentOrderId string, body UpdateFulfillmentOrderJSONRequestBody) (*http.Request, error) {
	var bodyReader io.Reader
	buf, err := json.Marshal(body)
	if err != nil {
		return nil, err
	}
	bodyReader = bytes.NewReader(buf)
	return NewUpdateFulfillmentOrderRequestWithBody(endpoint, sellerFulfillmentOrderId, "application/json", bodyReader)
}

// NewUpdateFulfillmentOrderRequestWithBody generates requests for UpdateFulfillmentOrder with any type of body
func NewUpdateFulfillmentOrderRequestWithBody(endpoint string, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*http.Request, error) {
	var err error

	var pathParam0 string

	pathParam0, err = runtime.StyleParam("simple", false, "sellerFulfillmentOrderId", sellerFulfillmentOrderId)
	if err != nil {
		return nil, err
	}

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/fulfillmentOrders/%s", pathParam0)
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("PUT", queryUrl.String(), body)
	if err != nil {
		return nil, err
	}

	req.Header.Add("Content-Type", contentType)
	return req, nil
}

// NewCancelFulfillmentOrderRequest generates requests for CancelFulfillmentOrder
func NewCancelFulfillmentOrderRequest(endpoint string, sellerFulfillmentOrderId string) (*http.Request, error) {
	var err error

	var pathParam0 string

	pathParam0, err = runtime.StyleParam("simple", false, "sellerFulfillmentOrderId", sellerFulfillmentOrderId)
	if err != nil {
		return nil, err
	}

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/fulfillmentOrders/%s/cancel", pathParam0)
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("PUT", queryUrl.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewCreateFulfillmentReturnRequest calls the generic CreateFulfillmentReturn builder with application/json body
func NewCreateFulfillmentReturnRequest(endpoint string, sellerFulfillmentOrderId string, body CreateFulfillmentReturnJSONRequestBody) (*http.Request, error) {
	var bodyReader io.Reader
	buf, err := json.Marshal(body)
	if err != nil {
		return nil, err
	}
	bodyReader = bytes.NewReader(buf)
	return NewCreateFulfillmentReturnRequestWithBody(endpoint, sellerFulfillmentOrderId, "application/json", bodyReader)
}

// NewCreateFulfillmentReturnRequestWithBody generates requests for CreateFulfillmentReturn with any type of body
func NewCreateFulfillmentReturnRequestWithBody(endpoint string, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*http.Request, error) {
	var err error

	var pathParam0 string

	pathParam0, err = runtime.StyleParam("simple", false, "sellerFulfillmentOrderId", sellerFulfillmentOrderId)
	if err != nil {
		return nil, err
	}

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/fulfillmentOrders/%s/return", pathParam0)
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("PUT", queryUrl.String(), body)
	if err != nil {
		return nil, err
	}

	req.Header.Add("Content-Type", contentType)
	return req, nil
}

// NewListReturnReasonCodesRequest generates requests for ListReturnReasonCodes
func NewListReturnReasonCodesRequest(endpoint string, params *ListReturnReasonCodesParams) (*http.Request, error) {
	var err error

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/returnReasonCodes")
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	queryValues := queryUrl.Query()

	if queryFrag, err := runtime.StyleParam("form", true, "sellerSku", params.SellerSku); err != nil {
		return nil, err
	} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
		return nil, err
	} else {
		for k, v := range parsed {
			for _, v2 := range v {
				queryValues.Add(k, v2)
			}
		}
	}

	if params.MarketplaceId != nil {

		if queryFrag, err := runtime.StyleParam("form", true, "marketplaceId", *params.MarketplaceId); err != nil {
			return nil, err
		} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
			return nil, err
		} else {
			for k, v := range parsed {
				for _, v2 := range v {
					queryValues.Add(k, v2)
				}
			}
		}

	}

	if params.SellerFulfillmentOrderId != nil {

		if queryFrag, err := runtime.StyleParam("form", true, "sellerFulfillmentOrderId", *params.SellerFulfillmentOrderId); err != nil {
			return nil, err
		} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
			return nil, err
		} else {
			for k, v := range parsed {
				for _, v2 := range v {
					queryValues.Add(k, v2)
				}
			}
		}

	}

	if queryFrag, err := runtime.StyleParam("form", true, "language", params.Language); err != nil {
		return nil, err
	} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
		return nil, err
	} else {
		for k, v := range parsed {
			for _, v2 := range v {
				queryValues.Add(k, v2)
			}
		}
	}

	queryUrl.RawQuery = queryValues.Encode()

	req, err := http.NewRequest("GET", queryUrl.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewGetPackageTrackingDetailsRequest generates requests for GetPackageTrackingDetails
func NewGetPackageTrackingDetailsRequest(endpoint string, params *GetPackageTrackingDetailsParams) (*http.Request, error) {
	var err error

	queryUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, err
	}

	basePath := fmt.Sprintf("/fba/outbound/2020-07-01/tracking")
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

	queryUrl, err = queryUrl.Parse(basePath)
	if err != nil {
		return nil, err
	}

	queryValues := queryUrl.Query()

	if queryFrag, err := runtime.StyleParam("form", true, "packageNumber", params.PackageNumber); err != nil {
		return nil, err
	} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
		return nil, err
	} else {
		for k, v := range parsed {
			for _, v2 := range v {
				queryValues.Add(k, v2)
			}
		}
	}

	queryUrl.RawQuery = queryValues.Encode()

	req, err := http.NewRequest("GET", queryUrl.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// ClientWithResponses builds on ClientInterface to offer response payloads
type ClientWithResponses struct {
	ClientInterface
}

// NewClientWithResponses creates a new ClientWithResponses, which wraps
// Client with return type handling
func NewClientWithResponses(endpoint string, opts ...ClientOption) (*ClientWithResponses, error) {
	client, err := NewClient(endpoint, opts...)
	if err != nil {
		return nil, err
	}
	return &ClientWithResponses{client}, nil
}

// WithBaseURL overrides the baseURL.
func WithBaseURL(baseURL string) ClientOption {
	return func(c *Client) error {
		newBaseURL, err := url.Parse(baseURL)
		if err != nil {
			return err
		}
		c.Endpoint = newBaseURL.String()
		return nil
	}
}

// ClientWithResponsesInterface is the interface specification for the client with responses above.
type ClientWithResponsesInterface interface {
	// GetFeatures request
	GetFeaturesWithResponse(ctx context.Context, params *GetFeaturesParams) (*GetFeaturesResp, error)

	// GetFeatureInventory request
	GetFeatureInventoryWithResponse(ctx context.Context, featureName string, params *GetFeatureInventoryParams) (*GetFeatureInventoryResp, error)

	// GetFeatureSKU request
	GetFeatureSKUWithResponse(ctx context.Context, featureName string, sellerSku string, params *GetFeatureSKUParams) (*GetFeatureSKUResp, error)

	// ListAllFulfillmentOrders request
	ListAllFulfillmentOrdersWithResponse(ctx context.Context, params *ListAllFulfillmentOrdersParams) (*ListAllFulfillmentOrdersResp, error)

	// CreateFulfillmentOrder request  with any body
	CreateFulfillmentOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*CreateFulfillmentOrderResp, error)

	CreateFulfillmentOrderWithResponse(ctx context.Context, body CreateFulfillmentOrderJSONRequestBody) (*CreateFulfillmentOrderResp, error)

	// GetFulfillmentPreview request  with any body
	GetFulfillmentPreviewWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*GetFulfillmentPreviewResp, error)

	GetFulfillmentPreviewWithResponse(ctx context.Context, body GetFulfillmentPreviewJSONRequestBody) (*GetFulfillmentPreviewResp, error)

	// GetFulfillmentOrder request
	GetFulfillmentOrderWithResponse(ctx context.Context, sellerFulfillmentOrderId string) (*GetFulfillmentOrderResp, error)

	// UpdateFulfillmentOrder request  with any body
	UpdateFulfillmentOrderWithBodyWithResponse(ctx context.Context, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*UpdateFulfillmentOrderResp, error)

	UpdateFulfillmentOrderWithResponse(ctx context.Context, sellerFulfillmentOrderId string, body UpdateFulfillmentOrderJSONRequestBody) (*UpdateFulfillmentOrderResp, error)

	// CancelFulfillmentOrder request
	CancelFulfillmentOrderWithResponse(ctx context.Context, sellerFulfillmentOrderId string) (*CancelFulfillmentOrderResp, error)

	// CreateFulfillmentReturn request  with any body
	CreateFulfillmentReturnWithBodyWithResponse(ctx context.Context, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*CreateFulfillmentReturnResp, error)

	CreateFulfillmentReturnWithResponse(ctx context.Context, sellerFulfillmentOrderId string, body CreateFulfillmentReturnJSONRequestBody) (*CreateFulfillmentReturnResp, error)

	// ListReturnReasonCodes request
	ListReturnReasonCodesWithResponse(ctx context.Context, params *ListReturnReasonCodesParams) (*ListReturnReasonCodesResp, error)

	// GetPackageTrackingDetails request
	GetPackageTrackingDetailsWithResponse(ctx context.Context, params *GetPackageTrackingDetailsParams) (*GetPackageTrackingDetailsResp, error)
}

type GetFeaturesResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetFeaturesResponse
}

// Status returns HTTPResponse.Status
func (r GetFeaturesResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r GetFeaturesResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type GetFeatureInventoryResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetFeatureInventoryResponse
}

// Status returns HTTPResponse.Status
func (r GetFeatureInventoryResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r GetFeatureInventoryResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type GetFeatureSKUResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetFeatureSkuResponse
}

// Status returns HTTPResponse.Status
func (r GetFeatureSKUResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r GetFeatureSKUResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type ListAllFulfillmentOrdersResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *ListAllFulfillmentOrdersResponse
}

// Status returns HTTPResponse.Status
func (r ListAllFulfillmentOrdersResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r ListAllFulfillmentOrdersResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type CreateFulfillmentOrderResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *CreateFulfillmentOrderResponse
}

// Status returns HTTPResponse.Status
func (r CreateFulfillmentOrderResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r CreateFulfillmentOrderResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type GetFulfillmentPreviewResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetFulfillmentPreviewResponse
}

// Status returns HTTPResponse.Status
func (r GetFulfillmentPreviewResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r GetFulfillmentPreviewResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type GetFulfillmentOrderResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetFulfillmentOrderResponse
}

// Status returns HTTPResponse.Status
func (r GetFulfillmentOrderResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r GetFulfillmentOrderResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type UpdateFulfillmentOrderResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *UpdateFulfillmentOrderResponse
}

// Status returns HTTPResponse.Status
func (r UpdateFulfillmentOrderResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r UpdateFulfillmentOrderResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type CancelFulfillmentOrderResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *CancelFulfillmentOrderResponse
}

// Status returns HTTPResponse.Status
func (r CancelFulfillmentOrderResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r CancelFulfillmentOrderResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type CreateFulfillmentReturnResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *CreateFulfillmentReturnResponse
}

// Status returns HTTPResponse.Status
func (r CreateFulfillmentReturnResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r CreateFulfillmentReturnResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type ListReturnReasonCodesResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *ListReturnReasonCodesResponse
}

// Status returns HTTPResponse.Status
func (r ListReturnReasonCodesResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r ListReturnReasonCodesResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type GetPackageTrackingDetailsResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetPackageTrackingDetailsResponse
}

// Status returns HTTPResponse.Status
func (r GetPackageTrackingDetailsResp) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r GetPackageTrackingDetailsResp) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

// GetFeaturesWithResponse request returning *GetFeaturesResponse
func (c *ClientWithResponses) GetFeaturesWithResponse(ctx context.Context, params *GetFeaturesParams) (*GetFeaturesResp, error) {
	rsp, err := c.GetFeatures(ctx, params)
	if err != nil {
		return nil, err
	}
	return ParseGetFeaturesResp(rsp)
}

// GetFeatureInventoryWithResponse request returning *GetFeatureInventoryResponse
func (c *ClientWithResponses) GetFeatureInventoryWithResponse(ctx context.Context, featureName string, params *GetFeatureInventoryParams) (*GetFeatureInventoryResp, error) {
	rsp, err := c.GetFeatureInventory(ctx, featureName, params)
	if err != nil {
		return nil, err
	}
	return ParseGetFeatureInventoryResp(rsp)
}

// GetFeatureSKUWithResponse request returning *GetFeatureSKUResponse
func (c *ClientWithResponses) GetFeatureSKUWithResponse(ctx context.Context, featureName string, sellerSku string, params *GetFeatureSKUParams) (*GetFeatureSKUResp, error) {
	rsp, err := c.GetFeatureSKU(ctx, featureName, sellerSku, params)
	if err != nil {
		return nil, err
	}
	return ParseGetFeatureSKUResp(rsp)
}

// ListAllFulfillmentOrdersWithResponse request returning *ListAllFulfillmentOrdersResponse
func (c *ClientWithResponses) ListAllFulfillmentOrdersWithResponse(ctx context.Context, params *ListAllFulfillmentOrdersParams) (*ListAllFulfillmentOrdersResp, error) {
	rsp, err := c.ListAllFulfillmentOrders(ctx, params)
	if err != nil {
		return nil, err
	}
	return ParseListAllFulfillmentOrdersResp(rsp)
}

// CreateFulfillmentOrderWithBodyWithResponse request with arbitrary body returning *CreateFulfillmentOrderResponse
func (c *ClientWithResponses) CreateFulfillmentOrderWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*CreateFulfillmentOrderResp, error) {
	rsp, err := c.CreateFulfillmentOrderWithBody(ctx, contentType, body)
	if err != nil {
		return nil, err
	}
	return ParseCreateFulfillmentOrderResp(rsp)
}

func (c *ClientWithResponses) CreateFulfillmentOrderWithResponse(ctx context.Context, body CreateFulfillmentOrderJSONRequestBody) (*CreateFulfillmentOrderResp, error) {
	rsp, err := c.CreateFulfillmentOrder(ctx, body)
	if err != nil {
		return nil, err
	}
	return ParseCreateFulfillmentOrderResp(rsp)
}

// GetFulfillmentPreviewWithBodyWithResponse request with arbitrary body returning *GetFulfillmentPreviewResponse
func (c *ClientWithResponses) GetFulfillmentPreviewWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*GetFulfillmentPreviewResp, error) {
	rsp, err := c.GetFulfillmentPreviewWithBody(ctx, contentType, body)
	if err != nil {
		return nil, err
	}
	return ParseGetFulfillmentPreviewResp(rsp)
}

func (c *ClientWithResponses) GetFulfillmentPreviewWithResponse(ctx context.Context, body GetFulfillmentPreviewJSONRequestBody) (*GetFulfillmentPreviewResp, error) {
	rsp, err := c.GetFulfillmentPreview(ctx, body)
	if err != nil {
		return nil, err
	}
	return ParseGetFulfillmentPreviewResp(rsp)
}

// GetFulfillmentOrderWithResponse request returning *GetFulfillmentOrderResponse
func (c *ClientWithResponses) GetFulfillmentOrderWithResponse(ctx context.Context, sellerFulfillmentOrderId string) (*GetFulfillmentOrderResp, error) {
	rsp, err := c.GetFulfillmentOrder(ctx, sellerFulfillmentOrderId)
	if err != nil {
		return nil, err
	}
	return ParseGetFulfillmentOrderResp(rsp)
}

// UpdateFulfillmentOrderWithBodyWithResponse request with arbitrary body returning *UpdateFulfillmentOrderResponse
func (c *ClientWithResponses) UpdateFulfillmentOrderWithBodyWithResponse(ctx context.Context, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*UpdateFulfillmentOrderResp, error) {
	rsp, err := c.UpdateFulfillmentOrderWithBody(ctx, sellerFulfillmentOrderId, contentType, body)
	if err != nil {
		return nil, err
	}
	return ParseUpdateFulfillmentOrderResp(rsp)
}

func (c *ClientWithResponses) UpdateFulfillmentOrderWithResponse(ctx context.Context, sellerFulfillmentOrderId string, body UpdateFulfillmentOrderJSONRequestBody) (*UpdateFulfillmentOrderResp, error) {
	rsp, err := c.UpdateFulfillmentOrder(ctx, sellerFulfillmentOrderId, body)
	if err != nil {
		return nil, err
	}
	return ParseUpdateFulfillmentOrderResp(rsp)
}

// CancelFulfillmentOrderWithResponse request returning *CancelFulfillmentOrderResponse
func (c *ClientWithResponses) CancelFulfillmentOrderWithResponse(ctx context.Context, sellerFulfillmentOrderId string) (*CancelFulfillmentOrderResp, error) {
	rsp, err := c.CancelFulfillmentOrder(ctx, sellerFulfillmentOrderId)
	if err != nil {
		return nil, err
	}
	return ParseCancelFulfillmentOrderResp(rsp)
}

// CreateFulfillmentReturnWithBodyWithResponse request with arbitrary body returning *CreateFulfillmentReturnResponse
func (c *ClientWithResponses) CreateFulfillmentReturnWithBodyWithResponse(ctx context.Context, sellerFulfillmentOrderId string, contentType string, body io.Reader) (*CreateFulfillmentReturnResp, error) {
	rsp, err := c.CreateFulfillmentReturnWithBody(ctx, sellerFulfillmentOrderId, contentType, body)
	if err != nil {
		return nil, err
	}
	return ParseCreateFulfillmentReturnResp(rsp)
}

func (c *ClientWithResponses) CreateFulfillmentReturnWithResponse(ctx context.Context, sellerFulfillmentOrderId string, body CreateFulfillmentReturnJSONRequestBody) (*CreateFulfillmentReturnResp, error) {
	rsp, err := c.CreateFulfillmentReturn(ctx, sellerFulfillmentOrderId, body)
	if err != nil {
		return nil, err
	}
	return ParseCreateFulfillmentReturnResp(rsp)
}

// ListReturnReasonCodesWithResponse request returning *ListReturnReasonCodesResponse
func (c *ClientWithResponses) ListReturnReasonCodesWithResponse(ctx context.Context, params *ListReturnReasonCodesParams) (*ListReturnReasonCodesResp, error) {
	rsp, err := c.ListReturnReasonCodes(ctx, params)
	if err != nil {
		return nil, err
	}
	return ParseListReturnReasonCodesResp(rsp)
}

// GetPackageTrackingDetailsWithResponse request returning *GetPackageTrackingDetailsResponse
func (c *ClientWithResponses) GetPackageTrackingDetailsWithResponse(ctx context.Context, params *GetPackageTrackingDetailsParams) (*GetPackageTrackingDetailsResp, error) {
	rsp, err := c.GetPackageTrackingDetails(ctx, params)
	if err != nil {
		return nil, err
	}
	return ParseGetPackageTrackingDetailsResp(rsp)
}

// ParseGetFeaturesResp parses an HTTP response from a GetFeaturesWithResponse call
func ParseGetFeaturesResp(rsp *http.Response) (*GetFeaturesResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &GetFeaturesResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest GetFeaturesResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseGetFeatureInventoryResp parses an HTTP response from a GetFeatureInventoryWithResponse call
func ParseGetFeatureInventoryResp(rsp *http.Response) (*GetFeatureInventoryResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &GetFeatureInventoryResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest GetFeatureInventoryResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseGetFeatureSKUResp parses an HTTP response from a GetFeatureSKUWithResponse call
func ParseGetFeatureSKUResp(rsp *http.Response) (*GetFeatureSKUResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &GetFeatureSKUResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest GetFeatureSkuResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseListAllFulfillmentOrdersResp parses an HTTP response from a ListAllFulfillmentOrdersWithResponse call
func ParseListAllFulfillmentOrdersResp(rsp *http.Response) (*ListAllFulfillmentOrdersResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &ListAllFulfillmentOrdersResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest ListAllFulfillmentOrdersResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseCreateFulfillmentOrderResp parses an HTTP response from a CreateFulfillmentOrderWithResponse call
func ParseCreateFulfillmentOrderResp(rsp *http.Response) (*CreateFulfillmentOrderResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &CreateFulfillmentOrderResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest CreateFulfillmentOrderResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseGetFulfillmentPreviewResp parses an HTTP response from a GetFulfillmentPreviewWithResponse call
func ParseGetFulfillmentPreviewResp(rsp *http.Response) (*GetFulfillmentPreviewResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &GetFulfillmentPreviewResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest GetFulfillmentPreviewResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseGetFulfillmentOrderResp parses an HTTP response from a GetFulfillmentOrderWithResponse call
func ParseGetFulfillmentOrderResp(rsp *http.Response) (*GetFulfillmentOrderResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &GetFulfillmentOrderResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest GetFulfillmentOrderResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseUpdateFulfillmentOrderResp parses an HTTP response from a UpdateFulfillmentOrderWithResponse call
func ParseUpdateFulfillmentOrderResp(rsp *http.Response) (*UpdateFulfillmentOrderResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &UpdateFulfillmentOrderResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest UpdateFulfillmentOrderResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseCancelFulfillmentOrderResp parses an HTTP response from a CancelFulfillmentOrderWithResponse call
func ParseCancelFulfillmentOrderResp(rsp *http.Response) (*CancelFulfillmentOrderResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &CancelFulfillmentOrderResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest CancelFulfillmentOrderResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseCreateFulfillmentReturnResp parses an HTTP response from a CreateFulfillmentReturnWithResponse call
func ParseCreateFulfillmentReturnResp(rsp *http.Response) (*CreateFulfillmentReturnResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &CreateFulfillmentReturnResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest CreateFulfillmentReturnResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseListReturnReasonCodesResp parses an HTTP response from a ListReturnReasonCodesWithResponse call
func ParseListReturnReasonCodesResp(rsp *http.Response) (*ListReturnReasonCodesResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &ListReturnReasonCodesResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest ListReturnReasonCodesResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}

// ParseGetPackageTrackingDetailsResp parses an HTTP response from a GetPackageTrackingDetailsWithResponse call
func ParseGetPackageTrackingDetailsResp(rsp *http.Response) (*GetPackageTrackingDetailsResp, error) {
	bodyBytes, err := ioutil.ReadAll(rsp.Body)
	defer rsp.Body.Close()
	if err != nil {
		return nil, err
	}

	response := &GetPackageTrackingDetailsResp{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	var dest GetPackageTrackingDetailsResponse
	if err := json.Unmarshal(bodyBytes, &dest); err != nil {
		return nil, err
	}

	response.Model = &dest

	if rsp.StatusCode >= 300 {
		err = fmt.Errorf(rsp.Status)
	}

	return response, err
}
