/*
Copyright 2021 The KodeRover Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package httpclient

import (
	"net/http"
	"net/url"

	"github.com/go-resty/resty/v2"
)

type RequestFunc func(request *resty.Request)

func SetResult(res interface{}) RequestFunc {
	return func(r *resty.Request) {
		r.SetResult(res)
	}
}

func SetBody(body interface{}) RequestFunc {
	return func(r *resty.Request) {
		r.SetBody(body)
	}
}

func SetHeader(header, value string) RequestFunc {
	return func(r *resty.Request) {
		r.SetHeader(header, value)
	}
}

func SetHeaders(headers map[string]string) RequestFunc {
	return func(r *resty.Request) {
		r.SetHeaders(headers)
	}
}

func SetHeadersFromHTTPHeader(header http.Header) RequestFunc {
	return func(r *resty.Request) {
		r.Header = header
	}
}

func SetQueryParamsFromValues(params url.Values) RequestFunc {
	return func(r *resty.Request) {
		r.SetQueryParamsFromValues(params)
	}
}

func SetQueryParams(params map[string]string) RequestFunc {
	return func(r *resty.Request) {
		r.SetQueryParams(params)
	}
}

func SetQueryParam(param, value string) RequestFunc {
	return func(r *resty.Request) {
		r.SetQueryParam(param, value)
	}
}

func ForceContentType(contentType string) RequestFunc {
	return func(r *resty.Request) {
		r.ForceContentType(contentType)
	}
}

func SetFormData(data map[string]string) RequestFunc {
	return func(r *resty.Request) {
		r.SetFormData(data)
	}
}
