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

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 {
	// GetDestinations request
	GetDestinations(ctx context.Context) (*http.Response, error)

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

	CreateDestination(ctx context.Context, body CreateDestinationJSONRequestBody) (*http.Response, error)

	// DeleteDestination request
	DeleteDestination(ctx context.Context, destinationId string) (*http.Response, error)

	// GetDestination request
	GetDestination(ctx context.Context, destinationId string) (*http.Response, error)

	// GetSubscription request
	GetSubscription(ctx context.Context, notificationType NotificationType) (*http.Response, error)

	// CreateSubscription request  with any body
	CreateSubscriptionWithBody(ctx context.Context, notificationType NotificationType, contentType string, body io.Reader) (*http.Response, error)

	CreateSubscription(ctx context.Context, notificationType NotificationType, body CreateSubscriptionJSONRequestBody) (*http.Response, error)

	// DeleteSubscriptionById request
	DeleteSubscriptionById(ctx context.Context, notificationType NotificationType, subscriptionId string) (*http.Response, error)

	// GetSubscriptionById request
	GetSubscriptionById(ctx context.Context, notificationType NotificationType, subscriptionId string) (*http.Response, error)
}

func (c *Client) GetDestinations(ctx context.Context) (*http.Response, error) {
	req, err := NewGetDestinationsRequest(c.Endpoint)
	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) CreateDestinationWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error) {
	req, err := NewCreateDestinationRequestWithBody(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) CreateDestination(ctx context.Context, body CreateDestinationJSONRequestBody) (*http.Response, error) {
	req, err := NewCreateDestinationRequest(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) DeleteDestination(ctx context.Context, destinationId string) (*http.Response, error) {
	req, err := NewDeleteDestinationRequest(c.Endpoint, destinationId)
	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) GetDestination(ctx context.Context, destinationId string) (*http.Response, error) {
	req, err := NewGetDestinationRequest(c.Endpoint, destinationId)
	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) GetSubscription(ctx context.Context, notificationType NotificationType) (*http.Response, error) {
	req, err := NewGetSubscriptionRequest(c.Endpoint, notificationType)
	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) CreateSubscriptionWithBody(ctx context.Context, notificationType NotificationType, contentType string, body io.Reader) (*http.Response, error) {
	req, err := NewCreateSubscriptionRequestWithBody(c.Endpoint, notificationType, 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) CreateSubscription(ctx context.Context, notificationType NotificationType, body CreateSubscriptionJSONRequestBody) (*http.Response, error) {
	req, err := NewCreateSubscriptionRequest(c.Endpoint, notificationType, 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) DeleteSubscriptionById(ctx context.Context, notificationType NotificationType, subscriptionId string) (*http.Response, error) {
	req, err := NewDeleteSubscriptionByIdRequest(c.Endpoint, notificationType, subscriptionId)
	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) GetSubscriptionById(ctx context.Context, notificationType NotificationType, subscriptionId string) (*http.Response, error) {
	req, err := NewGetSubscriptionByIdRequest(c.Endpoint, notificationType, subscriptionId)
	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
}

// NewGetDestinationsRequest generates requests for GetDestinations
func NewGetDestinationsRequest(endpoint string) (*http.Request, error) {
	var err error

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

	basePath := fmt.Sprintf("/notifications/v1/destinations")
	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
}

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

// NewCreateDestinationRequestWithBody generates requests for CreateDestination with any type of body
func NewCreateDestinationRequestWithBody(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("/notifications/v1/destinations")
	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
}

// NewDeleteDestinationRequest generates requests for DeleteDestination
func NewDeleteDestinationRequest(endpoint string, destinationId string) (*http.Request, error) {
	var err error

	var pathParam0 string

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

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

	basePath := fmt.Sprintf("/notifications/v1/destinations/%s", pathParam0)
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

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

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

	return req, nil
}

// NewGetDestinationRequest generates requests for GetDestination
func NewGetDestinationRequest(endpoint string, destinationId string) (*http.Request, error) {
	var err error

	var pathParam0 string

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

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

	basePath := fmt.Sprintf("/notifications/v1/destinations/%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
}

// NewGetSubscriptionRequest generates requests for GetSubscription
func NewGetSubscriptionRequest(endpoint string, notificationType NotificationType) (*http.Request, error) {
	var err error

	var pathParam0 string

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

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

	basePath := fmt.Sprintf("/notifications/v1/subscriptions/%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
}

// NewCreateSubscriptionRequest calls the generic CreateSubscription builder with application/json body
func NewCreateSubscriptionRequest(endpoint string, notificationType NotificationType, body CreateSubscriptionJSONRequestBody) (*http.Request, error) {
	var bodyReader io.Reader
	buf, err := json.Marshal(body)
	if err != nil {
		return nil, err
	}
	bodyReader = bytes.NewReader(buf)
	return NewCreateSubscriptionRequestWithBody(endpoint, notificationType, "application/json", bodyReader)
}

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

	var pathParam0 string

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

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

	basePath := fmt.Sprintf("/notifications/v1/subscriptions/%s", pathParam0)
	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
}

// NewDeleteSubscriptionByIdRequest generates requests for DeleteSubscriptionById
func NewDeleteSubscriptionByIdRequest(endpoint string, notificationType NotificationType, subscriptionId string) (*http.Request, error) {
	var err error

	var pathParam0 string

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

	var pathParam1 string

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

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

	basePath := fmt.Sprintf("/notifications/v1/subscriptions/%s/%s", pathParam0, pathParam1)
	if basePath[0] == '/' {
		basePath = basePath[1:]
	}

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

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

	return req, nil
}

// NewGetSubscriptionByIdRequest generates requests for GetSubscriptionById
func NewGetSubscriptionByIdRequest(endpoint string, notificationType NotificationType, subscriptionId string) (*http.Request, error) {
	var err error

	var pathParam0 string

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

	var pathParam1 string

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

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

	basePath := fmt.Sprintf("/notifications/v1/subscriptions/%s/%s", pathParam0, pathParam1)
	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
}

// 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 {
	// GetDestinations request
	GetDestinationsWithResponse(ctx context.Context) (*GetDestinationsResp, error)

	// CreateDestination request  with any body
	CreateDestinationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*CreateDestinationResp, error)

	CreateDestinationWithResponse(ctx context.Context, body CreateDestinationJSONRequestBody) (*CreateDestinationResp, error)

	// DeleteDestination request
	DeleteDestinationWithResponse(ctx context.Context, destinationId string) (*DeleteDestinationResp, error)

	// GetDestination request
	GetDestinationWithResponse(ctx context.Context, destinationId string) (*GetDestinationResp, error)

	// GetSubscription request
	GetSubscriptionWithResponse(ctx context.Context, notificationType NotificationType) (*GetSubscriptionResp, error)

	// CreateSubscription request  with any body
	CreateSubscriptionWithBodyWithResponse(ctx context.Context, notificationType NotificationType, contentType string, body io.Reader) (*CreateSubscriptionResp, error)

	CreateSubscriptionWithResponse(ctx context.Context, notificationType NotificationType, body CreateSubscriptionJSONRequestBody) (*CreateSubscriptionResp, error)

	// DeleteSubscriptionById request
	DeleteSubscriptionByIdWithResponse(ctx context.Context, notificationType NotificationType, subscriptionId string) (*DeleteSubscriptionByIdResp, error)

	// GetSubscriptionById request
	GetSubscriptionByIdWithResponse(ctx context.Context, notificationType NotificationType, subscriptionId string) (*GetSubscriptionByIdResp, error)
}

type GetDestinationsResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetDestinationsResponse
}

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

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

type CreateDestinationResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *CreateDestinationResponse
}

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

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

type DeleteDestinationResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *DeleteDestinationResponse
}

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

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

type GetDestinationResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetDestinationResponse
}

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

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

type GetSubscriptionResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetSubscriptionResponse
}

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

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

type CreateSubscriptionResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *CreateSubscriptionResponse
}

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

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

type DeleteSubscriptionByIdResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *DeleteSubscriptionByIdResponse
}

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

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

type GetSubscriptionByIdResp struct {
	Body         []byte
	HTTPResponse *http.Response
	Model        *GetSubscriptionByIdResponse
}

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

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

// GetDestinationsWithResponse request returning *GetDestinationsResponse
func (c *ClientWithResponses) GetDestinationsWithResponse(ctx context.Context) (*GetDestinationsResp, error) {
	rsp, err := c.GetDestinations(ctx)
	if err != nil {
		return nil, err
	}
	return ParseGetDestinationsResp(rsp)
}

// CreateDestinationWithBodyWithResponse request with arbitrary body returning *CreateDestinationResponse
func (c *ClientWithResponses) CreateDestinationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*CreateDestinationResp, error) {
	rsp, err := c.CreateDestinationWithBody(ctx, contentType, body)
	if err != nil {
		return nil, err
	}
	return ParseCreateDestinationResp(rsp)
}

func (c *ClientWithResponses) CreateDestinationWithResponse(ctx context.Context, body CreateDestinationJSONRequestBody) (*CreateDestinationResp, error) {
	rsp, err := c.CreateDestination(ctx, body)
	if err != nil {
		return nil, err
	}
	return ParseCreateDestinationResp(rsp)
}

// DeleteDestinationWithResponse request returning *DeleteDestinationResponse
func (c *ClientWithResponses) DeleteDestinationWithResponse(ctx context.Context, destinationId string) (*DeleteDestinationResp, error) {
	rsp, err := c.DeleteDestination(ctx, destinationId)
	if err != nil {
		return nil, err
	}
	return ParseDeleteDestinationResp(rsp)
}

// GetDestinationWithResponse request returning *GetDestinationResponse
func (c *ClientWithResponses) GetDestinationWithResponse(ctx context.Context, destinationId string) (*GetDestinationResp, error) {
	rsp, err := c.GetDestination(ctx, destinationId)
	if err != nil {
		return nil, err
	}
	return ParseGetDestinationResp(rsp)
}

// GetSubscriptionWithResponse request returning *GetSubscriptionResponse
func (c *ClientWithResponses) GetSubscriptionWithResponse(ctx context.Context, notificationType NotificationType) (*GetSubscriptionResp, error) {
	rsp, err := c.GetSubscription(ctx, notificationType)
	if err != nil {
		return nil, err
	}
	return ParseGetSubscriptionResp(rsp)
}

// CreateSubscriptionWithBodyWithResponse request with arbitrary body returning *CreateSubscriptionResponse
func (c *ClientWithResponses) CreateSubscriptionWithBodyWithResponse(ctx context.Context, notificationType NotificationType, contentType string, body io.Reader) (*CreateSubscriptionResp, error) {
	rsp, err := c.CreateSubscriptionWithBody(ctx, notificationType, contentType, body)
	if err != nil {
		return nil, err
	}
	return ParseCreateSubscriptionResp(rsp)
}

func (c *ClientWithResponses) CreateSubscriptionWithResponse(ctx context.Context, notificationType NotificationType, body CreateSubscriptionJSONRequestBody) (*CreateSubscriptionResp, error) {
	rsp, err := c.CreateSubscription(ctx, notificationType, body)
	if err != nil {
		return nil, err
	}
	return ParseCreateSubscriptionResp(rsp)
}

// DeleteSubscriptionByIdWithResponse request returning *DeleteSubscriptionByIdResponse
func (c *ClientWithResponses) DeleteSubscriptionByIdWithResponse(ctx context.Context, notificationType NotificationType, subscriptionId string) (*DeleteSubscriptionByIdResp, error) {
	rsp, err := c.DeleteSubscriptionById(ctx, notificationType, subscriptionId)
	if err != nil {
		return nil, err
	}
	return ParseDeleteSubscriptionByIdResp(rsp)
}

// GetSubscriptionByIdWithResponse request returning *GetSubscriptionByIdResponse
func (c *ClientWithResponses) GetSubscriptionByIdWithResponse(ctx context.Context, notificationType NotificationType, subscriptionId string) (*GetSubscriptionByIdResp, error) {
	rsp, err := c.GetSubscriptionById(ctx, notificationType, subscriptionId)
	if err != nil {
		return nil, err
	}
	return ParseGetSubscriptionByIdResp(rsp)
}

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

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

	var dest GetDestinationsResponse
	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
}

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

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

	var dest CreateDestinationResponse
	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
}

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

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

	var dest DeleteDestinationResponse
	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
}

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

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

	var dest GetDestinationResponse
	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
}

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

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

	var dest GetSubscriptionResponse
	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
}

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

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

	var dest CreateSubscriptionResponse
	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
}

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

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

	var dest DeleteSubscriptionByIdResponse
	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
}

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

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

	var dest GetSubscriptionByIdResponse
	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
}
