com.global.api.terminals.DeviceMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of globalpayments-sdk Show documentation
Show all versions of globalpayments-sdk Show documentation
API for processing payments through Global Payments
package com.global.api.terminals;
import com.global.api.entities.enums.ControlCodes;
import com.global.api.terminals.abstractions.IDeviceMessage;
import com.global.api.utils.EnumUtils;
import com.global.api.utils.IRawRequestBuilder;
import lombok.Getter;
import lombok.Setter;
public class DeviceMessage implements IDeviceMessage {
private byte[] buffer;
private boolean keepAlive;
private boolean awaitResponse;
@Getter
@Setter
private IRawRequestBuilder rawRequest;
public DeviceMessage(byte[] buffer){
this.buffer = buffer;
}
public byte[] getSendBuffer() { return this.buffer; }
@Override
public IRawRequestBuilder getRequestBuilder() {
return rawRequest;
}
public boolean isKeepAlive() {
return keepAlive;
}
public void setKeepAlive(boolean keepAlive) {
this.keepAlive = keepAlive;
}
public boolean isAwaitResponse() {
return awaitResponse;
}
public void setAwaitResponse(boolean awaitResponse) {
this.awaitResponse = awaitResponse;
}
@Override
public String toString(){
StringBuilder sb = new StringBuilder();
for(byte b : buffer){
if(EnumUtils.isDefined(ControlCodes.class, b)){
ControlCodes code = EnumUtils.parse(ControlCodes.class, b);
sb.append(code.toString());
}
else sb.append((char)b);
}
return sb.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy