Search in sources :

Example 1 with MosaicName

use of io.nem.sdk.model.mosaic.MosaicName 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

TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 PublicAccount (io.nem.sdk.model.account.PublicAccount)1 NetworkType (io.nem.sdk.model.blockchain.NetworkType)1 MosaicId (io.nem.sdk.model.mosaic.MosaicId)1 MosaicInfo (io.nem.sdk.model.mosaic.MosaicInfo)1 MosaicName (io.nem.sdk.model.mosaic.MosaicName)1 MosaicProperties (io.nem.sdk.model.mosaic.MosaicProperties)1 NamespaceId (io.nem.sdk.model.namespace.NamespaceId)1 UInt64 (io.nem.sdk.model.transaction.UInt64)1 Observable (io.reactivex.Observable)1 JsonObject (io.vertx.core.json.JsonObject)1 HttpResponse (io.vertx.reactivex.ext.web.client.HttpResponse)1 BodyCodec (io.vertx.reactivex.ext.web.codec.BodyCodec)1 MalformedURLException (java.net.MalformedURLException)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1