@@ -33,20 +33,22 @@ export class Assets {
3333 * @throws {@link Webflow.InternalServerError }
3434 *
3535 * @example
36- * await webflow.assets.list("string ")
36+ * await webflow.assets.list("site_id ")
3737 */
3838 public async list ( siteId : string , requestOptions ?: Assets . RequestOptions ) : Promise < Webflow . Asset [ ] > {
3939 const _response = await core . fetcher ( {
4040 url : urlJoin (
4141 ( await core . Supplier . get ( this . _options . environment ) ) ?? environments . WebflowEnvironment . Default ,
42- `v2/ sites/${ siteId } /assets`
42+ `sites/${ siteId } /assets`
4343 ) ,
4444 method : "GET" ,
4545 headers : {
4646 Authorization : await this . _getAuthorizationHeader ( ) ,
4747 "X-Fern-Language" : "JavaScript" ,
4848 "X-Fern-SDK-Name" : "webflow-api" ,
49- "X-Fern-SDK-Version" : "2.0.0-beta" ,
49+ "X-Fern-SDK-Version" : "v2.1.0" ,
50+ "X-Fern-Runtime" : core . RUNTIME . type ,
51+ "X-Fern-Runtime-Version" : core . RUNTIME . version ,
5052 } ,
5153 contentType : "application/json" ,
5254 timeoutMs : requestOptions ?. timeoutInSeconds != null ? requestOptions . timeoutInSeconds * 1000 : 60000 ,
@@ -106,7 +108,7 @@ export class Assets {
106108 * @throws {@link Webflow.InternalServerError }
107109 *
108110 * @example
109- * await webflow.assets.create("string ", {
111+ * await webflow.assets.create("site_id ", {
110112 * fileName: "file.png",
111113 * fileHash: "3c7d87c9575702bc3b1e991f4d3c638e",
112114 * parentFolder: "6436b1ce5281cace05b65aea"
@@ -120,14 +122,16 @@ export class Assets {
120122 const _response = await core . fetcher ( {
121123 url : urlJoin (
122124 ( await core . Supplier . get ( this . _options . environment ) ) ?? environments . WebflowEnvironment . Default ,
123- `v2/ sites/${ siteId } /assets`
125+ `sites/${ siteId } /assets`
124126 ) ,
125127 method : "POST" ,
126128 headers : {
127129 Authorization : await this . _getAuthorizationHeader ( ) ,
128130 "X-Fern-Language" : "JavaScript" ,
129131 "X-Fern-SDK-Name" : "webflow-api" ,
130- "X-Fern-SDK-Version" : "2.0.0-beta" ,
132+ "X-Fern-SDK-Version" : "v2.1.0" ,
133+ "X-Fern-Runtime" : core . RUNTIME . type ,
134+ "X-Fern-Runtime-Version" : core . RUNTIME . version ,
131135 } ,
132136 contentType : "application/json" ,
133137 body : await serializers . AssetsCreateRequest . jsonOrThrow ( request , { unrecognizedObjectKeys : "strip" } ) ,
@@ -188,20 +192,22 @@ export class Assets {
188192 * @throws {@link Webflow.InternalServerError }
189193 *
190194 * @example
191- * await webflow.assets.get("string ")
195+ * await webflow.assets.get("asset_id ")
192196 */
193197 public async get ( assetId : string , requestOptions ?: Assets . RequestOptions ) : Promise < Webflow . Asset > {
194198 const _response = await core . fetcher ( {
195199 url : urlJoin (
196200 ( await core . Supplier . get ( this . _options . environment ) ) ?? environments . WebflowEnvironment . Default ,
197- `v2/ assets/${ assetId } `
201+ `assets/${ assetId } `
198202 ) ,
199203 method : "GET" ,
200204 headers : {
201205 Authorization : await this . _getAuthorizationHeader ( ) ,
202206 "X-Fern-Language" : "JavaScript" ,
203207 "X-Fern-SDK-Name" : "webflow-api" ,
204- "X-Fern-SDK-Version" : "2.0.0-beta" ,
208+ "X-Fern-SDK-Version" : "v2.1.0" ,
209+ "X-Fern-Runtime" : core . RUNTIME . type ,
210+ "X-Fern-Runtime-Version" : core . RUNTIME . version ,
205211 } ,
206212 contentType : "application/json" ,
207213 timeoutMs : requestOptions ?. timeoutInSeconds != null ? requestOptions . timeoutInSeconds * 1000 : 60000 ,
@@ -261,20 +267,22 @@ export class Assets {
261267 * @throws {@link Webflow.InternalServerError }
262268 *
263269 * @example
264- * await webflow.assets.delete("string ")
270+ * await webflow.assets.delete("asset_id ")
265271 */
266272 public async delete ( assetId : string , requestOptions ?: Assets . RequestOptions ) : Promise < void > {
267273 const _response = await core . fetcher ( {
268274 url : urlJoin (
269275 ( await core . Supplier . get ( this . _options . environment ) ) ?? environments . WebflowEnvironment . Default ,
270- `v2/ assets/${ assetId } `
276+ `assets/${ assetId } `
271277 ) ,
272278 method : "DELETE" ,
273279 headers : {
274280 Authorization : await this . _getAuthorizationHeader ( ) ,
275281 "X-Fern-Language" : "JavaScript" ,
276282 "X-Fern-SDK-Name" : "webflow-api" ,
277- "X-Fern-SDK-Version" : "2.0.0-beta" ,
283+ "X-Fern-SDK-Version" : "v2.1.0" ,
284+ "X-Fern-Runtime" : core . RUNTIME . type ,
285+ "X-Fern-Runtime-Version" : core . RUNTIME . version ,
278286 } ,
279287 contentType : "application/json" ,
280288 timeoutMs : requestOptions ?. timeoutInSeconds != null ? requestOptions . timeoutInSeconds * 1000 : 60000 ,
@@ -319,6 +327,88 @@ export class Assets {
319327 }
320328 }
321329
330+ /**
331+ * Update an Asset </br></br> Required scope | `assets:write`
332+ * @throws {@link Webflow.BadRequestError }
333+ * @throws {@link Webflow.UnauthorizedError }
334+ * @throws {@link Webflow.NotFoundError }
335+ * @throws {@link Webflow.TooManyRequestsError }
336+ * @throws {@link Webflow.InternalServerError }
337+ *
338+ * @example
339+ * await webflow.assets.update("asset_id", {
340+ * displayName: "file.png"
341+ * })
342+ */
343+ public async update (
344+ assetId : string ,
345+ request : Webflow . AssetsUpdateRequest ,
346+ requestOptions ?: Assets . RequestOptions
347+ ) : Promise < Webflow . Asset > {
348+ const _response = await core . fetcher ( {
349+ url : urlJoin (
350+ ( await core . Supplier . get ( this . _options . environment ) ) ?? environments . WebflowEnvironment . Default ,
351+ `assets/${ assetId } `
352+ ) ,
353+ method : "PATCH" ,
354+ headers : {
355+ Authorization : await this . _getAuthorizationHeader ( ) ,
356+ "X-Fern-Language" : "JavaScript" ,
357+ "X-Fern-SDK-Name" : "webflow-api" ,
358+ "X-Fern-SDK-Version" : "v2.1.0" ,
359+ "X-Fern-Runtime" : core . RUNTIME . type ,
360+ "X-Fern-Runtime-Version" : core . RUNTIME . version ,
361+ } ,
362+ contentType : "application/json" ,
363+ body : await serializers . AssetsUpdateRequest . jsonOrThrow ( request , { unrecognizedObjectKeys : "strip" } ) ,
364+ timeoutMs : requestOptions ?. timeoutInSeconds != null ? requestOptions . timeoutInSeconds * 1000 : 60000 ,
365+ maxRetries : requestOptions ?. maxRetries ,
366+ } ) ;
367+ if ( _response . ok ) {
368+ return await serializers . Asset . parseOrThrow ( _response . body , {
369+ unrecognizedObjectKeys : "passthrough" ,
370+ allowUnrecognizedUnionMembers : true ,
371+ allowUnrecognizedEnumValues : true ,
372+ skipValidation : true ,
373+ breadcrumbsPrefix : [ "response" ] ,
374+ } ) ;
375+ }
376+
377+ if ( _response . error . reason === "status-code" ) {
378+ switch ( _response . error . statusCode ) {
379+ case 400 :
380+ throw new Webflow . BadRequestError ( _response . error . body ) ;
381+ case 401 :
382+ throw new Webflow . UnauthorizedError ( _response . error . body ) ;
383+ case 404 :
384+ throw new Webflow . NotFoundError ( _response . error . body ) ;
385+ case 429 :
386+ throw new Webflow . TooManyRequestsError ( _response . error . body ) ;
387+ case 500 :
388+ throw new Webflow . InternalServerError ( _response . error . body ) ;
389+ default :
390+ throw new errors . WebflowError ( {
391+ statusCode : _response . error . statusCode ,
392+ body : _response . error . body ,
393+ } ) ;
394+ }
395+ }
396+
397+ switch ( _response . error . reason ) {
398+ case "non-json" :
399+ throw new errors . WebflowError ( {
400+ statusCode : _response . error . statusCode ,
401+ body : _response . error . rawBody ,
402+ } ) ;
403+ case "timeout" :
404+ throw new errors . WebflowTimeoutError ( ) ;
405+ case "unknown" :
406+ throw new errors . WebflowError ( {
407+ message : _response . error . errorMessage ,
408+ } ) ;
409+ }
410+ }
411+
322412 /**
323413 * List Asset Folders within a given site <br><br> Required scope | `assets:read`
324414 * @throws {@link Webflow.BadRequestError }
@@ -328,20 +418,22 @@ export class Assets {
328418 * @throws {@link Webflow.InternalServerError }
329419 *
330420 * @example
331- * await webflow.assets.listFolders("string ")
421+ * await webflow.assets.listFolders("site_id ")
332422 */
333423 public async listFolders ( siteId : string , requestOptions ?: Assets . RequestOptions ) : Promise < Webflow . AssetFolderList > {
334424 const _response = await core . fetcher ( {
335425 url : urlJoin (
336426 ( await core . Supplier . get ( this . _options . environment ) ) ?? environments . WebflowEnvironment . Default ,
337- `v2/ sites/${ siteId } /asset_folders`
427+ `sites/${ siteId } /asset_folders`
338428 ) ,
339429 method : "GET" ,
340430 headers : {
341431 Authorization : await this . _getAuthorizationHeader ( ) ,
342432 "X-Fern-Language" : "JavaScript" ,
343433 "X-Fern-SDK-Name" : "webflow-api" ,
344- "X-Fern-SDK-Version" : "2.0.0-beta" ,
434+ "X-Fern-SDK-Version" : "v2.1.0" ,
435+ "X-Fern-Runtime" : core . RUNTIME . type ,
436+ "X-Fern-Runtime-Version" : core . RUNTIME . version ,
345437 } ,
346438 contentType : "application/json" ,
347439 timeoutMs : requestOptions ?. timeoutInSeconds != null ? requestOptions . timeoutInSeconds * 1000 : 60000 ,
@@ -401,7 +493,7 @@ export class Assets {
401493 * @throws {@link Webflow.InternalServerError }
402494 *
403495 * @example
404- * await webflow.assets.createFolder("string ", {
496+ * await webflow.assets.createFolder("site_id ", {
405497 * displayName: "my asset folder",
406498 * parentFolder: "6390c49774a71f99f21a08eb"
407499 * })
@@ -414,14 +506,16 @@ export class Assets {
414506 const _response = await core . fetcher ( {
415507 url : urlJoin (
416508 ( await core . Supplier . get ( this . _options . environment ) ) ?? environments . WebflowEnvironment . Default ,
417- `v2/ sites/${ siteId } /asset_folders`
509+ `sites/${ siteId } /asset_folders`
418510 ) ,
419511 method : "POST" ,
420512 headers : {
421513 Authorization : await this . _getAuthorizationHeader ( ) ,
422514 "X-Fern-Language" : "JavaScript" ,
423515 "X-Fern-SDK-Name" : "webflow-api" ,
424- "X-Fern-SDK-Version" : "2.0.0-beta" ,
516+ "X-Fern-SDK-Version" : "v2.1.0" ,
517+ "X-Fern-Runtime" : core . RUNTIME . type ,
518+ "X-Fern-Runtime-Version" : core . RUNTIME . version ,
425519 } ,
426520 contentType : "application/json" ,
427521 body : await serializers . AssetsCreateFolderRequest . jsonOrThrow ( request , { unrecognizedObjectKeys : "strip" } ) ,
@@ -482,7 +576,7 @@ export class Assets {
482576 * @throws {@link Webflow.InternalServerError }
483577 *
484578 * @example
485- * await webflow.assets.getFolder("string ")
579+ * await webflow.assets.getFolder("asset_folder_id ")
486580 */
487581 public async getFolder (
488582 assetFolderId : string ,
@@ -491,14 +585,16 @@ export class Assets {
491585 const _response = await core . fetcher ( {
492586 url : urlJoin (
493587 ( await core . Supplier . get ( this . _options . environment ) ) ?? environments . WebflowEnvironment . Default ,
494- `v2/ asset_folders/${ assetFolderId } `
588+ `asset_folders/${ assetFolderId } `
495589 ) ,
496590 method : "GET" ,
497591 headers : {
498592 Authorization : await this . _getAuthorizationHeader ( ) ,
499593 "X-Fern-Language" : "JavaScript" ,
500594 "X-Fern-SDK-Name" : "webflow-api" ,
501- "X-Fern-SDK-Version" : "2.0.0-beta" ,
595+ "X-Fern-SDK-Version" : "v2.1.0" ,
596+ "X-Fern-Runtime" : core . RUNTIME . type ,
597+ "X-Fern-Runtime-Version" : core . RUNTIME . version ,
502598 } ,
503599 contentType : "application/json" ,
504600 timeoutMs : requestOptions ?. timeoutInSeconds != null ? requestOptions . timeoutInSeconds * 1000 : 60000 ,
0 commit comments