Search in sources :

Example 1 with AllowedMoneySource

use of com.yandex.money.api.model.AllowedMoneySource in project yandex-money-sdk-java by yandex-money.

the class ShowcaseProcessTest method getEmptyShowcase.

private static Showcase getEmptyShowcase() {
    Group.Builder builder = new Group.Builder();
    Group group = builder.create();
    return new Showcase.Builder().setTitle("foo").setErrors(Collections.<Showcase.Error>emptyList()).setForm(group).setHiddenFields(Collections.<String, String>emptyMap()).setMoneySources(Collections.<AllowedMoneySource>emptyList()).create();
}
Also used : Group(com.yandex.money.api.model.showcase.components.containers.Group) Showcase(com.yandex.money.api.model.showcase.Showcase) AllowedMoneySource(com.yandex.money.api.model.AllowedMoneySource)

Example 2 with AllowedMoneySource

use of com.yandex.money.api.model.AllowedMoneySource in project yandex-money-sdk-java by yandex-money.

the class ShowcaseTypeAdapter method deserialize.

@Override
public Showcase deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    JsonObject object = json.getAsJsonObject();
    Group form = null;
    JsonArray array = object.getAsJsonArray(MEMBER_FORM);
    if (array != null) {
        form = ListDelegate.deserialize(array, context);
    }
    List<AllowedMoneySource> moneySources = context.deserialize(object.get(MEMBER_MONEY_SOURCE), new TypeToken<List<AllowedMoneySource>>() {
    }.getType());
    List<Error> errors = ErrorTypeAdapter.getInstance().fromJson(object.getAsJsonArray(MEMBER_ERROR));
    return new Showcase.Builder().setTitle(getString(object, MEMBER_TITLE)).setHiddenFields(getNotNullMap(object, MEMBER_HIDDEN_FIELDS)).setForm(form).setMoneySources(toEmptyListIfNull(moneySources)).setErrors(toEmptyListIfNull(errors)).create();
}
Also used : JsonArray(com.google.gson.JsonArray) Group(com.yandex.money.api.model.showcase.components.containers.Group) AllowedMoneySource(com.yandex.money.api.model.AllowedMoneySource) TypeToken(com.google.gson.reflect.TypeToken) JsonObject(com.google.gson.JsonObject) JsonUtils.toJsonObject(com.yandex.money.api.typeadapters.JsonUtils.toJsonObject) Error(com.yandex.money.api.model.showcase.Showcase.Error)

Aggregations

AllowedMoneySource (com.yandex.money.api.model.AllowedMoneySource)2 Group (com.yandex.money.api.model.showcase.components.containers.Group)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 TypeToken (com.google.gson.reflect.TypeToken)1 Showcase (com.yandex.money.api.model.showcase.Showcase)1 Error (com.yandex.money.api.model.showcase.Showcase.Error)1 JsonUtils.toJsonObject (com.yandex.money.api.typeadapters.JsonUtils.toJsonObject)1