From a543fdd3013c33ef5db66b0d29d7b9d9a07e3979 Mon Sep 17 00:00:00 2001 From: Patryk Kot Date: Mon, 22 May 2017 11:11:17 +0200 Subject: [PATCH 1/2] Added custom query params for action function in Client ( up to build request in http) to allow using custom functionality in query params ( for example using query params which are not visible in schema or custom filtering ) --- lib/client.js | 4 ++-- lib/transports/http.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/client.js b/lib/client.js index c767373..9499d94 100644 --- a/lib/client.js +++ b/lib/client.js @@ -34,10 +34,10 @@ class Client { this.transports = options.transports || [new transports.HTTPTransport(transportOptions)] } - action (document, keys, params = {}) { + action (document, keys, params = {}, customQueryParams = {}) { const link = lookupLink(document, keys) const transport = utils.determineTransport(this.transports, link.url) - return transport.action(link, this.decoders, params) + return transport.action(link, this.decoders, params, customQueryParams) } get (url) { diff --git a/lib/transports/http.js b/lib/transports/http.js index 07a0259..2aa6b22 100644 --- a/lib/transports/http.js +++ b/lib/transports/http.js @@ -27,10 +27,10 @@ class HTTPTransport { this.responseCallback = options.responseCallback } - buildRequest (link, decoders, params = {}) { + buildRequest (link, decoders, params = {}, customQueryParams = {}) { const fields = link.fields const method = link.method.toUpperCase() - let queryParams = {} + let queryParams = customQueryParams; let pathParams = {} let formParams = {} let fieldNames = [] @@ -113,9 +113,9 @@ class HTTPTransport { } } - action (link, decoders, params = {}) { + action (link, decoders, params = {}, customQueryParams = {}) { const responseCallback = this.responseCallback - const request = this.buildRequest(link, decoders, params) + const request = this.buildRequest(link, decoders, params, customQueryParams) if (this.requestCallback) { this.requestCallback(request) From 5c6eaaf3ad316d5520ef1d7d9f9055a797419a28 Mon Sep 17 00:00:00 2001 From: Patryk Kot Date: Mon, 22 May 2017 11:36:46 +0200 Subject: [PATCH 2/2] removed extra semicolon --- lib/transports/http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transports/http.js b/lib/transports/http.js index 2aa6b22..f601411 100644 --- a/lib/transports/http.js +++ b/lib/transports/http.js @@ -30,7 +30,7 @@ class HTTPTransport { buildRequest (link, decoders, params = {}, customQueryParams = {}) { const fields = link.fields const method = link.method.toUpperCase() - let queryParams = customQueryParams; + let queryParams = customQueryParams let pathParams = {} let formParams = {} let fieldNames = []