Search in sources :

Example 11 with MosaicId

use of io.nem.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class MosaicHttp method getMosaicNames.

@Override
public Observable<List<MosaicName>> getMosaicNames(List<MosaicId> mosaicIds) {
    JsonObject requestBody = new JsonObject();
    requestBody.put("mosaicIds", mosaicIds.stream().map(id -> UInt64.bigIntegerToHex(id.getId())).collect(Collectors.toList()));
    return this.client.postAbs(this.url + "/mosaic/names").as(BodyCodec.jsonArray()).rxSendJson(requestBody).toObservable().map(HttpResponse::body).map(json -> objectMapper.<List<MosaicNameDTO>>readValue(json.toString(), new TypeReference<List<MosaicNameDTO>>() {
    })).flatMapIterable(item -> item).map(mosaicNameDTO -> new MosaicName(new MosaicId(mosaicNameDTO.getMosaicId().extractIntArray()), mosaicNameDTO.getName(), new NamespaceId(mosaicNameDTO.getParentId().extractIntArray()))).toList().toObservable();
}
Also used : HttpResponse(io.vertx.reactivex.ext.web.client.HttpResponse) MalformedURLException(java.net.MalformedURLException) MosaicName(io.nem.sdk.model.mosaic.MosaicName) MosaicInfo(io.nem.sdk.model.mosaic.MosaicInfo) NetworkType(io.nem.sdk.model.blockchain.NetworkType) Collectors(java.util.stream.Collectors) UInt64(io.nem.sdk.model.transaction.UInt64) List(java.util.List) PublicAccount(io.nem.sdk.model.account.PublicAccount) BodyCodec(io.vertx.reactivex.ext.web.codec.BodyCodec) MosaicProperties(io.nem.sdk.model.mosaic.MosaicProperties) NamespaceId(io.nem.sdk.model.namespace.NamespaceId) Optional(java.util.Optional) Observable(io.reactivex.Observable) JsonObject(io.vertx.core.json.JsonObject) TypeReference(com.fasterxml.jackson.core.type.TypeReference) MosaicId(io.nem.sdk.model.mosaic.MosaicId) MosaicId(io.nem.sdk.model.mosaic.MosaicId) JsonObject(io.vertx.core.json.JsonObject) TypeReference(com.fasterxml.jackson.core.type.TypeReference) NamespaceId(io.nem.sdk.model.namespace.NamespaceId) MosaicName(io.nem.sdk.model.mosaic.MosaicName)

Aggregations

MosaicId (io.nem.sdk.model.mosaic.MosaicId)11 BigInteger (java.math.BigInteger)7 Mosaic (io.nem.sdk.model.mosaic.Mosaic)6 Test (org.junit.jupiter.api.Test)6 Address (io.nem.sdk.model.account.Address)4 PublicAccount (io.nem.sdk.model.account.PublicAccount)4 NetworkType (io.nem.sdk.model.blockchain.NetworkType)4 NamespaceId (io.nem.sdk.model.namespace.NamespaceId)4 JsonObject (io.vertx.core.json.JsonObject)4 List (java.util.List)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 TypeReference (com.fasterxml.jackson.core.type.TypeReference)3 MosaicProperties (io.nem.sdk.model.mosaic.MosaicProperties)3 Observable (io.reactivex.Observable)3 HttpResponse (io.vertx.reactivex.ext.web.client.HttpResponse)3 BodyCodec (io.vertx.reactivex.ext.web.codec.BodyCodec)3 MalformedURLException (java.net.MalformedURLException)3 DisplayName (org.junit.jupiter.api.DisplayName)3 MosaicInfo (io.nem.sdk.model.mosaic.MosaicInfo)2