* This file is part of MoLe.
* MoLe is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
* This file is part of MoLe.
* MoLe is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
import net.ktnx.mobileledger.json.Gateway;
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
import net.ktnx.mobileledger.json.Gateway;
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
import net.ktnx.mobileledger.utils.NetworkUtil;
import net.ktnx.mobileledger.utils.SimpleDate;
import net.ktnx.mobileledger.utils.UrlEncodedFormData;
import net.ktnx.mobileledger.utils.NetworkUtil;
import net.ktnx.mobileledger.utils.SimpleDate;
import net.ktnx.mobileledger.utils.UrlEncodedFormData;
import static net.ktnx.mobileledger.utils.Logger.debug;
/* TODO: get rid of the custom session/cookie and auth code?
import static net.ktnx.mobileledger.utils.Logger.debug;
/* TODO: get rid of the custom session/cookie and auth code?
- public SendTransactionTask(TaskCallback callback, MobileLedgerProfile profile,
- boolean simulate) {
+ public SendTransactionTask(TaskCallback callback, Profile profile,
+ LedgerTransaction transaction, boolean simulate) {
- public SendTransactionTask(TaskCallback callback, MobileLedgerProfile profile) {
- taskCallback = callback;
- mProfile = profile;
- simulate = false;
- }
- private boolean sendOK(API apiVersion) throws IOException {
+ private void sendOK(API apiVersion) throws IOException, ApiNotSupportedException {
HttpURLConnection http = NetworkUtil.prepareConnection(mProfile, "add");
http.setRequestMethod("PUT");
http.setRequestProperty("Content-Type", "application/json");
HttpURLConnection http = NetworkUtil.prepareConnection(mProfile, "add");
http.setRequestMethod("PUT");
http.setRequestProperty("Content-Type", "application/json");
Gateway gateway = Gateway.forApiVersion(apiVersion);
String body = gateway.transactionSaveRequest(transaction);
Gateway gateway = Gateway.forApiVersion(apiVersion);
String body = gateway.transactionSaveRequest(transaction);
- return sendRequest(http, body);
+ Logger.debug("network", "Sending using API " + apiVersion);
+ sendRequest(http, body);
- private boolean sendRequest(HttpURLConnection http, String body) throws IOException {
+ private void sendRequest(HttpURLConnection http, String body)
+ throws IOException, ApiNotSupportedException {
}
private boolean legacySendOK() throws IOException {
HttpURLConnection http = NetworkUtil.prepareConnection(mProfile, "add");
}
private boolean legacySendOK() throws IOException {
HttpURLConnection http = NetworkUtil.prepareConnection(mProfile, "add");
switch (profileApiVersion) {
case auto:
boolean sendOK = false;
for (API ver : API.allVersions) {
Logger.debug("network", "Trying version " + ver);
switch (profileApiVersion) {
case auto:
boolean sendOK = false;
for (API ver : API.allVersions) {
Logger.debug("network", "Trying version " + ver);