-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTTP-78 Support for optional query parameters for body-based requests (…
…#79) Support for optional query parameters for body-based requests Signed-off-by: Olivier Zembri <<[email protected]>>
- Loading branch information
1 parent
6926370
commit b17ede3
Showing
16 changed files
with
311 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/com/getindata/connectors/http/internal/table/lookup/LookupQueryInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.getindata.connectors.http.internal.table.lookup; | ||
|
||
import java.io.Serializable; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
import com.getindata.connectors.http.internal.utils.uri.NameValuePair; | ||
import com.getindata.connectors.http.internal.utils.uri.URLEncodedUtils; | ||
|
||
/** | ||
* Holds the lookup query for an HTTP request. | ||
* The {@code lookupQuery} either contain the query parameters for a GET operation | ||
* or the payload of a body-based request. | ||
* The {@code bodyBasedUrlQueryParams} contains the optional query parameters of a | ||
* body-based request in addition to its payload supplied with {@code lookupQuery}. | ||
*/ | ||
@ToString | ||
public class LookupQueryInfo implements Serializable { | ||
@Getter | ||
private final String lookupQuery; | ||
|
||
private final Map<String, String> bodyBasedUrlQueryParams; | ||
|
||
public LookupQueryInfo(String lookupQuery) { | ||
this(lookupQuery, null); | ||
} | ||
|
||
public LookupQueryInfo(String lookupQuery, Map<String, String> bodyBasedUrlQueryParams) { | ||
this.lookupQuery = | ||
lookupQuery == null ? "" : lookupQuery; | ||
this.bodyBasedUrlQueryParams = | ||
bodyBasedUrlQueryParams == null ? Collections.emptyMap() : bodyBasedUrlQueryParams; | ||
} | ||
|
||
public String getBodyBasedUrlQueryParameters() { | ||
return URLEncodedUtils.format( | ||
bodyBasedUrlQueryParams | ||
.entrySet() | ||
.stream() | ||
.map(entry -> new NameValuePair(entry.getKey(), entry.getValue())) | ||
.collect(Collectors.toList()), | ||
StandardCharsets.UTF_8); | ||
} | ||
|
||
public boolean hasLookupQuery() { | ||
return !lookupQuery.isBlank(); | ||
} | ||
public boolean hasBodyBasedUrlQueryParameters() { | ||
return !bodyBasedUrlQueryParams.isEmpty(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.