Search in sources :

Example 1 with Preferences

use of network.bisq.api.model.Preferences in project bisq-api by mrosseel.

the class BisqProxy method getPreferences.

public Preferences getPreferences() {
    final Preferences preferences = new Preferences();
    preferences.autoSelectArbitrators = this.preferences.isAutoSelectArbitrators();
    preferences.baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode();
    preferences.blockChainExplorer = this.preferences.getBlockChainExplorer().name;
    preferences.cryptoCurrencies = tradeCurrenciesToCodes(this.preferences.getCryptoCurrencies());
    preferences.fiatCurrencies = tradeCurrenciesToCodes(this.preferences.getFiatCurrencies());
    preferences.ignoredTraders = this.preferences.getIgnoreTradersList();
    preferences.maxPriceDistance = this.preferences.getMaxPriceDistanceInPercent();
    preferences.preferredTradeCurrency = this.preferences.getPreferredTradeCurrency().getCode();
    preferences.useCustomWithdrawalTxFee = this.preferences.getUseCustomWithdrawalTxFeeProperty().get();
    final Country userCountry = this.preferences.getUserCountry();
    if (null != userCountry)
        preferences.userCountry = userCountry.code;
    preferences.userLanguage = this.preferences.getUserLanguage();
    preferences.withdrawalTxFee = this.preferences.getWithdrawalTxFeeInBytes();
    return preferences;
}
Also used : Country(bisq.core.locale.Country) Preferences(network.bisq.api.model.Preferences)

Example 2 with Preferences

use of network.bisq.api.model.Preferences in project bisq-api by mrosseel.

the class PreferencesResourceIT method setPreferences_unsupportedPreferredTradeCurrency_returns422.

@InSequence(3)
@Test
public void setPreferences_unsupportedPreferredTradeCurrency_returns422() {
    final Preferences preferences = new Preferences();
    preferences.preferredTradeCurrency = "ABC";
    given().port(getAlicePort()).body(preferences).contentType(ContentType.JSON).when().put("/api/v1/preferences").then().statusCode(422).body("errors.size()", equalTo(1)).body("errors[0]", equalTo("Unsupported trade currency code: ABC"));
    getPreferences_always_returns200();
}
Also used : Preferences(network.bisq.api.model.Preferences) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 3 with Preferences

use of network.bisq.api.model.Preferences in project bisq-api by mrosseel.

the class PreferencesResourceIT method setPreferences_validPartialPayload_returns200.

@InSequence(4)
@Test
public void setPreferences_validPartialPayload_returns200() {
    final Preferences preferences = new Preferences();
    preferences.autoSelectArbitrators = true;
    given().port(getAlicePort()).body(preferences).contentType(ContentType.JSON).when().put("/api/v1/preferences").then().statusCode(200).body("autoSelectArbitrators", equalTo(preferences.autoSelectArbitrators)).body("baseCurrencyNetwork", equalTo(savedPreferences.baseCurrencyNetwork)).body("blockChainExplorer", equalTo(savedPreferences.blockChainExplorer)).body("cryptoCurrencies", equalTo(savedPreferences.cryptoCurrencies)).body("fiatCurrencies", equalTo(savedPreferences.fiatCurrencies)).body("ignoredTraders", equalTo(Arrays.asList("jes", "ber:3333"))).body("maxPriceDistance", equalTo(savedPreferences.maxPriceDistance.floatValue())).body("preferredTradeCurrency", equalTo(savedPreferences.preferredTradeCurrency)).body("useCustomWithdrawalTxFee", equalTo(savedPreferences.useCustomWithdrawalTxFee)).body("userCountry", equalTo(savedPreferences.userCountry)).body("userLanguage", equalTo(savedPreferences.userLanguage)).body("withdrawalTxFee", equalTo(savedPreferences.withdrawalTxFee.intValue()));
}
Also used : Preferences(network.bisq.api.model.Preferences) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 4 with Preferences

use of network.bisq.api.model.Preferences in project bisq-api by mrosseel.

the class PreferencesResourceIT method setPreferences_nullIgnoredTraders_returns422.

@InSequence(3)
@Test
public void setPreferences_nullIgnoredTraders_returns422() {
    final Preferences preferences = new Preferences();
    preferences.ignoredTraders = Collections.singletonList(null);
    given().port(getAlicePort()).body(preferences).contentType(ContentType.JSON).when().put("/api/v1/preferences").then().statusCode(422).body("errors.size()", equalTo(1)).body("errors[0]", equalTo("ignoredTraders must not contain null elements"));
    getPreferences_always_returns200();
}
Also used : Preferences(network.bisq.api.model.Preferences) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 5 with Preferences

use of network.bisq.api.model.Preferences in project bisq-api by mrosseel.

the class PreferencesResourceIT method setPreferences_baseCurrencyNetwork_returns422.

@InSequence(3)
@Test
public void setPreferences_baseCurrencyNetwork_returns422() {
    final Preferences preferences = new Preferences();
    preferences.baseCurrencyNetwork = "LTC";
    given().port(getAlicePort()).body(preferences).contentType(ContentType.JSON).when().put("/api/v1/preferences").then().statusCode(422).body("errors.size()", equalTo(1)).body("errors[0]", equalTo("Changing baseCurrencyNetwork is not supported"));
    getPreferences_always_returns200();
}
Also used : Preferences(network.bisq.api.model.Preferences) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Aggregations

Preferences (network.bisq.api.model.Preferences)13 InSequence (org.jboss.arquillian.junit.InSequence)12 Test (org.junit.Test)12 Country (bisq.core.locale.Country)1 ArrayList (java.util.ArrayList)1