@retroachievements/api 0.0.0-development → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.esm.js CHANGED
@@ -1925,6 +1925,152 @@ var getGameInfoAndUserProgress = /*#__PURE__*/function () {
1925
1925
  };
1926
1926
  }();
1927
1927
 
1928
+ /**
1929
+ * A call to this function will retrieve a list of
1930
+ * achievement set claims made over the lifetime of a given
1931
+ * user, targeted by their username.
1932
+ *
1933
+ * @param authorization An object containing your userName and webApiKey.
1934
+ * This can be constructed with `buildAuthorization()`.
1935
+ *
1936
+ * @param payload.userName The user for which to retrieve the historical
1937
+ * achievement set claims list for.
1938
+ *
1939
+ * @example
1940
+ * ```
1941
+ * const userClaims = await getUserClaims(
1942
+ * authorization,
1943
+ * { userName: "xelnia" }
1944
+ * );
1945
+ * ```
1946
+ *
1947
+ * @returns An array containing all the achievement set claims
1948
+ * made over the lifetime of the given user.
1949
+ */
1950
+
1951
+ var getUserClaims = /*#__PURE__*/function () {
1952
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1953
+ var userName, url, rawResponse;
1954
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1955
+ while (1) {
1956
+ switch (_context.prev = _context.next) {
1957
+ case 0:
1958
+ userName = payload.userName;
1959
+ url = buildRequestUrl(apiBaseUrl, "/API_GetUserClaims.php", authorization, {
1960
+ u: userName
1961
+ });
1962
+ _context.next = 4;
1963
+ return call({
1964
+ url: url
1965
+ });
1966
+
1967
+ case 4:
1968
+ rawResponse = _context.sent;
1969
+ return _context.abrupt("return", serializeProperties(rawResponse, {
1970
+ shouldCastToNumbers: ["ID", "GameID", "ClaimType", "SetType", "Status", "Extension", "Special", "MinutesLeft"]
1971
+ }));
1972
+
1973
+ case 6:
1974
+ case "end":
1975
+ return _context.stop();
1976
+ }
1977
+ }
1978
+ }, _callee);
1979
+ }));
1980
+
1981
+ return function getUserClaims(_x, _x2) {
1982
+ return _ref.apply(this, arguments);
1983
+ };
1984
+ }();
1985
+
1986
+ /**
1987
+ * A call to this function will retrieve completion metadata
1988
+ * about the games a given user has played. It returns two
1989
+ * entries per each game: one for the softcore completion and
1990
+ * one for the hardcore completion. These are designated by
1991
+ * the `hardcoreMode` property on the completion object.
1992
+ *
1993
+ * @param authorization An object containing your userName and webApiKey.
1994
+ * This can be constructed with `buildAuthorization()`.
1995
+ *
1996
+ * @param payload.userName The user for which to retrieve the
1997
+ * completion metadata for.
1998
+ *
1999
+ * @example
2000
+ * ```
2001
+ * const userCompletedGames = await getUserCompletedGames(
2002
+ * authorization,
2003
+ * { userName: "xelnia" }
2004
+ * );
2005
+ * ```
2006
+ *
2007
+ * @returns An array containing completion metadata objects
2008
+ * for a given user. Each game contains two completion records,
2009
+ * one for softcore and another for hardcore.
2010
+ * ```json
2011
+ * [
2012
+ * {
2013
+ * gameId: 14976,
2014
+ * title: 'Mortal Kombat',
2015
+ * imageIcon: '/Images/036812.png',
2016
+ * consoleId: 27,
2017
+ * consoleName: 'Arcade',
2018
+ * maxPossible: 35,
2019
+ * numAwarded: 13,
2020
+ * pctWon: 0.3714,
2021
+ * hardcoreMode: false
2022
+ * },
2023
+ * {
2024
+ * gameId: 14976,
2025
+ * title: 'Mortal Kombat',
2026
+ * imageIcon: '/Images/036812.png',
2027
+ * consoleId: 27,
2028
+ * consoleName: 'Arcade',
2029
+ * maxPossible: 35,
2030
+ * numAwarded: 13,
2031
+ * pctWon: 0.3714,
2032
+ * hardcoreMode: true
2033
+ * },
2034
+ * ]
2035
+ * ```
2036
+ */
2037
+
2038
+ var getUserCompletedGames = /*#__PURE__*/function () {
2039
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
2040
+ var userName, url, rawResponse;
2041
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2042
+ while (1) {
2043
+ switch (_context.prev = _context.next) {
2044
+ case 0:
2045
+ userName = payload.userName;
2046
+ url = buildRequestUrl(apiBaseUrl, "/API_GetUserCompletedGames.php", authorization, {
2047
+ u: userName
2048
+ });
2049
+ _context.next = 4;
2050
+ return call({
2051
+ url: url
2052
+ });
2053
+
2054
+ case 4:
2055
+ rawResponse = _context.sent;
2056
+ return _context.abrupt("return", serializeProperties(rawResponse, {
2057
+ shouldCastToNumbers: ["GameID", "ConsoleID", "MaxPossible", "NumAwarded", "PctWon"],
2058
+ shouldMapToBooleans: ["HardcoreMode"]
2059
+ }));
2060
+
2061
+ case 6:
2062
+ case "end":
2063
+ return _context.stop();
2064
+ }
2065
+ }
2066
+ }, _callee);
2067
+ }));
2068
+
2069
+ return function getUserCompletedGames(_x, _x2) {
2070
+ return _ref.apply(this, arguments);
2071
+ };
2072
+ }();
2073
+
1928
2074
  /**
1929
2075
  * A call to this function will retrieve metadata about
1930
2076
  * how a particular user has performed/ranked on a particular
@@ -1952,7 +2098,7 @@ var getGameInfoAndUserProgress = /*#__PURE__*/function () {
1952
2098
  * @returns An array containing metadata about the user's
1953
2099
  * rank and score for the target game ID. If metadata
1954
2100
  * cannot be found, the array is empty.
1955
- * ```
2101
+ * ```json
1956
2102
  * [
1957
2103
  * {
1958
2104
  * user: "xelnia",
@@ -2329,5 +2475,5 @@ var buildAuthorization = function buildAuthorization(options) {
2329
2475
  }; // This function simply returns what it's given, however the return
2330
2476
  // value has the added benefit of type safety.
2331
2477
 
2332
- export { AchievementDistributionFlags, ClaimSetType, ClaimStatus, ClaimType, buildAuthorization, getAchievementCount, getAchievementDistribution, getAchievementOfTheWeek, getAchievementUnlocks, getAchievementsEarnedBetween, getAchievementsEarnedOnDay, getActiveClaims, getConsoleIds, getGame, getGameExtended, getGameInfoAndUserProgress, getGameList, getGameRankAndScore, getGameRating, getTicketData, getTopTenUsers, getUserGameRankAndScore, getUserPoints, getUserProgress, getUserRecentlyPlayedGames, getUserSummary, call as unsafe_call };
2478
+ export { AchievementDistributionFlags, ClaimSetType, ClaimStatus, ClaimType, buildAuthorization, getAchievementCount, getAchievementDistribution, getAchievementOfTheWeek, getAchievementUnlocks, getAchievementsEarnedBetween, getAchievementsEarnedOnDay, getActiveClaims, getConsoleIds, getGame, getGameExtended, getGameInfoAndUserProgress, getGameList, getGameRankAndScore, getGameRating, getTicketData, getTopTenUsers, getUserClaims, getUserCompletedGames, getUserGameRankAndScore, getUserPoints, getUserProgress, getUserRecentlyPlayedGames, getUserSummary, call as unsafe_call };
2333
2479
  //# sourceMappingURL=api.esm.js.map