func (c *Client) prepareRequest(
	ctx context.Context,
	path string, method string,
	body interface{},
	headerParams map[string]string,
) (localVarRequest *http.Request, err error) {
	var b *bytes.Buffer
	b, err = genBody(body, headerParams)
	if err != nil {
		return nil, err
	}
	url, err := url.Parse(path)
	if err != nil {
		return nil, err
	}
	localVarRequest, err = genNewRequest(b, url.String(), method)
	if err != nil {
		return nil, err
	}
	if len(headerParams) > 0 {
		headers := http.Header{}
		for h, v := range headerParams {
			headers.Set(h, v)
		}
		localVarRequest.Header = headers
	}
	localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
	if ctx != nil {
		localVarRequest = localVarRequest.WithContext(ctx)
	}
	if c.cfg.OAuth2Support {
		auth, err := getNEFAuthorizationToken()
		if err != nil {
			return nil, err
		}
		if len(auth) > 0 {
			localVarRequest.Header.Add("Authorization", "Bearer "+auth)
		} else {
			localVarRequest.Header.Add("Authorization", "Bearer ")
		}
	}
	return localVarRequest, nil
}
prepareRequest build the request
package af
import (
	"bytes"
	"context"
	"crypto/tls"
	"crypto/x509"
	"encoding/json"
	"encoding/xml"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"regexp"
	"time"
	"golang.org/x/net/http2"
)
const contentType string = "application/json"
var (
	jsonCheck = regexp.MustCompile("(?i:[application|text]/json)")
	xmlCheck  = regexp.MustCompile("(?i:[application|text]/xml)")
)
type Client struct {
	cfg *CliConfig
	common service
	TrafficInfluSubGetAllAPI  *TrafficInfluenceSubscriptionGetAllAPIService
	TrafficInfluSubDeleteAPI  *TrafficInfluenceSubscriptionDeleteAPIService
	TrafficInfluSubGetAPI     *TrafficInfluenceSubscriptionGetAPIService
	TrafficInfluSubPatchAPI   *TrafficInfluenceSubscriptionPatchAPIService
	TrafficInfluSubPostAPI    *TrafficInfluenceSubscriptionPostAPIService
	TrafficInfluSubPutAPI     *TrafficInfluenceSubscriptionPutAPIService
	PfdManagementGetAllAPI    *PfdManagementTransactionGetAllAPIService
	PfdManagementPostAPI      *PfdManagementTransactionPostAPIService
	PfdManagementGetAPI       *PfdManagementTransactionGetAPIService
	PfdManagementDeleteAPI    *PfdManagementTransactionDeleteAPIService
	PfdManagementPutAPI       *PfdManagementTransactionPutAPIService
	PfdManagementAppGetAPI    *PfdManagementTransactionAppGetAPIService
	PfdManagementAppDeleteAPI *PfdManagementTransactionAppDeleteAPIService
	PfdManagementAppPutAPI    *PfdManagementTransactionAppPutAPIService
	PfdManagementAppPatchAPI  *PfdManagementTransactionAppPatchAPIService
}
type service struct {
	client *Client
}
var TestAf bool = false
var HTTPClient *http.Client
func SetHTTPClient(httpClient *http.Client) {
	HTTPClient = httpClient
}
func NewClient(cfg *CliConfig) *Client {
	if TestAf {
		cfg.HTTPClient = HTTPClient
	}
	if cfg.HTTPClient == nil || !TestAf {
		CACert, err := ioutil.ReadFile(cfg.NEFCliCertPath)
		if err != nil {
			log.Errf("Error: %v", err)
		}
		CACertPool := x509.NewCertPool()
		CACertPool.AppendCertsFromPEM(CACert)
		cfg.HTTPClient = &http.Client{
			Timeout: 15 * time.Second,
			Transport: &http2.Transport{
				TLSClientConfig: &tls.Config{
					RootCAs:    CACertPool,
					MinVersion: tls.VersionTLS12,
				},
			},
		}
	}
	c := &Client{}
	c.cfg = cfg
	c.common.client = c
	c.TrafficInfluSubGetAllAPI =
		(*TrafficInfluenceSubscriptionGetAllAPIService)(&c.common)
	c.TrafficInfluSubDeleteAPI =
		(*TrafficInfluenceSubscriptionDeleteAPIService)(&c.common)
	c.TrafficInfluSubGetAPI =
		(*TrafficInfluenceSubscriptionGetAPIService)(&c.common)
	c.TrafficInfluSubPatchAPI =
		(*TrafficInfluenceSubscriptionPatchAPIService)(&c.common)
	c.TrafficInfluSubPostAPI =
		(*TrafficInfluenceSubscriptionPostAPIService)(&c.common)
	c.TrafficInfluSubPutAPI =
		(*TrafficInfluenceSubscriptionPutAPIService)(&c.common)
	c.PfdManagementGetAllAPI =
		(*PfdManagementTransactionGetAllAPIService)(&c.common)
	c.PfdManagementPostAPI =
		(*PfdManagementTransactionPostAPIService)(&c.common)
	c.PfdManagementGetAPI =
		(*PfdManagementTransactionGetAPIService)(&c.common)
	c.PfdManagementDeleteAPI =
		(*PfdManagementTransactionDeleteAPIService)(&c.common)
	c.PfdManagementPutAPI =
		(*PfdManagementTransactionPutAPIService)(&c.common)
	c.PfdManagementAppGetAPI =
		(*PfdManagementTransactionAppGetAPIService)(&c.common)
	c.PfdManagementAppDeleteAPI =
		(*PfdManagementTransactionAppDeleteAPIService)(&c.common)
	c.PfdManagementAppPutAPI =
		(*PfdManagementTransactionAppPutAPIService)(&c.common)
	c.PfdManagementAppPatchAPI =
		(*PfdManagementTransactionAppPatchAPIService)(&c.common)
	return c
}
func (c *Client) callAPI(request *http.Request) (*http.Response, error) {
	return c.cfg.HTTPClient.Do(request)
}
func genNewRequest(body io.Reader, url string,
	method string) (*http.Request, error) {
	var (
		localVarRequest *http.Request
		err             error
	)
	localVarRequest, err = http.NewRequest(method, url, body)
	if err != nil {
		return nil, err
	}
	return localVarRequest, nil
}
func genBody(postBody interface{},
	headerParams map[string]string) (*bytes.Buffer, error) {
	var (
		body = &bytes.Buffer{}
		err  error
	)
	if postBody != nil {
		contenttype := headerParams["Content-Type"]
		body, err = setBody(postBody, contenttype)
		if err != nil {
			return nil, err
		}
	}
	return body, nil
}