Skip to content

Commit

Permalink
add header for uk traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaimoiseanu committed Mar 5, 2024
1 parent 0eb5ffa commit dc4c9d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public OAuthToken createToken() throws Exception {
}
rest.addRequestHttpHeader("Content-Type", "application/x-www-form-urlencoded");
rest.addRequestHttpHeader("User-Agent", String.format("MangoPay V2 SDK Java %s", getRoot().getConfig().getVersion()));
if(root.getConfig().isUkHeaderFlag()){
rest.addRequestHttpHeader("x-tenant-id", "uk");
}
OAuthToken response = rest.request(OAuthToken.class, null, urlMethod, requestType, requestData);

return response;
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/mangopay/core/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public class Configuration {
* Mangopay SDK Version
*/
private String version;

/**
* Set to true for uk traffic
*/
private boolean ukHeaderFlag = false;


public String getClientId() {
Expand Down Expand Up @@ -115,7 +120,14 @@ public void setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
}


public boolean isUkHeaderFlag() {
return ukHeaderFlag;
}

public void setUkHeaderFlag(boolean ukHeaderFlag) {
this.ukHeaderFlag = ukHeaderFlag;
}

/**
* Get Mangopay SDK Version
* @return String Mangopay Version
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/mangopay/core/RestTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,9 @@ private Map<String, String> getHttpHeaders(String restUrl) throws Exception {
}

httpHeaders.put("User-Agent", String.format("MangoPay V2 SDK Java %s", root.getConfig().getVersion()));

if(this.root.getConfig().isUkHeaderFlag()) {
httpHeaders.put("x-tenant-id", "uk");
}
return httpHeaders;
}

Expand Down

0 comments on commit dc4c9d0

Please sign in to comment.