From 80c009466663d77d00b8aaf15763f039ec44e80f Mon Sep 17 00:00:00 2001 From: kylekz Date: Sun, 29 Dec 2024 23:28:32 +1300 Subject: [PATCH] misc --- TODO.md | 50 ---------------------------------------- src/api/auth.ts | 2 -- src/api/grid.ts | 8 +------ src/api/news.ts | 4 ---- src/api/objekt.ts | 14 +++-------- src/api/rewards.ts | 3 --- src/api/season.ts | 3 +-- tests/api/objekt.spec.ts | 7 +++--- tests/mocks.json | 24 ------------------- tests/mocks.ts | 2 +- 10 files changed, 9 insertions(+), 108 deletions(-) diff --git a/TODO.md b/TODO.md index b1e679f..904b2bd 100644 --- a/TODO.md +++ b/TODO.md @@ -9,17 +9,6 @@ - [ ] get personal objekt/grid ranking - [ ] get top 10 ranking -## Artist - -- [x] get artist list -- [x] get artist & members -- [x] get artist (backend for frontend) - -## Auth - -- [x] sign in -- [x] refresh token - ## Gravity - [ ] total como spent per artist @@ -28,31 +17,9 @@ - [ ] get user status of a gravity - [ ] get polls for a gravity -## Grid - -- [x] artist status/counts -- [x] list of editions -- [x] list of grid for an edition -- [x] grid status -- [x] complete a grid -- [x] claim a grid reward - -## News - -- [x] home page -- [x] feed -- [x] exclusive feed -- [x] feed (backend for frontend) - ## Objekt -- [x] filters -- [x] get by serial -- [ ] claim by serial - [ ] objekt collection by address -- [x] get token -- [x] apply lenticular -- [x] remove lenticular - [ ] gas station ## Rekord @@ -66,24 +33,7 @@ - [ ] unlike post - [ ] get post by id -## Rewards - -- [x] list pending rewards -- [x] check if claimable -- [x] claim rewards - -## Season - -- [x] list seasons - ## Shop - [ ] get products - [ ] get banner - -## User - -- [x] get current user -- [x] search users -- [x] get user by nickname -- [x] update device profile diff --git a/src/api/auth.ts b/src/api/auth.ts index 3f8215d..e0dcf19 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -5,7 +5,6 @@ import { signInSchema } from "../zod/auth"; export class AuthAPI extends BaseAPI { /** * Sign in with Ramper credentials. - * * Authentication is not required. */ async signIn(payload: Auth.LoginPayload) { @@ -17,7 +16,6 @@ export class AuthAPI extends BaseAPI { /** * Refresh an access token. - * * Authentication is not required. */ async refreshToken(refreshToken: string) { diff --git a/src/api/grid.ts b/src/api/grid.ts index ea31be1..a6c576f 100644 --- a/src/api/grid.ts +++ b/src/api/grid.ts @@ -1,11 +1,10 @@ import { BaseAPI } from "./base-api"; import { AccessTokenMissing, BadRequestError, CosmoError } from "../errors"; -import { ValidArtist } from "./legacy-artist"; +import { ValidArtist } from "../types/artist-common"; export class GridAPI extends BaseAPI { /** * Get the grid status/counts for the given artist. - * * Authentication is required. */ async artistStatus(artist: ValidArtist) { @@ -18,7 +17,6 @@ export class GridAPI extends BaseAPI { /** * Get the list of editions for the given artist. - * * Authentication is required. */ async editions(artist: ValidArtist) { @@ -33,7 +31,6 @@ export class GridAPI extends BaseAPI { /** * Get the required objekts and rewards for the given edition. - * * Authentication is required. */ async editionGrids(edition: string) { @@ -48,7 +45,6 @@ export class GridAPI extends BaseAPI { /** * Get the current state of the given grid. - * * Authentication is required. */ async gridStatus(gridId: string) { @@ -63,7 +59,6 @@ export class GridAPI extends BaseAPI { /** * Complete a grid. - * * Authentication is required. */ async complete(gridId: string, slots: Grid.SlotCompletion[]) { @@ -97,7 +92,6 @@ export class GridAPI extends BaseAPI { /** * Claim a grid reward. * Must be called after {@link complete}. - * * Authentication is required. */ async claim(gridId: string) { diff --git a/src/api/news.ts b/src/api/news.ts index 85d2da9..a51019d 100644 --- a/src/api/news.ts +++ b/src/api/news.ts @@ -8,7 +8,6 @@ import { LegacyArtist } from "./legacy-artist"; export class NewsAPI extends BaseAPI { /** * Get home page news sections for the given artist. - * * Authentication is required. */ async home(artist: ValidArtist) { @@ -23,7 +22,6 @@ export class NewsAPI extends BaseAPI { /** * Get the news feed for the given artist. - * * Authentication is not required. */ async feed({ artist, startAfter = 0, limit = 10 }: News.Payload) { @@ -40,7 +38,6 @@ export class NewsAPI extends BaseAPI { /** * Get the exclusive news feed for the given artist. - * * Authentication is not required. */ async exclusive({ artist, startAfter = 0, limit = 10 }: News.Payload) { @@ -57,7 +54,6 @@ export class NewsAPI extends BaseAPI { /** * Get the news feed for the given artist via the backend for frontend endpoint. - * * Authentication is required. */ async feedBff({ artistName, page = 1, size = 10 }: NewsBFF.Payload) { diff --git a/src/api/objekt.ts b/src/api/objekt.ts index 4bebcf7..547ac2d 100644 --- a/src/api/objekt.ts +++ b/src/api/objekt.ts @@ -2,12 +2,11 @@ import { z } from "zod"; import { BaseAPI } from "./base-api"; import { objektFilterSchema } from "../zod/objekt"; import { AccessTokenMissing } from "../errors"; -import { ValidArtist } from "./legacy-artist"; +import { ValidArtist } from "../types/artist-common"; export class ObjektAPI extends BaseAPI { /** * Get the available objekt filters. - * * Authentication is required. */ async filters(artist?: ValidArtist) { @@ -25,7 +24,6 @@ export class ObjektAPI extends BaseAPI { /** * Get an objekt by its QR/odmq code. - * * Authentication is required. */ async getBySerial(serial: string) { @@ -41,7 +39,6 @@ export class ObjektAPI extends BaseAPI { /** * Claim an objekt by its QR/odmq code. - * * Authentication is required. */ async claimBySerial(serial: string) { @@ -49,15 +46,13 @@ export class ObjektAPI extends BaseAPI { throw new AccessTokenMissing(); } - throw new Error("not implemented"); - return await this.request(`/objekt/v1/by-serial/${serial}/claim`, { + return await this.request(`/objekt/v1/by-serial/${serial}/claim`, { method: "POST", - }); + }).then(() => true); } /** * Get the objekts owned by the given address. - * * Authentication is not required. */ async ownedBy(address: Objekt.OwnedBy, filters?: Objekt.CollectionParams) { @@ -78,7 +73,6 @@ export class ObjektAPI extends BaseAPI { /** * Get a single token by its ID. - * * Authentication is not required. */ async token(tokenId: Objekt.TokenId) { @@ -87,7 +81,6 @@ export class ObjektAPI extends BaseAPI { /** * Put two tokens into a lenticular pair. - * * Authentication is required. */ async applyLenticular(tokenA: Objekt.TokenId, tokenB: Objekt.TokenId) { @@ -106,7 +99,6 @@ export class ObjektAPI extends BaseAPI { /** * Remove a token from a lenticular pair. - * * Authentication is required. */ async removeLenticular(tokenId: Objekt.TokenId) { diff --git a/src/api/rewards.ts b/src/api/rewards.ts index 78933f7..ecf5c9f 100644 --- a/src/api/rewards.ts +++ b/src/api/rewards.ts @@ -4,7 +4,6 @@ import { AccessTokenMissing, BadRequestError } from "../errors"; export class RewardsAPI extends BaseAPI { /** * Display the list of pending rewards. - * * Authentication is required. */ async list() { @@ -23,7 +22,6 @@ export class RewardsAPI extends BaseAPI { /** * Check if there are any pending rewards. - * * Authentication is required. */ async check() { @@ -42,7 +40,6 @@ export class RewardsAPI extends BaseAPI { /** * Claim all pending rewards. - * * Authentication is required. */ async claim() { diff --git a/src/api/season.ts b/src/api/season.ts index b9dc3d8..f7af301 100644 --- a/src/api/season.ts +++ b/src/api/season.ts @@ -1,10 +1,9 @@ -import { ValidArtist } from "./legacy-artist"; +import { ValidArtist } from "../types/artist-common"; import { BaseAPI } from "./base-api"; export class SeasonAPI extends BaseAPI { /** * Get the seasons for the given artist. - * * Authentication is not required. */ async list(artist: ValidArtist) { diff --git a/tests/api/objekt.spec.ts b/tests/api/objekt.spec.ts index 012d3d0..cbbbcc3 100644 --- a/tests/api/objekt.spec.ts +++ b/tests/api/objekt.spec.ts @@ -27,9 +27,8 @@ describe("ObjektAPI", () => { }); it("should claim an objekt by its qr code", async () => { - await expect(() => { - return cosmo.objekts.claimBySerial("1234"); - }).rejects.toThrowError("not implemented"); + const response = await cosmo.objekts.claimBySerial("1234"); + expect(response).toEqual(true); }); it("should apply lenticular to two objekts", async () => { @@ -95,7 +94,7 @@ describe("ObjektAPI", () => { it("claiming an objekt by its qr code should handle unauthorized requests", async () => { await expect(cosmo.objekts.claimBySerial("1234")).rejects.toThrowError( - new Error("not implemented") + new UnauthorizedError("missing Authorization header") ); }); diff --git a/tests/mocks.json b/tests/mocks.json index 49e6bb9..d98f145 100644 --- a/tests/mocks.json +++ b/tests/mocks.json @@ -1081,30 +1081,6 @@ "isClaimed": true }, - "claimBySerial": { - "objekt": { - "collectionId": "Atom01 JiWoo 100Z", - "season": "Atom01", - "member": "JiWoo", - "collectionNo": "100Z", - "class": "Welcome", - "artists": ["tripleS"], - "thumbnailImage": "https://imagedelivery.net/qQuMkbHJ-0s6rwu8vup_5w/bd31d000-fa7b-4518-dd27-58cde1faf200/thumbnail", - "frontImage": "https://imagedelivery.net/qQuMkbHJ-0s6rwu8vup_5w/bd31d000-fa7b-4518-dd27-58cde1faf200/3x", - "backImage": "https://imagedelivery.net/qQuMkbHJ-0s6rwu8vup_5w/78f14332-1f28-4745-d49a-06684a8d4f00/3x", - "accentColor": "#F1F2F2", - "backgroundColor": "#F1F2F2", - "textColor": "#000000", - "comoAmount": 1, - "transferableByDefault": true, - "tokenId": "1", - "tokenAddress": "0xA4B37bE40F7b231Ee9574c4b16b7DDb7EAcDC99B", - "objektNo": 1, - "transferable": false - }, - "isClaimed": true - }, - "token": { "name": "Atom01 JinSoul 310Z #5", "description": "ARTMS\n——————————————————\nObjekt is a NFT photo card of ARTMS.\nUsers can acquire (as a reward or buy), collect, and trade their Objekt in COSMO, our exclusive app.\nYou can also mint your physical Objekt by scanning its QR code by COSMO.", diff --git a/tests/mocks.ts b/tests/mocks.ts index 472617a..a9a0c6c 100644 --- a/tests/mocks.ts +++ b/tests/mocks.ts @@ -62,7 +62,7 @@ export const handlers = [ HttpResponse.json(json.getBySerial) ), http.post(cosmo("/objekt/v1/by-serial/*/claim"), () => - HttpResponse.json(json.claimBySerial) + HttpResponse.json(undefined, { status: 201 }) ), http.post(cosmo("/lenticular/v1"), () => HttpResponse.json(undefined, { status: 201 })