001/*
002 * Copyright (c) 2012, the Last.fm Java Project and Committers
003 * All rights reserved.
004 *
005 * Redistribution and use of this software in source and binary forms, with or without modification, are
006 * permitted provided that the following conditions are met:
007 *
008 * - Redistributions of source code must retain the above
009 *   copyright notice, this list of conditions and the
010 *   following disclaimer.
011 *
012 * - Redistributions in binary form must reproduce the above
013 *   copyright notice, this list of conditions and the
014 *   following disclaimer in the documentation and/or other
015 *   materials provided with the distribution.
016 *
017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
018 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
019 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
020 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
021 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
023 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
024 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
025 */
026
027package de.umass.lastfm;
028
029import java.util.Collection;
030import java.util.LinkedHashMap;
031
032/**
033 * Provides nothing more than a namespace for the API methods starting with group.
034 *
035 * @author Janni Kovacs
036 */
037public class Group {
038
039        private Group() {
040        }
041
042        public static Chart<Album> getWeeklyAlbumChart(String group, String apiKey) {
043                return getWeeklyAlbumChart(group, null, null, -1, apiKey);
044        }
045
046        public static Chart<Album> getWeeklyAlbumChart(String group, int limit, String apiKey) {
047                return getWeeklyAlbumChart(group, null, null, limit, apiKey);
048        }
049
050        public static Chart<Album> getWeeklyAlbumChart(String group, String from, String to, int limit, String apiKey) {
051                return Chart.getChart("group.getWeeklyAlbumChart", "group", group, "album", from, to, limit, apiKey);
052        }
053
054        public static Chart<Artist> getWeeklyArtistChart(String group, String apiKey) {
055                return getWeeklyArtistChart(group, null, null, -1, apiKey);
056        }
057
058        public static Chart<Artist> getWeeklyArtistChart(String group, int limit, String apiKey) {
059                return getWeeklyArtistChart(group, null, null, limit, apiKey);
060        }
061
062        public static Chart<Artist> getWeeklyArtistChart(String group, String from, String to, int limit, String apiKey) {
063                return Chart.getChart("group.getWeeklyArtistChart", "group", group, "artist", from, to, limit, apiKey);
064        }
065
066        public static Chart<Track> getWeeklyTrackChart(String group, String apiKey) {
067                return getWeeklyTrackChart(group, null, null, -1, apiKey);
068        }
069
070        public static Chart<Track> getWeeklyTrackChart(String group, int limit, String apiKey) {
071                return getWeeklyTrackChart(group, null, null, limit, apiKey);
072        }
073
074        public static Chart<Track> getWeeklyTrackChart(String group, String from, String to, int limit, String apiKey) {
075                return Chart.getChart("group.getWeeklyTrackChart", "group", group, "track", from, to, limit, apiKey);
076        }
077
078        public static LinkedHashMap<String, String> getWeeklyChartList(String group, String apiKey) {
079                return Chart.getWeeklyChartList("group.getWeeklyChartList", "group", group, apiKey);
080        }
081
082        public static Collection<Chart> getWeeklyChartListAsCharts(String group, String apiKey) {
083                return Chart.getWeeklyChartListAsCharts("group", group, apiKey);
084        }
085
086        /**
087         * Get a list of members for this group.
088         *
089         * @param group The group name to fetch the members of
090         * @param apiKey A Last.fm API key
091         * @return the list of {@link User}s
092         */
093        public static PaginatedResult<User> getMembers(String group, String apiKey) {
094                return getMembers(group, 1, apiKey);
095        }
096
097        /**
098         * Get a list of members for this group.
099         *
100         * @param group The group name to fetch the members of
101         * @param page The results page you would like to fetch
102         * @param apiKey A Last.fm API key
103         * @return the list of {@link User}s
104         */
105        public static PaginatedResult<User> getMembers(String group, int page, String apiKey) {
106                Result result = Caller.getInstance().call("group.getMembers", apiKey, "group", group, "page", String.valueOf(page));
107                return ResponseBuilder.buildPaginatedResult(result, User.class);
108        }
109
110        /**
111         * Get the hype list for a group.
112         *
113         * @param group The last.fm group name
114         * @param apiKey A Last.fm API key
115         * @return a Collection of {@link Artist}s
116         */
117        public static Collection<Artist> getHype(String group, String apiKey) {
118                Result result = Caller.getInstance().call("group.getHype", apiKey, "group", group);
119                return ResponseBuilder.buildCollection(result, Artist.class);
120        }
121}