use of com.meniga.sdk.helpers.KeyVal in project mobile-sdk-android by meniga.
the class MenigaAccountApiTest method shouldFetchMetadataByName.
@Test
public void shouldFetchMetadataByName() throws Exception {
server.enqueue(new MockResponse());
MenigaAccount account = MenigaAccountFactory.createAccount();
Task<KeyVal<String, String>> task = account.fetchMetadataKeyVal("Valid to").getTask();
task.waitForCompletion();
RecordedRequest request = server.takeRequest();
assertThat(request.getPath()).isEqualTo("/v1/accounts/0/metadata/Valid%20to");
assertThat(request.getMethod()).isEqualTo("GET");
}
use of com.meniga.sdk.helpers.KeyVal in project mobile-sdk-android by meniga.
the class MenigaAccountApiTest method shouldUpdateMetadata.
@Test
public void shouldUpdateMetadata() throws Exception {
server.enqueue(new MockResponse());
MenigaAccount account = MenigaAccountFactory.createAccount();
Task<KeyVal<String, String>> task = account.updateMetadata(KeyVal.of("Valid to", "01/2100")).getTask();
task.waitForCompletion();
RecordedRequest request = server.takeRequest();
assertThat(request.getPath()).isEqualTo("/v1/accounts/0/metadata");
assertThat(request.getMethod()).isEqualTo("PUT");
JsonAssert.with(request.getBody().readUtf8()).assertThat("$.name", equalTo("Valid to")).assertThat("$.value", equalTo("01/2100"));
}
use of com.meniga.sdk.helpers.KeyVal in project mobile-sdk-android by meniga.
the class MenigaIdNameKeyValConverter method responseBodyConverter.
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
Type typeListOfNetWorthType = new TypeToken<List<KeyVal<Long, String>>>() {
}.getType();
if (typeListOfNetWorthType.equals(type)) {
return new Converter<ResponseBody, Object>() {
@Override
public Object convert(ResponseBody value) throws IOException {
List<KeyVal<Long, String>> list = new ArrayList<>();
JsonArray arr = getAsArray(value.byteStream());
for (int i = 0; i < arr.size(); i++) {
JsonObject entry = (JsonObject) arr.get(i);
KeyVal<Long, String> item = new KeyVal<>(entry.get("id").getAsLong(), entry.get("name").getAsString());
list.add(item);
}
return list;
}
};
}
return null;
}
use of com.meniga.sdk.helpers.KeyVal in project mobile-sdk-android by meniga.
the class MenigaAccountApiTest method shouldFetchMetadata.
@Test
public void shouldFetchMetadata() throws Exception {
MenigaAccount account = MenigaAccountFactory.createAccount();
server.enqueue(mockResponse("accountmetadata.json"));
Task<List<KeyVal<String, String>>> task = account.fetchMetadata().getTask();
task.waitForCompletion();
RecordedRequest request = server.takeRequest();
assertThat(request.getPath()).isEqualTo("/v1/accounts/0/metadata");
assertThat(request.getMethod()).isEqualTo("GET");
List<KeyVal<String, String>> result = task.getResult();
assertThat(result.get(0).getKey()).isEqualTo("Card holder");
assertThat(result.get(0).getValue()).isEqualTo("John Bob");
assertThat(result.get(1).getKey()).isEqualTo("Card number");
assertThat(result.get(1).getValue()).isEqualTo("1234 XXXX XXXX 5432");
assertThat(result.get(2).getKey()).isEqualTo("Valid to");
assertThat(result.get(2).getValue()).isEqualTo("12/2026");
}
use of com.meniga.sdk.helpers.KeyVal in project mobile-sdk-android by meniga.
the class MenigaRealmAuthParameter method getDropDownValues.
public List<KeyVal<String, String>> getDropDownValues() {
JsonParser parser = new JsonParser();
JsonElement elements = parser.parse(dropDownValues);
JsonArray values = elements.getAsJsonArray();
List<KeyVal<String, String>> entries = new ArrayList<>();
for (int i = 0; i < values.size(); i++) {
JsonObject item = values.get(i).getAsJsonObject();
KeyVal<String, String> entry = new KeyVal<>(item.get("Name").getAsString(), item.get("Value").getAsString());
entries.add(entry);
}
return entries;
}
Aggregations