fix build and some docs
This commit is contained in:
@@ -15,19 +15,19 @@ icon: node-js
|
||||
<Step title="Install SDK">
|
||||
<CodeGroup>
|
||||
```bash npm
|
||||
npm install usesend
|
||||
npm install usesend-js
|
||||
```
|
||||
|
||||
```bash yarn
|
||||
yarn add usesend
|
||||
yarn add usesend-js
|
||||
```
|
||||
|
||||
```bash pnpm
|
||||
pnpm add usesend
|
||||
pnpm add usesend-js
|
||||
```
|
||||
|
||||
```bash bun
|
||||
bun add usesend
|
||||
bun add usesend-js
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
@@ -36,7 +36,7 @@ icon: node-js
|
||||
Get the API key from the [useSend dashboard](https://app.usesend.com/dev-settings/api-keys) and initialize the SDK
|
||||
|
||||
```javascript
|
||||
import { UseSend } from "usesend";
|
||||
import { UseSend } from "usesend-js";
|
||||
|
||||
const usesend = new UseSend("us_12345");
|
||||
```
|
||||
|
@@ -13,7 +13,7 @@ const APP_URL = "https://app.usesend.com";
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<main className="min-h-screen bg-sidebar-background text-foreground">
|
||||
<main className="min-h-screen text-foreground bg-background">
|
||||
<TopNav />
|
||||
<Hero />
|
||||
<TrustedBy />
|
||||
@@ -288,16 +288,16 @@ function Features() {
|
||||
}
|
||||
|
||||
function CodeExample() {
|
||||
const code = `import { Unsend } from "@unsend/sdk";
|
||||
const code = `import { UseSend } from "usesend-js";
|
||||
|
||||
const unsend = new Unsend({ apiKey: process.env.UNSEND_API_KEY! });
|
||||
const usesend = new UseSend("us_12345");
|
||||
|
||||
await unsend.emails.send({
|
||||
from: "hi@example.com",
|
||||
to: "you@company.com",
|
||||
subject: "Welcome to useSend",
|
||||
template: "welcome", // or html/text
|
||||
data: { name: "Ada" },
|
||||
usesend.emails.send({
|
||||
to: "hello@acme.com",
|
||||
from: "hello@company.com",
|
||||
subject: "useSend email",
|
||||
html: "<p>useSend is the best open source product to send emails</p>",
|
||||
text: "useSend is the best open source product to send emails",
|
||||
});`;
|
||||
|
||||
return (
|
||||
@@ -314,12 +314,12 @@ await unsend.emails.send({
|
||||
</div>
|
||||
|
||||
<div className="mt-8 overflow-hidden">
|
||||
<div className=" py-2 text-xs text-muted-foreground">TypeScript</div>
|
||||
<div className=" py-2 text-xs text-muted-foreground">JavaScript</div>
|
||||
<div className="rounded-[18px] bg-primary/20 p-1">
|
||||
<div className="rounded-[14px] bg-primary/20 p-0.5 shadow-sm">
|
||||
<div className="bg-background rounded-xl overflow-hidden">
|
||||
<CodeBlock
|
||||
lang="typescript"
|
||||
lang="javascript"
|
||||
children={code}
|
||||
className="p-4 rounded-[10px]"
|
||||
/>
|
||||
|
@@ -1,135 +0,0 @@
|
||||
import { CodeBlock } from "@usesend/ui/src/code";
|
||||
|
||||
export const getSendTestEmailCode = ({
|
||||
from,
|
||||
to,
|
||||
subject,
|
||||
body,
|
||||
bodyHtml,
|
||||
}: {
|
||||
from: string;
|
||||
to: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
bodyHtml: string;
|
||||
}): Array<CodeBlock> => {
|
||||
return [
|
||||
{
|
||||
language: "js",
|
||||
title: "Node.js",
|
||||
code: `import { UseSend } from "usesend";
|
||||
|
||||
const usesend = new UseSend("us_12345");
|
||||
|
||||
// const usesend = new UseSend("us_12345", "https://app.usesend.com");
|
||||
|
||||
usesend.emails.send({
|
||||
to: "${to}",
|
||||
from: "${from}",
|
||||
subject: "${subject}",
|
||||
html: "${bodyHtml}",
|
||||
text: "${body}",
|
||||
});
|
||||
`,
|
||||
},
|
||||
{
|
||||
language: "python",
|
||||
title: "Python",
|
||||
code: `import requests
|
||||
|
||||
url = "https://app.usesend.com/api/v1/emails"
|
||||
|
||||
payload = {
|
||||
"to": "${to}",
|
||||
"from": "${from}",
|
||||
"subject": "${subject}",
|
||||
"text": "${body}",
|
||||
"html": "${bodyHtml}",
|
||||
}
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer us_12345"
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, json=payload, headers=headers)
|
||||
`,
|
||||
},
|
||||
{
|
||||
language: "php",
|
||||
title: "PHP",
|
||||
code: `<?php
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://app.usesend.com/api/v1/emails",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => "{\\n \\"to\\": \\"${to}\\",\\n \\"from\\": \\"${from}\\",\\n \\"subject\\": \\"${subject}\\",\\n \\"replyTo\\": \\"${from}\\",\\n \\"text\\": \\"${body}\\",\\n \\"html\\": \\"${bodyHtml}\\"\\n}",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Bearer us_12345",
|
||||
"Content-Type: application/json"
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err) {
|
||||
echo "cURL Error #:" . $err;
|
||||
} else {
|
||||
echo $response;
|
||||
}
|
||||
|
||||
`,
|
||||
},
|
||||
{
|
||||
language: "ruby",
|
||||
title: "Ruby",
|
||||
code: `require 'net/http'
|
||||
require 'uri'
|
||||
require 'json'
|
||||
|
||||
url = URI("https://app.usesend.com/api/v1/emails")
|
||||
|
||||
payload = {
|
||||
"to" => "${to}",
|
||||
"from" => "${from}",
|
||||
"subject" => "${subject}",
|
||||
"text" => "${body}",
|
||||
"html" => "${bodyHtml}"
|
||||
}.to_json
|
||||
|
||||
headers = {
|
||||
"Content-Type" => "application/json",
|
||||
"Authorization" => "Bearer us_12345"
|
||||
}
|
||||
|
||||
http = Net::HTTP.new(url.host, url.port)
|
||||
http.use_ssl = true
|
||||
|
||||
request = Net::HTTP::Post.new(url, headers)
|
||||
request.body = payload
|
||||
|
||||
response = http.request(request)
|
||||
|
||||
puts response.body
|
||||
`,
|
||||
},
|
||||
{
|
||||
language: "curl",
|
||||
title: "cURL",
|
||||
code: `curl -X POST https://app.usesend.com/api/v1/emails \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-H "Authorization: Bearer us_12345" \\
|
||||
-d '{"to": "${to}", "from": "${from}", "subject": "${subject}", "text": "${body}", "html": "${bodyHtml}"}'`,
|
||||
},
|
||||
];
|
||||
};
|
Reference in New Issue
Block a user