resend 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Resend } from '../resend';
|
|
2
|
-
import { CreateApiKeyOptions, CreateApiKeyRequestOptions } from './interfaces';
|
|
2
|
+
import { CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse } from './interfaces';
|
|
3
3
|
export declare class ApiKeys {
|
|
4
4
|
private readonly resend;
|
|
5
5
|
constructor(resend: Resend);
|
|
6
|
-
create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<
|
|
6
|
+
create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
|
|
7
7
|
list(): Promise<void>;
|
|
8
8
|
remove(id: string): Promise<void>;
|
|
9
9
|
}
|
|
@@ -16,8 +16,8 @@ class ApiKeys {
|
|
|
16
16
|
}
|
|
17
17
|
create(payload, options = {}) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const { data } = yield this.resend.post('/api-keys', payload, options);
|
|
20
|
-
return data;
|
|
19
|
+
const { data: apiKey } = yield this.resend.post('/api-keys', payload, options);
|
|
20
|
+
return { token: apiKey.data };
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
list() {
|
|
@@ -19,13 +19,16 @@ const mock = new axios_mock_adapter_1.default(axios_1.default);
|
|
|
19
19
|
describe('API Keys', () => {
|
|
20
20
|
describe('create', () => {
|
|
21
21
|
it('creates an api key', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
mock
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
mock.onPost('/api-keys', { name: 'Test' }).replyOnce(201, {
|
|
23
|
+
data: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
|
|
24
|
+
});
|
|
25
|
+
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
26
|
+
yield expect(resend.apiKeys.create({ name: 'Test' })).resolves
|
|
27
|
+
.toMatchInlineSnapshot(`
|
|
28
|
+
{
|
|
29
|
+
"token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
|
|
30
|
+
}
|
|
31
|
+
`);
|
|
29
32
|
expect(mock.history.post.length).toBe(1);
|
|
30
33
|
}));
|
|
31
34
|
});
|