@@ -32,7 +32,7 @@ const {
32
32
TESTING_ENDPOINT ,
33
33
BULK_ENDPOINT ,
34
34
} = CLIENT_SETTINGS ;
35
- const { TEST_INBOX_ID_MISSING , ACCOUNT_ID_MISSING , BULK_SANDBOX_INCOMPATIBLE } =
35
+ const { ACCOUNT_ID_MISSING , BULK_SANDBOX_INCOMPATIBLE , TEST_INBOX_ID_MISSING } =
36
36
ERRORS ;
37
37
38
38
/**
@@ -96,10 +96,6 @@ export default class MailtrapClient {
96
96
* Getter for Testing API. Warns if some of the required keys are missing.
97
97
*/
98
98
get testing ( ) {
99
- if ( ! this . testInboxId ) {
100
- throw new MailtrapError ( TEST_INBOX_ID_MISSING ) ;
101
- }
102
-
103
99
this . validateAccountIdPresence ( ) ;
104
100
105
101
return new TestingAPI ( this . axios , this . accountId ) ;
@@ -132,6 +128,9 @@ export default class MailtrapClient {
132
128
return new ContactListsBaseAPI ( this . axios , this . accountId ) ;
133
129
}
134
130
131
+ /**
132
+ * Getter for Templates API.
133
+ */
135
134
get templates ( ) {
136
135
this . validateAccountIdPresence ( ) ;
137
136
@@ -164,8 +163,13 @@ export default class MailtrapClient {
164
163
*/
165
164
public async send ( mail : Mail ) : Promise < SendResponse > {
166
165
const host = this . determineHost ( ) ;
166
+
167
+ if ( this . sandbox && ! this . testInboxId ) {
168
+ throw new MailtrapError ( TEST_INBOX_ID_MISSING ) ;
169
+ }
170
+
167
171
const url = `${ host } /api/send${
168
- this . testInboxId ? `/${ this . testInboxId } ` : ""
172
+ this . sandbox && this . testInboxId ? `/${ this . testInboxId } ` : ""
169
173
} `;
170
174
const preparedMail = encodeMailBuffers ( mail ) ;
171
175
0 commit comments