Skip to content

Commit 823084f

Browse files
committed
fix: add url to return envelope
1 parent 6320ab2 commit 823084f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

models/letter.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export class Letter {
6060
if (typeof input?.template_version_id !== "undefined") {
6161
this.template_version_id = input.template_version_id;
6262
}
63+
if (typeof input?.url !== "undefined") {
64+
this.url = input.url;
65+
}
6366
if (typeof input?.object !== "undefined") {
6467
this.object = input.object;
6568
}
@@ -214,6 +217,27 @@ export class Letter {
214217
this._template_version_id = newValue;
215218
}
216219

220+
/**
221+
* A [signed link](#section/Asset-URLs) served over HTTPS. The link returned will expire in 30 days to prevent mis-sharing. Each time a GET request is initiated, a new signed URL will be generated.
222+
* @type {string}
223+
* @memberof Letter
224+
*/
225+
private "_url"?: string;
226+
public get url() {
227+
return (this._url || undefined) as string;
228+
}
229+
public set url(newValue: string) {
230+
if (
231+
newValue &&
232+
!/^https:\/\/(lob-assets|lob-assets-staging)\.com\/(letters|postcards|bank-accounts|checks|self-mailers|cards)\/[a-z]{3,4}_[a-z0-9]{15,16}(\.pdf|_thumb_[a-z]+_[0-9]+\.png)\?(version=[a-z0-9-]*&)?expires=[0-9]{10}&signature=[a-zA-Z0-9-_]+$/.test(
233+
newValue
234+
)
235+
) {
236+
throw new Error("Invalid url provided");
237+
}
238+
this._url = newValue;
239+
}
240+
217241
/**
218242
*
219243
* @type {string}

0 commit comments

Comments
 (0)