// WithString returns a PrepareDecorator that encodes the passed string into the body of the request
// and sets the Content-Length header.
355217
func WithString(v string) PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r, err := p.Prepare(r)
			if err == nil {
				r.ContentLength = int64(len(v))
				r.Body = ioutil.NopCloser(strings.NewReader(v))
			}
			return r, err
		})
	}
}
998304
func (s *TermvectorsService) BodyString(body string) *TermvectorsService {
	s.bodyString = body
	return s
}
316951
func (s *MultiTermvectorService) BodyString(body string) *MultiTermvectorService {
	s.bodyString = body
	return s
}
682047
func WithMethod(method string) PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r.Method = method
			return p.Prepare(r)
		})
	}
}
1145267
func WithFormData(v url.Values) PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r, err := p.Prepare(r)
			if err == nil {
				s := v.Encode()

				if r.Header == nil {
					r.Header = make(http.Header)
				}
				r.Header.Set(http.CanonicalHeaderKey(headerContentType), mimeTypeFormPost)
				r.ContentLength = int64(len(s))
				r.Body = ioutil.NopCloser(strings.NewReader(s))
			}
			return r, err
		})
	}
}
221100
func (h Headers) String() string {
	ec := h.Validate()
	if ec != nil {
		return ec.Error()
	}
	b := make([]byte, 0, 1024)
	for i := 0; i < len(h); i += 2 {
		b = append(b, h[i]+":"+h[i+1]+"\n"...)
	}
	return string(b)
}
912700
func (this *HttpClient) WithHeaders(m map[string]string) *HttpClient {
	for k, v := range m {
		this.WithHeader(k, v)
	}

	return this
}
782035
func ToString(i interface{}) string {
	if i == nil {
		return ""
	}

	if s, ok := i.(string); ok {
		return s
	}

	if sl, ok := i.([]string); ok {
		if len(sl) == 1 {
			return sl[0]
		}
	}

	return ""
}
148262
func (s *PutMappingService) BodyString(mapping string) *PutMappingService {
	s.bodyString = mapping
	return s
}
530035
func WithFile(f io.ReadCloser) PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r, err := p.Prepare(r)
			if err == nil {
				b, err := ioutil.ReadAll(f)
				if err != nil {
					return r, err
				}
				r.Body = ioutil.NopCloser(bytes.NewReader(b))
				r.ContentLength = int64(len(b))
			}
			return r, err
		})
	}
}
1032692
func ToString(in interface{}) (string, error) {
	if val, err := cast.ToStringE(in); err == nil {
		return val, nil
	}
	return "", ErrBadType
}
1301562
func (s *IndicesShrinkService) BodyString(body string) *IndicesShrinkService {
	s.bodyString = body
	return s
}
1186582
func (r *Request) BodyString(data string) *Request {
	r.Use(body.String(data))
	return r
}
295359
func (o *CreateJSONWebKeySetParams) WithBody(body *models.CreateRequest) *CreateJSONWebKeySetParams {
	o.SetBody(body)
	return o
}
287208
func (h Hex) ToString() string {
	s := fmt.Sprintf("%x", h.Value)
	if len(s)%2 != 0 {
		s = "0" + s
	}

	// should never error.
	b, _ := hex.DecodeString(s)
	return string(b)
}
1346170
func (b *IndicesCreateService) BodyString(body string) *IndicesCreateService {
	b.bodyString = body
	return b
}
753772
func (o *AcceptConsentRequestParams) WithBody(body *models.HandledConsentRequest) *AcceptConsentRequestParams {
	o.SetBody(body)
	return o
}