Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekz committed Dec 29, 2024
1 parent 4fcade8 commit 80c0094
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 108 deletions.
50 changes: 0 additions & 50 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -17,7 +16,6 @@ export class AuthAPI extends BaseAPI {

/**
* Refresh an access token.
*
* Authentication is not required.
*/
async refreshToken(refreshToken: string) {
Expand Down
8 changes: 1 addition & 7 deletions src/api/grid.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -48,7 +45,6 @@ export class GridAPI extends BaseAPI {

/**
* Get the current state of the given grid.
*
* Authentication is required.
*/
async gridStatus(gridId: string) {
Expand All @@ -63,7 +59,6 @@ export class GridAPI extends BaseAPI {

/**
* Complete a grid.
*
* Authentication is required.
*/
async complete(gridId: string, slots: Grid.SlotCompletion[]) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions src/api/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
14 changes: 3 additions & 11 deletions src/api/objekt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -25,7 +24,6 @@ export class ObjektAPI extends BaseAPI {

/**
* Get an objekt by its QR/odmq code.
*
* Authentication is required.
*/
async getBySerial(serial: string) {
Expand All @@ -41,23 +39,20 @@ export class ObjektAPI extends BaseAPI {

/**
* Claim an objekt by its QR/odmq code.
*
* Authentication is required.
*/
async claimBySerial(serial: string) {
if (!this.config.accessToken) {
throw new AccessTokenMissing();
}

throw new Error("not implemented");
return await this.request<boolean>(`/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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -106,7 +99,6 @@ export class ObjektAPI extends BaseAPI {

/**
* Remove a token from a lenticular pair.
*
* Authentication is required.
*/
async removeLenticular(tokenId: Objekt.TokenId) {
Expand Down
3 changes: 0 additions & 3 deletions src/api/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -23,7 +22,6 @@ export class RewardsAPI extends BaseAPI {

/**
* Check if there are any pending rewards.
*
* Authentication is required.
*/
async check() {
Expand All @@ -42,7 +40,6 @@ export class RewardsAPI extends BaseAPI {

/**
* Claim all pending rewards.
*
* Authentication is required.
*/
async claim() {
Expand Down
3 changes: 1 addition & 2 deletions src/api/season.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions tests/api/objekt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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")
);
});

Expand Down
24 changes: 0 additions & 24 deletions tests/mocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion tests/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit 80c0094

Please sign in to comment.