public ShapeShiftTxStatus getShapeShiftTxStatus() { ShapeShiftTxStatus.Status shapeShiftStatus; switch (status) { case STATUS_INITIAL: shapeShiftStatus = ShapeShiftTxStatus.Status.NO_DEPOSITS; break; case STATUS_PROCESSING: shapeShiftStatus = ShapeShiftTxStatus.Status.RECEIVED; break; case STATUS_COMPLETE: shapeShiftStatus = ShapeShiftTxStatus.Status.COMPLETE; break; case STATUS_FAILED: shapeShiftStatus = ShapeShiftTxStatus.Status.FAILED; break; case STATUS_UNKNOWN: default: shapeShiftStatus = ShapeShiftTxStatus.Status.UNKNOWN; } return new ShapeShiftTxStatus(shapeShiftStatus, depositAddress, withdrawAddress, depositAmount, withdrawAmount, withdrawTransactionId); }
/** * Status of deposit to address * * This returns the status of the most recent deposit transaction to the address. */ public ShapeShiftTxStatus getTxStatus(AbstractAddress address) throws ShapeShiftException, IOException { String apiUrl = getApiUrl(String.format(TX_STATUS_API, address.toString())); Request request = new Request.Builder().url(apiUrl).build(); ShapeShiftTxStatus reply = new ShapeShiftTxStatus(getMakeApiCall(request)); if (!reply.isError && reply.address != null) checkAddress(address, reply.address); return new ShapeShiftTxStatus(reply, address); }
@Test public void testTxStatus5() throws JSONException, ShapeShiftException { JSONObject json = new JSONObject( "{status: \"new_fancy_optional_status\"}"); ShapeShiftTxStatus txStatus = new ShapeShiftTxStatus(json); assertNotNull(txStatus); assertFalse(txStatus.isError); assertEquals(ShapeShiftTxStatus.Status.UNKNOWN, txStatus.status); assertNull(txStatus.address); assertNull(txStatus.withdraw); assertNull(txStatus.incomingValue); assertNull(txStatus.outgoingValue); assertNull(txStatus.transactionId); }
@Test public void testTxStatus() throws JSONException, ShapeShiftException { JSONObject json = new JSONObject( "{" + "status: \"no_deposits\"," + "address: \"1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN\"" + "}"); ShapeShiftTxStatus txStatus = new ShapeShiftTxStatus(json); assertNotNull(txStatus); assertFalse(txStatus.isError); assertEquals(ShapeShiftTxStatus.Status.NO_DEPOSITS, txStatus.status); // assertEquals("1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN", txStatus.address.toString()); assertNull(txStatus.withdraw); assertNull(txStatus.incomingValue); assertNull(txStatus.outgoingValue); assertNull(txStatus.transactionId); }
@Test public void testTxStatusError() throws JSONException, ShapeShiftException { JSONObject json = new JSONObject("{ error: \"error\" }"); ShapeShiftTxStatus txStatus = new ShapeShiftTxStatus(json); assertNotNull(txStatus); assertTrue(txStatus.isError); assertEquals("error", txStatus.errorMessage); assertNull(txStatus.status); assertNull(txStatus.address); assertNull(txStatus.withdraw); assertNull(txStatus.incomingValue); assertNull(txStatus.outgoingValue); assertNull(txStatus.transactionId); }
@Test public void testTxStatus4() throws JSONException, ShapeShiftException { JSONObject json = new JSONObject( "{" + "status: \"failed\"," + "error: \"error\"" + "}"); ShapeShiftTxStatus txStatus = new ShapeShiftTxStatus(json); assertNotNull(txStatus); assertTrue(txStatus.isError); assertEquals(ShapeShiftTxStatus.Status.FAILED, txStatus.status); assertEquals("error", txStatus.errorMessage); assertNull(txStatus.address); assertNull(txStatus.withdraw); assertNull(txStatus.incomingValue); assertNull(txStatus.outgoingValue); assertNull(txStatus.transactionId); }
@Test public void testTxStatus2() throws JSONException, ShapeShiftException { JSONObject json = new JSONObject( "{" + "status: \"received\"," + "address: \"1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN\"," + "incomingCoin: 0.00297537," + "incomingType: \"BTC\"" + "}"); ShapeShiftTxStatus txStatus = new ShapeShiftTxStatus(json); assertNotNull(txStatus); assertFalse(txStatus.isError); assertEquals(ShapeShiftTxStatus.Status.RECEIVED, txStatus.status); assertEquals("1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN", txStatus.address.toString()); assertEquals(BTC, txStatus.address.getType()); assertNull(txStatus.withdraw); assertEquals(BTC.value("0.00297537"), txStatus.incomingValue); assertNull(txStatus.outgoingValue); assertNull(txStatus.transactionId); }
@Test public void testTxStatus3Alt() throws JSONException, ShapeShiftException { JSONObject json = new JSONObject( "{\n" + "status: \"complete\",\n" + "address: \"1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN\",\n" + "withdraw: \"BB6kZZi87mCd7mC1tWWJjuKGPTYQ1n2Fcg\",\n" + "incomingCoin: 0.01,\n" + "incomingType: \"BTC\",\n" + "outgoingCoin: \"2.32997513\",\n" + "outgoingType: \"NBT\",\n" + "transaction: \"66fa0b4c11227f9f05efa13d23e58c65b50acbd6395a126b5cd751064e6e79df\"\n" + "}"); ShapeShiftTxStatus txStatus = new ShapeShiftTxStatus(json); assertNotNull(txStatus); assertFalse(txStatus.isError); assertEquals(ShapeShiftTxStatus.Status.COMPLETE, txStatus.status); assertEquals("1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN", txStatus.address.toString()); assertEquals(BTC, txStatus.address.getType()); assertEquals("BB6kZZi87mCd7mC1tWWJjuKGPTYQ1n2Fcg", txStatus.withdraw.toString()); assertEquals(NBT, txStatus.withdraw.getType()); assertEquals(BTC.value("0.01"), txStatus.incomingValue); assertEquals(NBT.value("2.33"), txStatus.outgoingValue); assertEquals("66fa0b4c11227f9f05efa13d23e58c65b50acbd6395a126b5cd751064e6e79df", txStatus.transactionId); }
@Test public void testTxStatus3() throws JSONException, ShapeShiftException { JSONObject json = new JSONObject( "{" + "status: \"complete\"," + "address: \"1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN\"," + "withdraw: \"LMmeBWH17TWkQKvK7YFio2oiimPAzrHG6f\"," + "incomingCoin: 0.00297537," + "incomingType: \"BTC\"," + "outgoingCoin: \"0.42000000\"," + "outgoingType: \"LTC\"," + "transaction: " + "\"66fa0b4c11227f9f05efa13d23e58c65b50acbd6395a126b5cd751064e6e79df\"" + "}"); ShapeShiftTxStatus txStatus = new ShapeShiftTxStatus(json); assertNotNull(txStatus); assertFalse(txStatus.isError); assertEquals(ShapeShiftTxStatus.Status.COMPLETE, txStatus.status); assertEquals("1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN", txStatus.address.toString()); assertEquals(BTC, txStatus.address.getType()); assertEquals("LMmeBWH17TWkQKvK7YFio2oiimPAzrHG6f", txStatus.withdraw.toString()); assertEquals(LTC, txStatus.withdraw.getType()); assertEquals(BTC.value("0.00297537"), txStatus.incomingValue); assertEquals(LTC.value("0.42"), txStatus.outgoingValue); assertEquals("66fa0b4c11227f9f05efa13d23e58c65b50acbd6395a126b5cd751064e6e79df", txStatus.transactionId); }