Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions src/main/java/Services/Stamp/SWStampService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Exceptions.AuthException;
import Exceptions.GeneralException;
import Services.SWService;
import Utils.Enums.StampVersions;
import Utils.Requests.Stamp.StampOptionsRequest;
import Utils.Requests.Stamp.StampRequest;

Expand All @@ -29,38 +30,29 @@ public SWStampService(String token, String URI, String proxyHost, int proxyPort)
super(token, URI, proxyHost, proxyPort);
}

public IResponse Stamp(String xml, String version) throws AuthException, GeneralException, IOException {
StampOptionsRequest settings = new StampOptionsRequest(getToken(), getURI(), xml, version, getProxyHost(), getProxyPort(), false);
StampRequest req = new StampRequest();
return req.sendRequest(settings);
public IResponse Stamp(String xml, StampVersions version) throws AuthException, GeneralException, IOException {
return this.Stamp(xml, version, false);
}

public IResponse Stamp(String xml, String version, boolean isb64)
public IResponse Stamp(String xml, StampVersions version, boolean isb64)
throws AuthException, GeneralException, IOException {
if (isb64) {
StampOptionsRequest settings = new StampOptionsRequest(getToken(), getURI(), xml, version, isb64, getProxyHost(), getProxyPort(), false);
StampRequest req = new StampRequest();
return req.sendRequest(settings);
} else {
StampOptionsRequest settings = new StampOptionsRequest(getToken(), getURI(), xml, version, getProxyHost(), getProxyPort(), false);
StampRequest req = new StampRequest();
return req.sendRequest(settings);
}
StampRequest req = new StampRequest();
return req.sendRequest(this.getOptions(xml, version, isb64));
}

public IResponse Stamp(byte[] xmlFile, String version, boolean isb64)
public IResponse Stamp(byte[] xmlFile, StampVersions version, boolean isb64)
throws AuthException, GeneralException, IOException {
String xmlProcess = new String(xmlFile, Charset.forName("UTF-8"));
StampOptionsRequest settings = new StampOptionsRequest(getToken(), getURI(), xmlProcess, version, getProxyHost(), getProxyPort(), false);
StampRequest req = new StampRequest();
return req.sendRequest(settings);
return this.Stamp(xmlProcess, version, isb64);
}

public IResponse Stamp(byte[] xmlFile, String version) throws AuthException, GeneralException, IOException {
String xmlProcess = new String(xmlFile, Charset.forName("UTF-8"));
StampOptionsRequest settings = new StampOptionsRequest(getToken(), getURI(), xmlProcess, version, getProxyHost(), getProxyPort(), false);
StampRequest req = new StampRequest();
return req.sendRequest(settings);
public IResponse Stamp(byte[] xmlFile, StampVersions version) throws AuthException, GeneralException, IOException {
return this.Stamp(xmlFile, version, false);
}

private StampOptionsRequest getOptions(String xml, StampVersions version, boolean isBase64) throws AuthException,
GeneralException, IOException {
return new StampOptionsRequest(super.getToken(), super.getURI(), xml, version.version, isBase64,
super.getProxyHost(), super.getProxyPort(), false);
}
}
14 changes: 14 additions & 0 deletions src/main/java/Utils/Enums/StampVersions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package Utils.Enums;

public enum StampVersions {
v1("v1"),
v2("v2"),
v3("v3"),
v4("V4");

public final String version;

private StampVersions(String version){
this.version = version;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class StampOptionsRequest extends IRequest {
private String xml;

public StampOptionsRequest(String token, String URI, String xml, String version, boolean isb64, String proxyHost, int proxyPort, boolean isV2) {
super(token, URI + (isV2 ? Constants.STAMP_V2_PATH : Constants.STAMP_PATH) + version + "/b64", version, isb64, proxyHost, proxyPort);
super(token, URI + (isV2 ? Constants.STAMP_V2_PATH : Constants.STAMP_PATH) + version + (isb64 ? "/b64" : ""), version, isb64, proxyHost, proxyPort);
this.xml = xml;
this.version = version;
}
Expand Down
Loading