Code Monkey home page Code Monkey logo

apex-http-request-builder's Introduction

Apex HTTP Request Builder

license

A small library to make building HttpRequest instances in Apex easy.

new HttpRequestBuilder()
    .post('https://www.example.com')
    .json(new Account(Name = 'Example'))
    .send()

A POST request will be sent to https://www.example.com with the Content-Type header set to application/json and the Account serialized as JSON in the body.

Usage

HttpRequest build()

Build a new client request.

HttpRequest build(List<String> params)

Build a new client request with the given parameters substituted within the endpoint.

HttpResponse send()

Sends the request and returns the response.

HttpResponse send(List<String> params)

Sends the request with the given parameters substituted within the endpoint and returns the response.

HttpRequestBuilder get(String endpoint)

Sets the type of method to be used for the HTTP request to GET and specifies the endpoint for this request.

HttpRequestBuilder patch(String endpoint)

Sets the type of method to be used for the HTTP request to PATCH and specifies the endpoint for this request.

HttpRequestBuilder post(String endpoint)

Sets the type of method to be used for the HTTP request to POST and specifies the endpoint for this request.

HttpRequestBuilder put(String endpoint)

Sets the type of method to be used for the HTTP request to PUT and specifies the endpoint for this request.

HttpRequestBuilder json(Object data)

Sets the contents of the body for this request. The contents are serialized as JSON.

HttpRequestBuilder setBody(String body)

Sets the contents of the body for this request.

HttpRequestBuilder setBody(Blob body)

Sets the contents of the body for this request using a Blob.

HttpRequestBuilder setBody(Dom.Document document)

Sets the contents of the body for this request. The contents represent a DOM document.

HttpRequestBuilder setClientCertificateName(String certDevName)

If the external service requires a client certificate for authentication, set the certificate name.

HttpRequestBuilder setCompressed(Boolean flag)

If true, the data in the body is delivered to the endpoint in the gzip compressed format. If false, no compression format is used.

HttpRequestBuilder setEndpoint(String endpoint)

Specifies the endpoint for this request.

HttpRequestBuilder setHeader(String key, String value)

Sets the contents of the request header.

HttpRequestBuilder setHeaders(Map<String, String> headers)

Sets the contents of multiple request headers.

HttpRequestBuilder setMethod(String method)

Sets the type of method to be used for the HTTP request.

HttpRequestBuilder setTimeout(Integer timeout)

Sets the timeout in milliseconds for the request.

License

MIT

apex-http-request-builder's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.