Search in sources :

Example 1 with SepaPaymentAccount

use of io.bisq.api.model.payment.SepaPaymentAccount in project bisq-api by mrosseel.

the class ApiTestHelper method randomValidCreateSepaAccountPayload.

public static SepaPaymentAccount randomValidCreateSepaAccountPayload(String tradeCurrency, String countryCode) {
    final Faker faker = new Faker();
    final SepaPaymentAccount accountToCreate = new SepaPaymentAccount();
    if (null == countryCode)
        countryCode = faker.options().nextElement(CountryUtil.getAllSepaCountries()).code;
    accountToCreate.paymentMethod = PaymentMethod.SEPA_ID;
    accountToCreate.accountName = faker.commerce().productName();
    accountToCreate.bic = faker.finance().bic();
    accountToCreate.iban = faker.finance().iban();
    accountToCreate.holderName = faker.name().fullName();
    accountToCreate.countryCode = countryCode;
    accountToCreate.acceptedCountries = new ArrayList<>(new HashSet<>(Arrays.asList("PL", "GB", countryCode)));
    accountToCreate.selectedTradeCurrency = faker.options().option("PLN", "USD", "EUR", "GBP");
    if (null != tradeCurrency)
        accountToCreate.selectedTradeCurrency = tradeCurrency;
    accountToCreate.tradeCurrencies = Collections.singletonList(accountToCreate.selectedTradeCurrency);
    return accountToCreate;
}
Also used : Faker(com.github.javafaker.Faker) SepaPaymentAccount(io.bisq.api.model.payment.SepaPaymentAccount)

Example 2 with SepaPaymentAccount

use of io.bisq.api.model.payment.SepaPaymentAccount in project bisq-api by mrosseel.

the class OfferResourceIT method addPaymentAccounts.

private void addPaymentAccounts() {
    final int alicePort = getAlicePort();
    final int bobPort = getBobPort();
    SepaPaymentAccount sepaAccountToCreate;
    sepaAccountToCreate = ApiTestHelper.randomValidCreateSepaAccountPayload();
    tradeCurrency = sepaAccountToCreate.selectedTradeCurrency;
    final String tradePaymentMethodCountry = sepaAccountToCreate.countryCode;
    alicePaymentAccount = ApiTestHelper.createPaymentAccount(alicePort, sepaAccountToCreate).extract().as(SepaPaymentAccount.class);
    sepaAccountToCreate = ApiTestHelper.randomValidCreateSepaAccountPayload(tradeCurrency, tradePaymentMethodCountry);
    bobPaymentAccount = ApiTestHelper.createPaymentAccount(bobPort, sepaAccountToCreate).extract().as(SepaPaymentAccount.class);
    final String incompatibleCurrency = "EUR".equals(tradeCurrency) ? "PLN" : "EUR";
    sepaAccountToCreate = ApiTestHelper.randomValidCreateSepaAccountPayload(incompatibleCurrency, tradePaymentMethodCountry);
    bobIncompatiblePaymentAccountId = ApiTestHelper.createPaymentAccount(bobPort, sepaAccountToCreate).extract().body().jsonPath().get("id");
}
Also used : SepaPaymentAccount(io.bisq.api.model.payment.SepaPaymentAccount)

Example 3 with SepaPaymentAccount

use of io.bisq.api.model.payment.SepaPaymentAccount in project bisq-api by mrosseel.

the class TradeResourceIT method getTrades_returnsTrade.

@InSequence(1)
@Test
public void getTrades_returnsTrade() throws Exception {
    final int alicePort = getAlicePort();
    final SepaPaymentAccount alicePaymentAccount = OfferResourceIT.alicePaymentAccount;
    final SepaPaymentAccount bobPaymentAccount = OfferResourceIT.bobPaymentAccount;
    given().port(getBobPort()).when().get("/api/v1/trades").then().statusCode(200).and().body("trades[0].id", isA(String.class)).and().body("trades[0].offer.id", isA(String.class)).and().body("trades[0].offer.acceptedCountryCodes", equalTo(alicePaymentAccount.acceptedCountries)).and().body("trades[0].offer.amount", equalTo(1)).and().body("trades[0].offer.arbitratorNodeAddresses", equalTo(ApiTestHelper.getAcceptedArbitrators(alicePort))).and().body("trades[0].offer.baseCurrencyCode", equalTo("BTC")).and().body("trades[0].offer.bankId", equalTo(alicePaymentAccount.bic)).and().body("trades[0].offer.blockHeightAtOfferCreation", isA(Integer.class)).and().body("trades[0].offer.buyerSecurityDeposit", equalTo((int) OfferResourceIT.createdOffer.buyerSecurityDeposit)).and().body("trades[0].offer.counterCurrencyCode", equalTo(alicePaymentAccount.selectedTradeCurrency)).and().body("trades[0].offer.countryCode", equalTo(alicePaymentAccount.countryCode)).and().body("trades[0].offer.currencyCode", equalTo(alicePaymentAccount.selectedTradeCurrency)).and().body("trades[0].offer.date", isA(Long.class)).and().body("trades[0].offer.direction", equalTo(OfferPayload.Direction.BUY.name())).and().body("trades[0].offer.id", isA(String.class)).and().body("trades[0].offer.isCurrencyForMakerFeeBtc", equalTo(true)).and().body("trades[0].offer.isPrivateOffer", equalTo(false)).and().body("trades[0].offer.lowerClosePrice", equalTo(0)).and().body("trades[0].offer.makerFee", equalTo(5000)).and().body("trades[0].offer.makerPaymentAccountId", equalTo(alicePaymentAccount.id)).and().body("trades[0].offer.marketPriceMargin", equalTo(10f)).and().body("trades[0].offer.maxTradeLimit", equalTo(25000000)).and().body("trades[0].offer.maxTradePeriod", equalTo(518400000)).and().body("trades[0].offer.minAmount", equalTo(1)).and().body("trades[0].offer.offerFeePaymentTxId", isA(String.class)).and().body("trades[0].offer.ownerNodeAddress", equalTo(ApiTestHelper.getP2PNetworkStatus(alicePort).address)).and().body("trades[0].offer.paymentMethodId", equalTo(alicePaymentAccount.paymentMethod)).and().body("trades[0].offer.price", equalTo(10)).and().body("trades[0].offer.protocolVersion", equalTo(1)).and().body("trades[0].offer.sellerSecurityDeposit", equalTo(300000)).and().body("trades[0].offer.state", equalTo(Offer.State.AVAILABLE.name())).and().body("trades[0].offer.txFee", equalTo(6000)).and().body("trades[0].offer.upperClosePrice", equalTo(0)).and().body("trades[0].offer.useAutoClose", equalTo(false)).and().body("trades[0].offer.useMarketBasedPrice", equalTo(false)).and().body("trades[0].offer.useReOpenAfterAutoClose", equalTo(false)).and().body("trades[0].offer.versionNr", isA(String.class)).and().body("trades[0].buyerPaymentAccount.paymentMethod", equalTo(alicePaymentAccount.paymentMethod)).and().body("trades[0].buyerPaymentAccount.paymentDetails", isA(String.class)).and().body("trades[0].buyerPaymentAccount.countryCode", equalTo(alicePaymentAccount.countryCode)).and().body("trades[0].buyerPaymentAccount.holderName", equalTo(alicePaymentAccount.holderName)).and().body("trades[0].buyerPaymentAccount.bic", equalTo(alicePaymentAccount.bic)).and().body("trades[0].buyerPaymentAccount.iban", equalTo(alicePaymentAccount.iban)).and().body("trades[0].buyerPaymentAccount.acceptedCountries", equalTo(alicePaymentAccount.acceptedCountries)).and().body("trades[0].sellerPaymentAccount.paymentMethod", equalTo(bobPaymentAccount.paymentMethod)).and().body("trades[0].sellerPaymentAccount.paymentDetails", isA(String.class)).and().body("trades[0].sellerPaymentAccount.countryCode", equalTo(bobPaymentAccount.countryCode)).and().body("trades[0].sellerPaymentAccount.holderName", equalTo(bobPaymentAccount.holderName)).and().body("trades[0].sellerPaymentAccount.bic", equalTo(bobPaymentAccount.bic)).and().body("trades[0].sellerPaymentAccount.iban", equalTo(bobPaymentAccount.iban)).and().body("trades[0].sellerPaymentAccount.acceptedCountries", equalTo(bobPaymentAccount.acceptedCountries)).and().body("trades[0].isCurrencyForTakerFeeBtc", equalTo(true)).and().body("trades[0].txFee", isA(Integer.class)).and().body("trades[0].takerFee", isA(Integer.class)).and().body("trades[0].takeOfferDate", isA(Long.class)).and().body("trades[0].takerFeeTxId", isA(String.class)).and().body("trades[0].payoutTxId", isEmptyOrNullString()).and().body("trades[0].tradeAmount", equalTo(1)).and().body("trades[0].tradePrice", equalTo(10)).and().body("trades[0].state", isOneOf(ApiTestHelper.toString(Trade.State.values()))).and().body("trades[0].disputeState", equalTo(Trade.DisputeState.NO_DISPUTE.name())).and().body("trades[0].tradePeriodState", equalTo(Trade.TradePeriodState.FIRST_HALF.name())).and().body("trades[0].arbitratorBtcPubKey", isA(String.class)).and().body("trades[0].contractHash", isA(String.class)).and().body("trades[0].mediatorNodeAddress", isA(String.class)).and().body("trades[0].takerContractSignature", isA(String.class)).and().body("trades[0].makerContractSignature", isEmptyOrNullString()).and().body("trades[0].arbitratorNodeAddress", isA(String.class)).and().body("trades[0].tradingPeerNodeAddress", isA(String.class)).and().body("trades[0].takerPaymentAccountId", equalTo(bobPaymentAccount.id)).and().body("trades[0].counterCurrencyTxId", isEmptyOrNullString());
}
Also used : SepaPaymentAccount(io.bisq.api.model.payment.SepaPaymentAccount) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Aggregations

SepaPaymentAccount (io.bisq.api.model.payment.SepaPaymentAccount)3 Faker (com.github.javafaker.Faker)1 InSequence (org.jboss.arquillian.junit.InSequence)1 Test (org.junit.Test)1