@@ -36,6 +36,10 @@ export default function createSpaceApi ({
36
36
const { wrapEntry, wrapEntryCollection} = entities . entry
37
37
const { wrapAsset, wrapAssetCollection} = entities . asset
38
38
const { wrapLocale, wrapLocaleCollection} = entities . locale
39
+ const { wrapWebhook, wrapWebhookCollection} = entities . webhook
40
+ const { wrapRole, wrapRoleCollection} = entities . role
41
+ const { wrapSpaceMembership, wrapSpaceMembershipCollection} = entities . spaceMembership
42
+ const { wrapApiKey, wrapApiKeyCollection} = entities . apiKey
39
43
40
44
/**
41
45
* Space instances.
@@ -352,6 +356,238 @@ export default function createSpaceApi ({
352
356
. then ( ( response ) => wrapLocale ( http , response . data ) , errorHandler )
353
357
}
354
358
359
+ /**
360
+ * Gets a Webhook
361
+ * @memberof ContentfulSpaceAPI
362
+ * @param {string } id
363
+ * @return {Promise<Entities.Webhook> } Promise for a Webhook
364
+ * @example
365
+ * space.getWebhook('id')
366
+ * .then(webhook => console.log(webhook))
367
+ */
368
+ function getWebhook ( id ) {
369
+ return http . get ( 'webhook_definitions/' + id )
370
+ . then ( ( response ) => wrapWebhook ( http , response . data ) , errorHandler )
371
+ }
372
+
373
+ /**
374
+ * Gets a collection of Webhooks
375
+ * @memberof ContentfulSpaceAPI
376
+ * @return {Promise<Entities.WebhookCollection> } Promise for a collection of Webhooks
377
+ * @example
378
+ * space.getWebhooks()
379
+ * .then(webhooks => console.log(webhooks.items))
380
+ */
381
+ function getWebhooks ( ) {
382
+ return http . get ( 'webhook_definitions' )
383
+ . then ( ( response ) => wrapWebhookCollection ( http , response . data ) , errorHandler )
384
+ }
385
+
386
+ /**
387
+ * Creates a Webhook
388
+ * @memberof ContentfulSpaceAPI
389
+ * @see {Entities.Webhook}
390
+ * @param {object } data - Object representation of the Webhook to be created
391
+ * @return {Promise<Entities.Webhook> } Promise for the newly created Webhook
392
+ * @example
393
+ * space.createWebhook({})
394
+ * .then(webhook => console.log(webhook))
395
+ */
396
+ function createWebhook ( data ) {
397
+ return http . post ( 'webhook_definitions' , data )
398
+ . then ( ( response ) => wrapWebhook ( http , response . data ) , errorHandler )
399
+ }
400
+
401
+ /**
402
+ * Creates a Webhook with a specific id
403
+ * @memberof ContentfulSpaceAPI
404
+ * @see {Entities.Webhook}
405
+ * @param {string } id - Webhook ID
406
+ * @param {object } data - Object representation of the Webhook to be created
407
+ * @return {Promise<Entities.Webhook> } Promise for the newly created Webhook
408
+ * @example
409
+ * space.createWebhook('id', {})
410
+ * .then(webhook => console.log(webhook))
411
+ */
412
+ function createWebhookWithId ( id , data ) {
413
+ return http . put ( 'webhook_definitions/' + id , data )
414
+ . then ( ( response ) => wrapWebhook ( http , response . data ) , errorHandler )
415
+ }
416
+
417
+ /**
418
+ * Gets a Space Membership
419
+ * @memberof ContentfulSpaceAPI
420
+ * @param {string } id
421
+ * @return {Promise<Entities.SpaceMembership> } Promise for a Space Membership
422
+ * @example
423
+ * space.getSpaceMembership('id')
424
+ * .then(spaceMembership => console.log(spaceMembership))
425
+ */
426
+ function getSpaceMembership ( id ) {
427
+ return http . get ( 'space_memberships/' + id )
428
+ . then ( ( response ) => wrapSpaceMembership ( http , response . data ) , errorHandler )
429
+ }
430
+
431
+ /**
432
+ * Gets a collection of Space Memberships
433
+ * @memberof ContentfulSpaceAPI
434
+ * @return {Promise<Entities.SpaceMembershipCollection> } Promise for a collection of Space Memberships
435
+ * @example
436
+ * space.getSpaceMemberships()
437
+ * .then(spaceMemberships => console.log(spaceMemberships.items))
438
+ */
439
+ function getSpaceMemberships ( ) {
440
+ return http . get ( 'space_memberships' )
441
+ . then ( ( response ) => wrapSpaceMembershipCollection ( http , response . data ) , errorHandler )
442
+ }
443
+
444
+ /**
445
+ * Creates a Space Membership
446
+ * @memberof ContentfulSpaceAPI
447
+ * @see {Entities.SpaceMembership}
448
+ * @param {object } data - Object representation of the Space Membership to be created
449
+ * @return {Promise<Entities.SpaceMembership> } Promise for the newly created Space Membership
450
+ * @example
451
+ * space.createSpaceMembership({})
452
+ * .then(spaceMembership => console.log(spaceMembership))
453
+ */
454
+ function createSpaceMembership ( data ) {
455
+ return http . post ( 'space_memberships' , data )
456
+ . then ( ( response ) => wrapSpaceMembership ( http , response . data ) , errorHandler )
457
+ }
458
+
459
+ /**
460
+ * Creates a Space Membership with a specific id
461
+ * @memberof ContentfulSpaceAPI
462
+ * @see {Entities.SpaceMembership}
463
+ * @param {string } id - Space Membership ID
464
+ * @param {object } data - Object representation of the Space Membership to be created
465
+ * @return {Promise<Entities.SpaceMembership> } Promise for the newly created Space Membership
466
+ * @example
467
+ * space.createSpaceMembership('id', {})
468
+ * .then(spaceMembership => console.log(spaceMembership))
469
+ */
470
+ function createSpaceMembershipWithId ( id , data ) {
471
+ return http . put ( 'space_memberships/' + id , data )
472
+ . then ( ( response ) => wrapSpaceMembership ( http , response . data ) , errorHandler )
473
+ }
474
+
475
+ /**
476
+ * Gets a Role
477
+ * @memberof ContentfulSpaceAPI
478
+ * @param {string } id
479
+ * @return {Promise<Entities.Role> } Promise for a Role
480
+ * @example
481
+ * space.getRole('id')
482
+ * .then(role => console.log(role))
483
+ */
484
+ function getRole ( id ) {
485
+ return http . get ( 'roles/' + id )
486
+ . then ( ( response ) => wrapRole ( http , response . data ) , errorHandler )
487
+ }
488
+
489
+ /**
490
+ * Gets a collection of Roles
491
+ * @memberof ContentfulSpaceAPI
492
+ * @return {Promise<Entities.RoleCollection> } Promise for a collection of Roles
493
+ * @example
494
+ * space.getRoles()
495
+ * .then(roles => console.log(roles.items))
496
+ */
497
+ function getRoles ( ) {
498
+ return http . get ( 'roles' )
499
+ . then ( ( response ) => wrapRoleCollection ( http , response . data ) , errorHandler )
500
+ }
501
+
502
+ /**
503
+ * Creates a Role
504
+ * @memberof ContentfulSpaceAPI
505
+ * @see {Entities.Role}
506
+ * @param {object } data - Object representation of the Role to be created
507
+ * @return {Promise<Entities.Role> } Promise for the newly created Role
508
+ * @example
509
+ * space.createRole({})
510
+ * .then(role => console.log(role))
511
+ */
512
+ function createRole ( data ) {
513
+ return http . post ( 'roles' , data )
514
+ . then ( ( response ) => wrapRole ( http , response . data ) , errorHandler )
515
+ }
516
+
517
+ /**
518
+ * Creates a Role with a specific id
519
+ * @memberof ContentfulSpaceAPI
520
+ * @see {Entities.Role}
521
+ * @param {string } id - Role ID
522
+ * @param {object } data - Object representation of the Role to be created
523
+ * @return {Promise<Entities.Role> } Promise for the newly created Role
524
+ * @example
525
+ * space.createRole('id', {})
526
+ * .then(role => console.log(role))
527
+ */
528
+ function createRoleWithId ( id , data ) {
529
+ return http . put ( 'roles/' + id , data )
530
+ . then ( ( response ) => wrapRole ( http , response . data ) , errorHandler )
531
+ }
532
+
533
+ /**
534
+ * Gets a Api Key
535
+ * @memberof ContentfulSpaceAPI
536
+ * @param {string } id
537
+ * @return {Promise<Entities.ApiKey> } Promise for a Api Key
538
+ * @example
539
+ * space.getApiKey('id')
540
+ * .then(apiKey => console.log(apiKey))
541
+ */
542
+ function getApiKey ( id ) {
543
+ return http . get ( 'api_keys/' + id )
544
+ . then ( ( response ) => wrapApiKey ( http , response . data ) , errorHandler )
545
+ }
546
+
547
+ /**
548
+ * Gets a collection of Api Keys
549
+ * @memberof ContentfulSpaceAPI
550
+ * @return {Promise<Entities.ApiKeyCollection> } Promise for a collection of Api Keys
551
+ * @example
552
+ * space.getApiKeys()
553
+ * .then(apiKeys => console.log(apiKeys.items))
554
+ */
555
+ function getApiKeys ( ) {
556
+ return http . get ( 'api_keys' )
557
+ . then ( ( response ) => wrapApiKeyCollection ( http , response . data ) , errorHandler )
558
+ }
559
+
560
+ /**
561
+ * Creates a Api Key
562
+ * @memberof ContentfulSpaceAPI
563
+ * @see {Entities.ApiKey}
564
+ * @param {object } data - Object representation of the Api Key to be created
565
+ * @return {Promise<Entities.ApiKey> } Promise for the newly created Api Key
566
+ * @example
567
+ * space.createApiKey({})
568
+ * .then(apiKey => console.log(apiKey))
569
+ */
570
+ function createApiKey ( data ) {
571
+ return http . post ( 'api_keys' , data )
572
+ . then ( ( response ) => wrapApiKey ( http , response . data ) , errorHandler )
573
+ }
574
+
575
+ /**
576
+ * Creates a Api Key with a specific id
577
+ * @memberof ContentfulSpaceAPI
578
+ * @see {Entities.ApiKey}
579
+ * @param {string } id - Api Key ID
580
+ * @param {object } data - Object representation of the Api Key to be created
581
+ * @return {Promise<Entities.ApiKey> } Promise for the newly created Api Key
582
+ * @example
583
+ * space.createApiKey('id', {})
584
+ * .then(apiKey => console.log(apiKey))
585
+ */
586
+ function createApiKeyWithId ( id , data ) {
587
+ return http . put ( 'api_keys/' + id , data )
588
+ . then ( ( response ) => wrapApiKey ( http , response . data ) , errorHandler )
589
+ }
590
+
355
591
return {
356
592
delete : deleteSpace ,
357
593
update : updateSpace ,
@@ -369,6 +605,22 @@ export default function createSpaceApi ({
369
605
createAssetWithId : createAssetWithId ,
370
606
getLocale : getLocale ,
371
607
getLocales : getLocales ,
372
- createLocale : createLocale
608
+ createLocale : createLocale ,
609
+ getWebhook : getWebhook ,
610
+ getWebhooks : getWebhooks ,
611
+ createWebhook : createWebhook ,
612
+ createWebhookWithId : createWebhookWithId ,
613
+ getRole : getRole ,
614
+ getRoles : getRoles ,
615
+ createRole : createRole ,
616
+ createRoleWithId : createRoleWithId ,
617
+ getSpaceMembership : getSpaceMembership ,
618
+ getSpaceMemberships : getSpaceMemberships ,
619
+ createSpaceMembership : createSpaceMembership ,
620
+ createSpaceMembershipWithId : createSpaceMembershipWithId ,
621
+ getApiKey : getApiKey ,
622
+ getApiKeys : getApiKeys ,
623
+ createApiKey : createApiKey ,
624
+ createApiKeyWithId : createApiKeyWithId
373
625
}
374
626
}
0 commit comments