mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
Add temp-email
driver implementation to the SDK
This commit is contained in:
parent
49f61c4782
commit
233a2719c6
@ -1,6 +1,7 @@
|
|||||||
import OS from './modules/OS.js';
|
import OS from './modules/OS.js';
|
||||||
import FileSystem from './modules/FileSystem/index.js';
|
import FileSystem from './modules/FileSystem/index.js';
|
||||||
import Hosting from './modules/Hosting.js';
|
import Hosting from './modules/Hosting.js';
|
||||||
|
import Email from './modules/Email.js';
|
||||||
import Apps from './modules/Apps.js';
|
import Apps from './modules/Apps.js';
|
||||||
import UI from './modules/UI.js';
|
import UI from './modules/UI.js';
|
||||||
import KV from './modules/KV.js';
|
import KV from './modules/KV.js';
|
||||||
@ -196,6 +197,8 @@ window.puter = (function() {
|
|||||||
this.ui = new UI(this.appInstanceID, this.parentInstanceID, this.appID, this.env, this.util);
|
this.ui = new UI(this.appInstanceID, this.parentInstanceID, this.appID, this.env, this.util);
|
||||||
// Hosting
|
// Hosting
|
||||||
this.hosting = new Hosting(this.authToken, this.APIOrigin, this.appID, this.env);
|
this.hosting = new Hosting(this.authToken, this.APIOrigin, this.appID, this.env);
|
||||||
|
// Email
|
||||||
|
this.email = new Email(this.authToken, this.APIOrigin, this.appID);
|
||||||
// Apps
|
// Apps
|
||||||
this.apps = new Apps(this.authToken, this.APIOrigin, this.appID, this.env);
|
this.apps = new Apps(this.authToken, this.APIOrigin, this.appID, this.env);
|
||||||
// AI
|
// AI
|
||||||
@ -208,7 +211,7 @@ window.puter = (function() {
|
|||||||
|
|
||||||
updateSubmodules() {
|
updateSubmodules() {
|
||||||
// Update submodules with new auth token and API origin
|
// Update submodules with new auth token and API origin
|
||||||
[this.os, this.fs, this.hosting, this.apps, this.ai, this.kv].forEach(module => {
|
[this.os, this.fs, this.hosting, this.email, this.apps, this.ai, this.kv].forEach(module => {
|
||||||
if(!module) return;
|
if(!module) return;
|
||||||
module.setAuthToken(this.authToken);
|
module.setAuthToken(this.authToken);
|
||||||
module.setAPIOrigin(this.APIOrigin);
|
module.setAPIOrigin(this.APIOrigin);
|
||||||
|
62
packages/puter-js/src/modules/Email.js
Normal file
62
packages/puter-js/src/modules/Email.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import * as utils from '../lib/utils.js'
|
||||||
|
|
||||||
|
class Email{
|
||||||
|
/**
|
||||||
|
* Creates a new instance with the given authentication token, API origin, and app ID,
|
||||||
|
*
|
||||||
|
* @class
|
||||||
|
* @param {string} authToken - Token used to authenticate the user.
|
||||||
|
* @param {string} APIOrigin - Origin of the API server. Used to build the API endpoint URLs.
|
||||||
|
* @param {string} appID - ID of the app to use.
|
||||||
|
*/
|
||||||
|
constructor (authToken, APIOrigin, appID) {
|
||||||
|
this.authToken = authToken;
|
||||||
|
this.APIOrigin = APIOrigin;
|
||||||
|
this.appID = appID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new authentication token.
|
||||||
|
*
|
||||||
|
* @param {string} authToken - The new authentication token.
|
||||||
|
* @memberof [Email]
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
setAuthToken (authToken) {
|
||||||
|
this.authToken = authToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the API origin.
|
||||||
|
*
|
||||||
|
* @param {string} APIOrigin - The new API origin.
|
||||||
|
* @memberof [Email]
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
setAPIOrigin (APIOrigin) {
|
||||||
|
this.APIOrigin = APIOrigin;
|
||||||
|
}
|
||||||
|
|
||||||
|
send = async(...args) => {
|
||||||
|
let options = {};
|
||||||
|
|
||||||
|
// arguments are required
|
||||||
|
if(!args || args.length === 0){
|
||||||
|
throw ({message: 'Arguments are required', code: 'arguments_required'});
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof args[0] === 'object'){
|
||||||
|
options = args[0];
|
||||||
|
}else{
|
||||||
|
options = {
|
||||||
|
to: args[0],
|
||||||
|
subject: args[1],
|
||||||
|
html: args[2]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.make_driver_method(['to', 'subject', 'html'], 'temp-email', 'send').call(this, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Email
|
Loading…
Reference in New Issue
Block a user