class NamespaceRepositoryOkHttpImpl extends AbstractRepositoryOkHttpImpl implements NamespaceRepository {

  @Override
  public Observable<Page<NamespaceInfo>> search(NamespaceSearchCriteria criteria) {

    String ownerAddress = toDto(criteria.getOwnerAddress());
    NamespaceRegistrationTypeEnum registrationType =
        criteria.getRegistrationType() == null
            ? null
            : NamespaceRegistrationTypeEnum.fromValue(criteria.getRegistrationType().getValue());
    String level0 = criteria.getLevel0();
    AliasTypeEnum aliasType =
        criteria.getAliasType() == null
            ? null
            : AliasTypeEnum.fromValue(criteria.getAliasType().getValue());
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    String offset = criteria.getOffset();
    Order order = toDto(criteria.getOrder());
    Callable<NamespacePage> callback =
        () ->
            getClient()
                .searchNamespaces(
                    ownerAddress,
                    registrationType,
                    level0,
                    aliasType,
                    pageSize,
                    pageNumber,
                    offset,
                    order);

    return exceptionHandling(
        call(callback)
            .map(
                page ->
                    this.toPage(
                        page.getPagination(),
                        page.getData().stream()
                            .map(this::toNamespaceInfo)
                            .collect(Collectors.toList()))));
  }

  public  NamespaceRepositoryOkHttpImpl(ApiClient apiClient);

}