Skip to content

Commit

Permalink
Merge branch 'main' into PLT-1397-add-actions-claim-qr-endpoint-funct…
Browse files Browse the repository at this point in the history
…ionality-30
  • Loading branch information
rlajous committed Sep 13, 2023
2 parents afe804d + f960384 commit bcf1787
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions packages/moments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bcf1787

Please sign in to comment.