-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create resend.com plugin template #852
base: 0.8.2-dev
Are you sure you want to change the base?
Conversation
Please also let me know if there are no issues and I will continue to complete the remaining features of this plugin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some quick remarks. :) By and Large the code look great.
name="Sender Email Address", | ||
required=True, | ||
description="To include a friendly name, use the format \"Your Name <[email protected]>\".", | ||
component=FormComponent(type="dotPath", props={"label": "Resend"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You use dotPath for sender which is good but the params.sender are not dun through dotAccessor to get the value.
url = f"https://api.resend.com/emails" | ||
params = { | ||
"from": self.config.sender, | ||
"to": self.config.to, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You use dotPath for sender, to, etc which is good but the params.sender are not dun through dotAccessor to get the value.
to get the right value when the user use dotPath like [email protected] do the following:
dot = self._get_dot_accessor(payload) # This gets the class that can evaluate any dot notation.
self.config.sender = dot[self.config.sender]
this will convert the dot notation if found to the actual value. If not found it will leave the value as it is. THis should be done for all dotPaths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be also good to check if after converting the sender, to, etc. if the values are real emails.
params["html"] = self.config.message.get("content", "") | ||
else: | ||
params["text"] = self.config.message.get("content", "") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no content we'd rather not send anything and return a message on error port.
"id": "", | ||
"name": "" | ||
}, | ||
"params": {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good practive to set the default values for params:
init={
"resource": {
"id": "",
"name": ""
},
"params": {
"from": "",
"to": "[email protected]",
...
}
}
@@ -74,6 +74,14 @@ def get_resource_types() -> List[ResourceSettings]: | |||
"password": "<password>" | |||
} | |||
), | |||
ResourceSettings( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YOu could reuse the existing api_key resource then there is no need for new ResourceSetting.
this is the one:
ResourceSettings(
id="api-key",
name="Api Key",
icon="hash",
tags=["api", "key", "token", "api_key"],
config={
"api_key": ""
}
),
It should be first on the list.
from pydantic import BaseModel | ||
|
||
|
||
class ResendResource(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to reuse existing model for ApiKey. It is at: tracardi.resources.api_key
resource = await resource_db.load(config.resource.id) | ||
|
||
self.config = config.params | ||
self.credentials: "ResendResource" = resource.credentials.get_credentials(self, output=ResendResource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reuse: tracardi.resource.api_key instead of ResendResource.
name="Resend Resource", | ||
required=True, | ||
description="Select Resend Resource.", | ||
component=FormComponent(type="resource", props={"label": "Resend Resource", "tag": "resend"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When yo reuse existing ApiKeythen set tag to: api_key
@atompie There is a resend.com plugin demo.
You can test with the plugin named
Resend: Send Email
, and this plugin is implemented for send email API.Could you please review this code to see if there are any issues with the coding logic.