diff --git a/packages/moments/README.md b/packages/moments/README.md index 89481ff8..b03612fb 100644 --- a/packages/moments/README.md +++ b/packages/moments/README.md @@ -27,27 +27,52 @@ yarn add @poap-xyz/moments @poap-xyz/utils @poap-xyz/providers axios form-data ## Usage ```javascript -import { MomentsClient, createMomentInput, Moment } from '@poap-xyz/moments'; -import { PoapCompass, PoapMomentsApi } from '@poap-xyz/providers'; +import { MomentsClient, CreateMomentInput, Moment } from '@poap-xyz/moments'; +import { PoapCompass, PoapMomentsApi, AuthenticationProviderHttp } from '@poap-xyz/providers'; import fs from 'fs'; +// Set up the PoapMomentsApi with proper authentication +const momentsApi = new PoapMomentsApi({ + authenticationProvider: new AuthenticationProviderHttp( + 'CLIENT_ID', + 'CLIENT_SECRET', + ), +}); + const client = new MomentsClient( - new PoapMomentsApi('your_api_key'), - new PoapCompass('your_api_key'), + momentsApi, + new PoapCompass('your_api_key_for_compass'), ); -const input: createMomentInput = { - dropId: 110148, - /** - * The Token ID related to the moment (Optional) - */ - tokenId: 6568008, - file: await fs.promises.readFile('src/assets/poap.png'), - author: '0x82AB2941Cf555CED5ad7Ed232a5B5f6083815FBC', - mimeType: 'image/png', +const input: CreateMomentInput = { + dropId: 110148, + tokenId: 6568008, // Optional: The Token ID related to the moment + medias: [{ + fileBinary: await fs.promises.readFile('src/assets/poap.png'), + fileType: 'image/png', + }], + author: '0x82AB2941Cf555CED5ad7Ed232a5B5f6083815FBC', + description: 'Your moment description here', // Optional description for the moment + onStepUpdate: (step) => { + console.log(step); // Monitor the step-by-step process of creating a moment + }, + onFileUploadProgress: (progress) => { + console.log(progress); // Monitor file upload progress + }, + timeOut: 5000, // Optional: Set a timeout for the media processing }; const moment: Moment = await client.createMoment(input); ``` +Explanations for each step: + +| Step Name | Explanation | +|-------------------------|----------------------------------------------------------| +| `UPLOADING_MEDIA` | The process of uploading media assets. | +| `PROCESSING_MEDIA` | The media assets are being processed after upload. | +| `PROCESSING_MEDIA_ERROR`| An error occurred during the media processing phase. | +| `UPLOADING_MOMENT` | The process of uploading the moment's data. | +| `FINISHED` | The entire operation of creating the moment is complete. | + ## Documentation