/** * Request email receipt * * This call allows you to request a fixed amount to be sent to the {@code withdrawal} address. * You provide a withdrawal address and the amount you want sent to it. We return the amount * to deposit and the address to deposit to. This allows you to use shapeshift as a payment * mechanism. * * The exchange pair is determined from the {@link CoinType}s of {@code refund} and * {@code withdrawal}. */ public ShapeShiftEmail requestEmailReceipt(String email, ShapeShiftTxStatus txStatus) throws ShapeShiftException, IOException { JSONObject requestJson = new JSONObject(); try { requestJson.put("email", email); checkState(txStatus.status == ShapeShiftTxStatus.Status.COMPLETE, "Transaction not complete"); requestJson.put("txid", checkNotNull(txStatus.transactionId, "Null transaction id")); } catch (Exception e) { throw new ShapeShiftException("Could not create a JSON request", e); } String apiUrl = getApiUrl(EMAIL_RECEIPT_API); RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, requestJson.toString()); Request request = new Request.Builder().url(apiUrl).post(body).build(); return new ShapeShiftEmail(getMakeApiCall(request)); }
@Test public void testEmail() throws JSONException, ShapeShiftException { JSONObject json = new JSONObject( "{" + "\"email\":{" + "\"status\":\"success\"," + "\"message\":\"Email receipt sent\"" + "}" + "}"); ShapeShiftEmail email = new ShapeShiftEmail(json); assertNotNull(email); assertFalse(email.isError); assertEquals(ShapeShiftEmail.Status.SUCCESS, email.status); assertEquals("Email receipt sent", email.message); }