@reech-rewards/reech
Version:
This Node package allows you to easily integrate rewards into your application using our Rewards as a Service API.
37 lines (31 loc) • 923 B
JavaScript
// index.js
class RewardsService {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://api.reechrewards.com'; // Replace with your actual API URL
}
async createReward(userId, rewardDetails) {
// Simulating a call to your RaaS API
const response = await fetch(`${this.baseUrl}/rewards/create`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.apiKey}`,
},
body: JSON.stringify({
userId,
rewardDetails,
}),
});
return response.json();
}
async getReward(rewardId) {
const response = await fetch(`${this.baseUrl}/rewards/${rewardId}`, {
headers: {
'Authorization': `Bearer ${this.apiKey}`,
},
});
return response.json();
}
}
module.exports = RewardsService;