Skip to content

Commit

Permalink
feat: Expose SerializableDrop interface (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
reobin authored Oct 23, 2024
1 parent b7864a2 commit 0890fa7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/drops/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/drops",
"version": "0.5.6",
"version": "0.5.7",
"description": "Drops module for the poap.js library",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
Expand Down
32 changes: 31 additions & 1 deletion packages/drops/src/domain/Drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,36 @@ export class Drop {
});
}

public static fromSerializableObject(
serializableDrop: SerializableDrop,
): Drop {
return new Drop({
id: serializableDrop.id,
fancyId: serializableDrop.fancyId,
name: serializableDrop.name,
description: serializableDrop.description,
city: serializableDrop.city,
country: serializableDrop.country,
channel: serializableDrop.channel,
platform: serializableDrop.platform,
locationType: serializableDrop.locationType,
dropUrl: serializableDrop.dropUrl,
imageUrl: serializableDrop.imageUrl,
originalImageUrl: serializableDrop.originalImageUrl,
animationUrl: serializableDrop.animationUrl,
year: serializableDrop.year,
timezone: serializableDrop.timezone,
private: serializableDrop.private,
startDate: new Date(serializableDrop.startDate),
createdDate: new Date(serializableDrop.createdDate),
expiryDate: new Date(serializableDrop.expiryDate),
endDate: new Date(serializableDrop.endDate),
poapCount: serializableDrop.poapCount,
transferCount: serializableDrop.transferCount,
emailReservationCount: serializableDrop.emailReservationCount,
});
}

// eslint-disable-next-line max-statements
constructor(properties: DropProperties) {
this.id = properties.id;
Expand Down Expand Up @@ -168,7 +198,7 @@ export class Drop {
}
}

interface SerializableDrop {
export interface SerializableDrop {
id: number;
fancyId: string;
name: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/drops/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { DropsClient } from './DropsClient';
export { Drop } from './domain/Drop';
export { Drop, SerializableDrop } from './domain/Drop';
export { DropsSortFields } from './types/DropsSortFields';

0 comments on commit 0890fa7

Please sign in to comment.