当前位置: 首页>>代码示例>>Java>>正文


Java Group类代码示例

本文整理汇总了Java中com.foursquare4j.response.Group的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Group类属于com.foursquare4j.response包,在下文中一共展示了Group类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUserVenueLikes

import com.foursquare4j.response.Group; //导入依赖的package包/类
/**
 * Returns a list of venues liked by the specified user.
 * 
 * @param userId User ID or self.
 * @param beforeTimestamp Seconds since epoch..
 * @param afterTimestamp Seconds since epoch.
 * @param categoryId Limits returned venues to those in this category. If specifying a top-level
 *        category, all sub-categories will also match the query.
 * @param limit Number of results to return.
 * @param offset Used to page through results.
 * @return a Group of Venues wrapped in a Result object.
 */
public Result<Group<Venue>> getUserVenueLikes(String userId, Long beforeTimestamp, 
        Long afterTimestamp, String categoryId, Integer limit, Integer offset) {
    HttpUrl.Builder urlBuilder = newApiUrlBuilder()
            .addPathSegment("users")
            .addPathSegment(userId)
            .addPathSegment("venuelikes");
    if (beforeTimestamp != null) urlBuilder.addQueryParameter("beforeTimestamp", String.valueOf(beforeTimestamp));
    if (afterTimestamp != null) urlBuilder.addQueryParameter("afterTimestamp", String.valueOf(afterTimestamp));
    if (categoryId != null) urlBuilder.addQueryParameter("categoryId", categoryId);
    if (limit != null) urlBuilder.addQueryParameter("limit", String.valueOf(limit));
    if (offset != null) urlBuilder.addQueryParameter("offset", String.valueOf(offset));
    String json = newRequest(urlBuilder.toString());
    LOGGER.debug("Response ---> {}", json);
    return Parser.parse(json, "venues", new TypeToken<Group<Venue>>(){});
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:28,代码来源:FoursquareApi.java

示例2: collectLikesFrom

import com.foursquare4j.response.Group; //导入依赖的package包/类
private Set<Category> collectLikesFrom(String userId, FoursquareApi foursquareApi) {
    Result<Group<Venue>> venueLikes = foursquareApi.getUserVenueLikes(userId, null, null, null, null, null);
    if (venueLikes.getMeta().getCode() == 200) {
        Set<Category> myCategories = new HashSet<>();
        for (Venue venue : venueLikes.getResponse().getItems()) {
            for (com.foursquare4j.response.Category category : venue.getCategories()) {
                Category myCategory = new Category();
                myCategory.setFoursquareId(category.getId());
                myCategories.add(myCategory);
            }
        }
        return myCategories;
    } else {
        LOGGER.error("Foursquare error while requesting [user/venuelikes] [code={}, errorType={}, errorDetail={}]", venueLikes.getMeta().getCode(), venueLikes.getMeta().getErrorType(), venueLikes.getMeta().getErrorDetail());
        throw new DaoException.Builder()
            .messageKey("foursquare.request.error")
            .addMessageArgument(venueLikes.getMeta().getErrorDetail())
            .build();
    }
}
 
开发者ID:dan-zx,项目名称:rox-server,代码行数:21,代码来源:FoursquareProfileDao.java

示例3: findNearLocations

import com.foursquare4j.response.Group; //导入依赖的package包/类
@Override
public List<Poi> findNearLocations(Location... locations) {
    FoursquareApi foursquareApi = getFoursquareApi();
    List<Poi> pois = new ArrayList<>(locations.length);
    for (Location location : locations) {
        Result<ExploreVenueGroups> exploreResult = foursquareApi.exploreVenues(location.stringValues(), null, null, null, null, null, null, null, 50, null, null, null, null, null, null, null, null, null, null, null, null);
        if (exploreResult.getMeta().getCode() == 200) {
            for (Group<VenueRecommendation> group : exploreResult.getResponse().getGroups()) {
                Arrays.stream(group.getItems()).forEach(venueRecommendation -> pois.add(toPoi(venueRecommendation.getVenue())));
            }
        } else throw new DaoException.Builder().messageKey("foursquare.request.error").addMessageArgument(exploreResult.getMeta().getErrorDetail()).build();
    }
    return pois;
}
 
开发者ID:dan-zx,项目名称:rox-db-support,代码行数:15,代码来源:PoiFoursquareDao.java

示例4: getUserFriends

import com.foursquare4j.response.Group; //导入依赖的package包/类
/**
 * Returns an array of a user's friends.
 * 
 * @param userId Identity of the user to get friends of. Pass self to get friends of the acting
 *        user.
 * @param limit Number of results to return, up to 500.
 * @param offset Used to page through results.
 * @return a Group of Users wrapped in a Result object.
 */
public Result<Group<User>> getUserFriends(String userId, Integer limit, Integer offset) {
    HttpUrl.Builder urlBuilder = newApiUrlBuilder()
            .addPathSegment("users")
            .addPathSegment(userId)
            .addPathSegment("friends");
    if (limit != null) urlBuilder.addQueryParameter("limit", String.valueOf(limit));
    if (offset != null) urlBuilder.addQueryParameter("offset", String.valueOf(offset));
    String json = newRequest(urlBuilder.toString());
    LOGGER.debug("Response ---> {}", json);
    return Parser.parse(json, "friends", new TypeToken<Group<User>>(){});
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:21,代码来源:FoursquareApi.java

示例5: getNextVenues

import com.foursquare4j.response.Group; //导入依赖的package包/类
/**
 * Returns venues that people often check in to after the current venue. Up to 5 venues are
 * returned in each query, and results are sorted by how many people have visited that venue
 * after the current one. Homes are never returned in results.
 * 
 * @param venueId ID of the venue you want to see next venue information about.
 * @return Compact venues.
 */
public Result<Group<Venue>> getNextVenues(String venueId) {
    String url = newApiUrlBuilder()
            .addPathSegment("venues")
            .addPathSegment(venueId)
            .addPathSegment("nextvenues")
            .toString();
    String json = newRequest(url);
    LOGGER.debug("Response ---> {}", json);
    return Parser.parse(json, "nextVenues", new TypeToken<Group<Venue>>(){});
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:19,代码来源:FoursquareApi.java

示例6: testGetUserFriends

import com.foursquare4j.response.Group; //导入依赖的package包/类
@Test
public void testGetUserFriends() throws Exception {
    foursquareApi.setAccessToken(configs.getProperty("foursquare.app.access_token"));
    Result<Group<User>> actualResult = foursquareApi.getUserFriends("self", null, null);
    foursquareApi.setAccessToken(null);

    assertThat(actualResult).isNotNull();
    assertThat(actualResult.getMeta()).isNotNull();
    assertThat(actualResult.getMeta().getCode()).isNotNull().isEqualTo(200);
    assertThat(actualResult.getResponse()).isNotNull();
    assertThat(actualResult.getResponse().getCount()).isNotNull();
    assertThat(actualResult.getResponse().getItems()).isNotNull().isNotEmpty();
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:14,代码来源:FoursquareApiTest.java

示例7: testGetUserVenueLikes

import com.foursquare4j.response.Group; //导入依赖的package包/类
@Test
public void testGetUserVenueLikes() throws Exception {
    foursquareApi.setAccessToken(configs.getProperty("foursquare.app.access_token"));
    Result<Group<Venue>> actualResult = foursquareApi.getUserVenueLikes("57562206", null, null, null, null, null);
    foursquareApi.setAccessToken(null);

    assertThat(actualResult).isNotNull();
    assertThat(actualResult.getMeta()).isNotNull();
    assertThat(actualResult.getMeta().getCode()).isNotNull().isEqualTo(200);
    assertThat(actualResult.getResponse()).isNotNull();
    assertThat(actualResult.getResponse().getCount()).isNotNull();
    assertThat(actualResult.getResponse().getItems()).isNotNull().isNotEmpty();
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:14,代码来源:FoursquareApiTest.java

示例8: testGetNextVenues

import com.foursquare4j.response.Group; //导入依赖的package包/类
@Test 
public void testGetNextVenues() throws Exception {
    Result<Group<Venue>> actualResult = foursquareApi.getNextVenues("4b9d70a1f964a520e2ac36e3");

    assertThat(actualResult).isNotNull();
    assertThat(actualResult.getMeta()).isNotNull();
    assertThat(actualResult.getMeta().getCode()).isNotNull().isEqualTo(200);
    assertThat(actualResult.getResponse()).isNotNull();
    assertThat(actualResult.getResponse().getCount()).isNotNull();
    assertThat(actualResult.getResponse().getItems()).isNotNull().isNotEmpty();
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:12,代码来源:FoursquareApiTest.java

示例9: testGetUserFriends

import com.foursquare4j.response.Group; //导入依赖的package包/类
@Test
public void testGetUserFriends() throws Exception {
    mockWebServer.enqueue(new MockResponse()
        .setStatus(HttpStatus.OK.toString())
        .setBody(getJsonFrom("responses/friends.json")));

    Result<Group<User>> actualResult = foursquareApi.getUserFriends("any", null, null);
    
    assertThat(actualResult).isNotNull();
    assertThat(actualResult.getMeta()).isNotNull();
    assertThat(actualResult.getMeta().getCode()).isNotNull().isEqualTo(200);
    assertThat(actualResult.getResponse()).isNotNull();
    assertThat(actualResult.getResponse().getCount()).isNotNull();
    assertThat(actualResult.getResponse().getItems()).isNotNull().isNotEmpty();
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:16,代码来源:FoursquareApiMockTest.java

示例10: testGetUserVenueLikes

import com.foursquare4j.response.Group; //导入依赖的package包/类
@Test
public void testGetUserVenueLikes() throws Exception {
    mockWebServer.enqueue(new MockResponse()
        .setStatus(HttpStatus.OK.toString())
        .setBody(getJsonFrom("responses/venuelikes.json")));

    Result<Group<Venue>> actualResult = foursquareApi.getUserVenueLikes("any", null, null, null, null, null);
    
    assertThat(actualResult).isNotNull();
    assertThat(actualResult.getMeta()).isNotNull();
    assertThat(actualResult.getMeta().getCode()).isNotNull().isEqualTo(200);
    assertThat(actualResult.getResponse()).isNotNull();
    assertThat(actualResult.getResponse().getCount()).isNotNull();
    assertThat(actualResult.getResponse().getItems()).isNotNull().isNotEmpty();
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:16,代码来源:FoursquareApiMockTest.java

示例11: testGetNextVenues

import com.foursquare4j.response.Group; //导入依赖的package包/类
@Test 
public void testGetNextVenues() throws Exception {
    mockWebServer.enqueue(new MockResponse()
        .setStatus(HttpStatus.OK.toString())
        .setBody(getJsonFrom("responses/nextvenues.json")));

    Result<Group<Venue>> actualResult = foursquareApi.getNextVenues("4b9d70a1f964a520e2ac36e3");
    
    assertThat(actualResult).isNotNull();
    assertThat(actualResult.getMeta()).isNotNull();
    assertThat(actualResult.getMeta().getCode()).isNotNull().isEqualTo(200);
    assertThat(actualResult.getResponse()).isNotNull();
    assertThat(actualResult.getResponse().getCount()).isNotNull();
    assertThat(actualResult.getResponse().getItems()).isNotNull().isNotEmpty();
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:16,代码来源:FoursquareApiMockTest.java

示例12: testError

import com.foursquare4j.response.Group; //导入依赖的package包/类
@Test 
public void testError() throws Exception {
    mockWebServer.enqueue(new MockResponse()
        .setStatus(HttpStatus.INTERNAL_SERVER_ERROR.toString())
        .setBody(getJsonFrom("responses/error.json")));

    Result<Group<Venue>> actualResult = foursquareApi.getNextVenues("whatever");
    
    assertThat(actualResult).isNotNull();
    assertThat(actualResult.getMeta()).isNotNull();
    assertThat(actualResult.getMeta().getCode()).isNotNull().isEqualTo(500);
    assertThat(actualResult.getMeta().getErrorType()).isNotNull().isEqualTo("generic_error");
    assertThat(actualResult.getMeta().getErrorDetail()).isNotNull().isEqualTo("Generic error");
    assertThat(actualResult.getResponse()).isNull();
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:16,代码来源:FoursquareApiMockTest.java

示例13: collectUserData

import com.foursquare4j.response.Group; //导入依赖的package包/类
protected User collectUserData(FoursquareApi foursquareApi) {
    LOGGER.trace("Collecting user data...");
    Result<com.foursquare4j.response.User> foursquareUser = foursquareApi.getUser("self");
    if (foursquareUser.getMeta().getCode() == 200) {
        User user = toUser(foursquareUser.getResponse());
        user.setLikes(collectLikesFrom("self", foursquareApi));
        Result<Group<com.foursquare4j.response.User>> foursquareFriends = foursquareApi.getUserFriends("self", 500, null);
        if (foursquareFriends.getMeta().getCode() == 200) {
            Set<User> friends = new HashSet<>();
            for (com.foursquare4j.response.User foursquareFriend : foursquareFriends.getResponse().getItems()) {
                User friend = toUser(foursquareFriend);
                friend.setLikes(collectLikesFrom(foursquareFriend.getId(), foursquareApi));
                friends.add(friend);
            }
            user.setFriends(friends);
        } else {
            LOGGER.error("Foursquare error while requesting [user/friends] [code={}, errorType={}, errorDetail={}]", foursquareFriends.getMeta().getCode(), foursquareFriends.getMeta().getErrorType(), foursquareFriends.getMeta().getErrorDetail());
            throw new DaoException.Builder()
                .messageKey("foursquare.request.error")
                .addMessageArgument(foursquareFriends.getMeta().getErrorDetail())
                .build();
        }
        LOGGER.trace("Done");
        return user;
    } else {
        LOGGER.error("Foursquare error while requesting [user/self] [code={}, errorType={}, errorDetail={}]", foursquareUser.getMeta().getCode(), foursquareUser.getMeta().getErrorType(), foursquareUser.getMeta().getErrorDetail());
        throw new DaoException.Builder()
            .messageKey("foursquare.request.error")
            .addMessageArgument(foursquareUser.getMeta().getErrorDetail())
            .build();
    }
}
 
开发者ID:dan-zx,项目名称:rox-server,代码行数:33,代码来源:FoursquareProfileDao.java

示例14: fetchNext

import com.foursquare4j.response.Group; //导入依赖的package包/类
protected List<Poi> fetchNext(FoursquareApi foursquareApi, String poiFoursquareId, int limit) {
    Result<Venue> venueResult = foursquareApi.getVenue(poiFoursquareId);
    if (venueResult.getMeta().getCode() == 200) {
        Poi seed = toPoi(venueResult.getResponse());
        Set<String> categoryIds = new HashSet<>();
        categoryIds.addAll(seed.getCategories().stream().map(Category::getFoursquareId).collect(Collectors.toSet()));
        List<Poi> pois = new ArrayList<>(limit);
        Poi currentPoi = seed;
        for (int numberOfPois = 0; numberOfPois < limit-1; numberOfPois++) {
            Result<Group<Venue>> nextVenues = foursquareApi.getNextVenues(currentPoi.getFoursquareId());
            if (nextVenues.getMeta().getCode() == 200) {
                for (Venue venue : nextVenues.getResponse().getItems()) {
                    currentPoi = toPoi(venue);
                    final String currentFoursquarId = venue.getId();
                    List<Poi> matchingPois = pois.stream().filter(poi -> poi.getFoursquareId().equals(currentFoursquarId)).collect(Collectors.toList());
                    if (matchingPois.isEmpty()) {
                        boolean existsCategory = false;
                        for (Category currentPoiCategory : currentPoi.getCategories()) {
                            if (!categoryIds.add(currentPoiCategory.getFoursquareId())) {
                                existsCategory = true;
                                break;
                            }
                        }
                        if (!existsCategory) {
                            pois.add(currentPoi);
                            break;
                        }
                    }
                }
            } else {
                LOGGER.error("Foursquare error while requesting [venues/{}/nextvenues] [code={}, errorType={}, errorDetail={}]", currentPoi.getFoursquareId(), nextVenues.getMeta().getCode(), nextVenues.getMeta().getErrorType(), nextVenues.getMeta().getErrorDetail());
                throw new DaoException.Builder()
                    .messageKey("foursquare.request.error")
                    .addMessageArgument(nextVenues.getMeta().getErrorDetail())
                    .build();
            }
        }
        return pois;
    } else {
        LOGGER.error("Foursquare error while requesting [venues/{}] [code={}, errorType={}, errorDetail={}]", poiFoursquareId, venueResult.getMeta().getCode(), venueResult.getMeta().getErrorType(), venueResult.getMeta().getErrorDetail());
        throw new DaoException.Builder()
            .messageKey("foursquare.request.error")
            .addMessageArgument(venueResult.getMeta().getErrorDetail())
            .build();
    }
}
 
开发者ID:dan-zx,项目名称:rox-server,代码行数:47,代码来源:PoiFoursquareDao.java


注:本文中的com.foursquare4j.response.Group类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。