- Travel3-Node-API
npm install --save @travel3/travel3-api
Travel3.Context.initialize({
apiKey: 'YOUR_API_KEY',
apiBaseUrl: 'https://travel-3-api.herokuapp.com',
errorCallback: (error) => {
// eslint-disable-next-line no-console, no-undef
console.log('Error: ', error.data);
}
});
Send the pre-register request to the server. This request will return a user id. You need to save this id for the next step.
import Travel3 from '@travel3/travel3-api';
await Travel3.Auth.preRegister({
email: '[email protected]',
client_id: process.env.CLIENT_ID,
identifier_type: 'email'
});
- Example Response
{
"status": "ok",
"data": {
"user": {
"id": "d5a84e54-9921-434b-9b1e-1c3b4a4754e7",
"email": "[email protected]",
"first_name": "",
"last_name": "",
"phone_number": null,
"country_code": null,
"created_at": "2022-10-04T14:20:07.819Z",
"updated_at": "2022-10-04T14:20:07.819Z"
}
}
}
Send the register request to the server. This request will return a access token. You need to save this access token for the next step.
import Travel3 from '@travel3/travel3-api';
await Travel3.Auth.register({
user_id: 'd5a84e54-9921-434b-9b1e-1c3b4a4754e7',
password: '12345678',
password_confirmation: '12345678',
nickname: 'roylee',
client_id: process.env.CLIENT_ID
});
- Example Response
{
"status": "ok",
"data": {
"user": {
"id": "d5a84e54-9921-434b-9b1e-1c3b4a4754e7",
"email": "[email protected]",
"nickname": "12345s6asd",
"first_name": "",
"last_name": ""
},
"access_token": {
"access_token": "HNtA_G3VXfTlquk-ic9xio4904zQlqB2SuzLsxbgsd4",
"token_type": "bearer",
"expires_in": 172800,
"refresh_token": "V1zu59f2aDzYNOcJOZg3noHHM-YuHRbsUd4HIE0M1Ug",
"created_at": "2022-10-04T14:20:52.532Z"
}
}
}
-
- Third you need to send the wallet uuid generate request to the server. This request will return a client_secret, nonce and token. You need to save this uuid for the next step.
import Travel3 from '@travel3/travel3-api';
await Travel3.Wallet.generateUUID();
import Travel3 from '@travel3/travel3-api';
import dotenv from 'dotenv';
dotenv.config();
await Travel3.Auth.login({
email: '[email protected]',
password: '12345678',
grant_type: 'password',
client_id: process.env.CLIENT_ID,
client_secret: process.env.CLIENT_SECRET,
identifier_type: 'email'
});
import Travel3 from '@travel3/travel3-api';
const events = await Travel3.Event.listGoing({
page: 0
});
import Travel3 from '@travel3/travel3-api';
await Travel3.Event.participate({
event_id: '1'
});
import Travel3 from '@travel3/travel3-api'
const events = await Travel3.Event.listFeatured()
import Travel3 from '@travel3/travel3-api';
const eventTypes = await Travel3.EventCategory.list();
import Travel3 from '@travel3/travel3-api';
const eventTypes = await Travel3.EventType.list();
import Travel3 from '@travel3/travel3-api';
const nfts = await Travel3.Account.getMe();
import Travel3 from '@travel3/travel3-api';
const nfts = await Travel3.Account.updateMe({
first_name: 'Roy',
last_name: 'Lee',
nickname: 'roylee',
});
import Travel3 from '@travel3/travel3-api';
const nfts = await Travel3.Account.updatePassword({
old_password: '',
password: '',
password_confirmation: '',
});
import Travel3 from '@travel3/travel3-api';
const nfts = await Travel3.Nft.list();
import Travel3 from '@travel3/travel3-api';
const nftAssetItem = await Travel3.NftAssetItem.show({
nft_asset_item_id: '1'
});
import Travel3 from '@travel3/travel3-api';
const events = await Travel3.Admin.Event.list();
import Travel3 from '@travel3/travel3-api';
const event = await Travel3.Admin.Event.show({
event_id: 'cdf58f57-618c-41e3-9cd2-21d4c3691002'
});
You have to retrieve event type id by using Travel3.EventType.list()
before you create an event.
import Travel3 from '@travel3/travel3-api';
const event = await Travel3.Admin.Event.create({
event_type_id: '7bbec334-db09-4d04-acea-09df4a7b0963',
nft_collection_id: '2c196aa2-1939-4200-95ef-ffdae46d981d',
name: '(Sample) MGM Cotai Starbucks Coffee Workshop',
timezone: 'Asia/Hong_Kong',
slug: 'mgm-cotai-starbucks-coffee-workshop',
started_at: '2022-08-01 04:44:17',
scheduled_to_end_at: '2022-09-30 04:44:17',
description: 'Hello world',
language: 'Chinese',
venue_attributes: {
name: 'MGM Cotai',
address: '4HW9+78V, Av. da Nave Desportiva, Macao',
latitude: 22.145734,
longitude: 113.568012,
city: 'Macau SAR',
state: 'Macau SAR',
country: 'Macau SAR'
},
images_attributes: [
{
src: 'https://cdn.pixabay.com/photo/2016/03/26/23/23/starbucks-1281880__480.jpg'
}
]
});
- Get the image metadata from travel3 api
const metadata = await Travel3.Image.getMedia({
filename: '123.png',
type: 'image/png',
access_token
});
- Upload the image to the url
await Travel3.directS3Upload(file, metadata.fields);
import Travel3 from '@travel3/travel3-api';
await Travel3.Image.delete({
media_id: "aaaa-bbbb-cccc-dddd"
});
import Travel3 from '@travel3/travel3-api';
const nfts = await Travel3.Nft.list();
import Travel3 from '@travel3/travel3-api';
const balance = await Travel3.Balance.show();
import Travel3 from '@travel3/travel3-api';
const mysteries = await Travel3.MyStery.list();
import Travel3 from '@travel3/travel3-api';
const attend = await Travel3.Attend.create({
loyalty_reward_id: '3a0e038b-eb07-43df-8bfb-7c9e86bb9515'
});
import Travel3 from '@travel3/travel3-api';
const productList = await Travel3.Product.list();
import Travel3 from '@travel3/travel3-api';
const product = await Travel3.Product.show({
productId: 7987297517852
});
import Travel3 from '@travel3/travel3-api';
const events = await Travel3.Organization.Event.list();
import Travel3 from '@travel3/travel3-api';
const event = await Travel3.Organization.Event.show({
event_id: 'cdf58f57-618c-41e3-9cd2-21d4c3691002'
});
You have to retrieve event type id by using Travel3.EventType.list()
before you create an event.
import Travel3 from '@travel3/travel3-api';
const event = await Travel3.Organization.Event.create({
event_type_id: '7bbec334-db09-4d04-acea-09df4a7b0963',
event_category_id: '7bbec334-db09-4d04-acea-09df4a7b0963',
nft_collection_id: '2c196aa2-1939-4200-95ef-ffdae46d981d',
name: '(Sample) MGM Cotai Starbucks Coffee Workshop',
timezone: 'Asia/Hong_Kong',
slug: 'mgm-cotai-starbucks-coffee-workshop',
started_at: '2022-08-01 04:44:17',
scheduled_to_end_at: '2022-09-30 04:44:17',
description: 'Hello world',
language: 'Chinese',
venue_attributes: {
name: 'MGM Cotai',
address: '4HW9+78V, Av. da Nave Desportiva, Macao',
latitude: 22.145734,
longitude: 113.568012,
city: 'Macau SAR',
state: 'Macau SAR',
country: 'Macau SAR'
},
images_attributes: [
{
src: 'https://cdn.pixabay.com/photo/2016/03/26/23/23/starbucks-1281880__480.jpg'
}
]
});
import Travel3 from '@travel3/travel3-api';
Travel3.Organization.Event.update({
event_id: 'cdf58f57-618c-41e3-9cd2-21d4c3691002',
event_type_id: '7bbec334-db09-4d04-acea-09df4a7b0963',
nft_collection_id: '2c196aa2-1939-4200-95ef-ffdae46d981d',
name: '(Sample) MGM Cotai Starbucks Coffee Workshop',
timezone: 'Asia/Hong_Kong',
slug: 'mgm-cotai-starbucks-coffee-workshop',
started_at: '2022-08-01 04:44:17',
scheduled_to_end_at: '2022-09-30 04:44:17',
description: 'Hello world',
language: 'Chinese',
venue_attributes: {
name: 'MGM Cotai',
address: '4HW9+78V, Av. da Nave Desportiva, Macao',
latitude: 22.145734,
longitude: 113.568012,
city: 'Macau SAR',
state: 'Macau SAR',
country: 'Macau SAR'
},
images_attributes: [
{
src: 'https://cdn.pixabay.com/photo/2016/03/26/23/23/starbucks-1281880__480.jpg'
}
]
});
import Travel3 from '@travel3/travel3-api';
const participants = await Travel3.Organization.Event.listParticipants({
event_id: 'cdf58f57-618c-41e3-9cd2-21d4c3691002'
});