@@ -17,12 +17,14 @@ import type { Client } from 'openapi-fetch'
1717 */
1818export class Customers {
1919 public apps : CustomerApps
20- public entitlements : CustomerEntitlements
20+ public entitlementsV1 : CustomerEntitlements
21+ public entitlements : CustomerEntitlementsV2
2122 public stripe : CustomerStripe
2223
2324 constructor ( private client : Client < paths , `${string } /${string } `> ) {
2425 this . apps = new CustomerApps ( client )
25- this . entitlements = new CustomerEntitlements ( client )
26+ this . entitlementsV1 = new CustomerEntitlements ( client )
27+ this . entitlements = new CustomerEntitlementsV2 ( client )
2628 this . stripe = new CustomerStripe ( client )
2729 }
2830
@@ -383,3 +385,288 @@ export class CustomerEntitlements {
383385 return transformResponse ( resp )
384386 }
385387}
388+
389+ /**
390+ * Customer Entitlements V2
391+ */
392+ export class CustomerEntitlementsV2 {
393+ constructor ( private client : Client < paths , `${string } /${string } `> ) { }
394+
395+ /**
396+ * List all entitlements for a customer
397+ * @param customerIdOrKey - The ID or Key of the customer
398+ * @param options - Request options including query parameters
399+ * @returns List of customer entitlements
400+ */
401+ public async list (
402+ customerIdOrKey : operations [ 'listCustomerEntitlementsV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
403+ options ?: RequestOptions & {
404+ query ?: operations [ 'listCustomerEntitlementsV2' ] [ 'parameters' ] [ 'query' ]
405+ }
406+ ) {
407+ const resp = await this . client . GET (
408+ '/api/v2/customers/{customerIdOrKey}/entitlements' ,
409+ {
410+ params : {
411+ path : { customerIdOrKey } ,
412+ query : options ?. query ,
413+ } ,
414+ ...options ,
415+ }
416+ )
417+
418+ return transformResponse ( resp )
419+ }
420+
421+ /**
422+ * Create a customer entitlement
423+ * @param customerIdOrKey - The ID or Key of the customer
424+ * @param entitlement - The entitlement data to create
425+ * @param options - Request options
426+ * @returns The created entitlement
427+ */
428+ public async create (
429+ customerIdOrKey : operations [ 'createCustomerEntitlementV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
430+ entitlement : operations [ 'createCustomerEntitlementV2' ] [ 'requestBody' ] [ 'content' ] [ 'application/json' ] ,
431+ options ?: RequestOptions
432+ ) {
433+ const resp = await this . client . POST (
434+ '/api/v2/customers/{customerIdOrKey}/entitlements' ,
435+ {
436+ body : entitlement ,
437+ params : {
438+ path : { customerIdOrKey } ,
439+ } ,
440+ ...options ,
441+ }
442+ )
443+
444+ return transformResponse ( resp )
445+ }
446+
447+ /**
448+ * Get a specific customer entitlement
449+ * @param customerIdOrKey - The ID or Key of the customer
450+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
451+ * @param options - Request options
452+ * @returns The entitlement
453+ */
454+ public async get (
455+ customerIdOrKey : operations [ 'getCustomerEntitlementV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
456+ entitlementIdOrFeatureKey : operations [ 'getCustomerEntitlementV2' ] [ 'parameters' ] [ 'path' ] [ 'entitlementIdOrFeatureKey' ] ,
457+ options ?: RequestOptions
458+ ) {
459+ const resp = await this . client . GET (
460+ '/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}' ,
461+ {
462+ params : {
463+ path : { customerIdOrKey, entitlementIdOrFeatureKey } ,
464+ } ,
465+ ...options ,
466+ }
467+ )
468+
469+ return transformResponse ( resp )
470+ }
471+
472+ /**
473+ * Delete a customer entitlement
474+ * @param customerIdOrKey - The ID or Key of the customer
475+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
476+ * @param options - Request options
477+ * @returns The deletion response
478+ */
479+ public async delete (
480+ customerIdOrKey : operations [ 'deleteCustomerEntitlementV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
481+ entitlementIdOrFeatureKey : operations [ 'deleteCustomerEntitlementV2' ] [ 'parameters' ] [ 'path' ] [ 'entitlementIdOrFeatureKey' ] ,
482+ options ?: RequestOptions
483+ ) {
484+ const resp = await this . client . DELETE (
485+ '/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}' ,
486+ {
487+ params : {
488+ path : { customerIdOrKey, entitlementIdOrFeatureKey } ,
489+ } ,
490+ ...options ,
491+ }
492+ )
493+
494+ return transformResponse ( resp )
495+ }
496+
497+ /**
498+ * Override a customer entitlement
499+ * @param customerIdOrKey - The ID or Key of the customer
500+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
501+ * @param entitlement - The new entitlement data
502+ * @param options - Request options
503+ * @returns The overridden entitlement
504+ */
505+ public async override (
506+ customerIdOrKey : operations [ 'overrideCustomerEntitlementV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
507+ entitlementIdOrFeatureKey : operations [ 'overrideCustomerEntitlementV2' ] [ 'parameters' ] [ 'path' ] [ 'entitlementIdOrFeatureKey' ] ,
508+ entitlement : operations [ 'overrideCustomerEntitlementV2' ] [ 'requestBody' ] [ 'content' ] [ 'application/json' ] ,
509+ options ?: RequestOptions
510+ ) {
511+ const resp = await this . client . PUT (
512+ '/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/override' ,
513+ {
514+ body : entitlement ,
515+ params : {
516+ path : { customerIdOrKey, entitlementIdOrFeatureKey } ,
517+ } ,
518+ ...options ,
519+ }
520+ )
521+
522+ return transformResponse ( resp )
523+ }
524+
525+ /**
526+ * List grants for a customer entitlement
527+ * @param customerIdOrKey - The ID or Key of the customer
528+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
529+ * @param options - Request options including query parameters
530+ * @returns List of entitlement grants
531+ */
532+ public async listGrants (
533+ customerIdOrKey : operations [ 'listCustomerEntitlementGrantsV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
534+ entitlementIdOrFeatureKey : operations [ 'listCustomerEntitlementGrantsV2' ] [ 'parameters' ] [ 'path' ] [ 'entitlementIdOrFeatureKey' ] ,
535+ options ?: RequestOptions & {
536+ query ?: operations [ 'listCustomerEntitlementGrantsV2' ] [ 'parameters' ] [ 'query' ]
537+ }
538+ ) {
539+ const resp = await this . client . GET (
540+ '/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/grants' ,
541+ {
542+ params : {
543+ path : { customerIdOrKey, entitlementIdOrFeatureKey } ,
544+ query : options ?. query ,
545+ } ,
546+ ...options ,
547+ }
548+ )
549+
550+ return transformResponse ( resp )
551+ }
552+
553+ /**
554+ * Create a grant for a customer entitlement
555+ * @param customerIdOrKey - The ID or Key of the customer
556+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
557+ * @param grant - The grant data to create
558+ * @param options - Request options
559+ * @returns The created grant
560+ */
561+ public async createGrant (
562+ customerIdOrKey : operations [ 'createCustomerEntitlementGrantV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
563+ entitlementIdOrFeatureKey : operations [ 'createCustomerEntitlementGrantV2' ] [ 'parameters' ] [ 'path' ] [ 'entitlementIdOrFeatureKey' ] ,
564+ grant : operations [ 'createCustomerEntitlementGrantV2' ] [ 'requestBody' ] [ 'content' ] [ 'application/json' ] ,
565+ options ?: RequestOptions
566+ ) {
567+ const resp = await this . client . POST (
568+ '/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/grants' ,
569+ {
570+ body : grant ,
571+ params : {
572+ path : { customerIdOrKey, entitlementIdOrFeatureKey } ,
573+ } ,
574+ ...options ,
575+ }
576+ )
577+
578+ return transformResponse ( resp )
579+ }
580+
581+ /**
582+ * Get the value of a customer entitlement
583+ * @param customerIdOrKey - The ID or Key of the customer
584+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
585+ * @param options - Request options including query parameters
586+ * @returns The entitlement value
587+ */
588+ public async value (
589+ customerIdOrKey : operations [ 'getCustomerEntitlementValueV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
590+ entitlementIdOrFeatureKey : operations [ 'getCustomerEntitlementValueV2' ] [ 'parameters' ] [ 'path' ] [ 'entitlementIdOrFeatureKey' ] ,
591+ options ?: RequestOptions & {
592+ query ?: operations [ 'getCustomerEntitlementValueV2' ] [ 'parameters' ] [ 'query' ]
593+ }
594+ ) {
595+ const resp = await this . client . GET (
596+ '/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/value' ,
597+ {
598+ params : {
599+ path : { customerIdOrKey, entitlementIdOrFeatureKey } ,
600+ query : options ?. query ,
601+ } ,
602+ ...options ,
603+ }
604+ )
605+
606+ return transformResponse ( resp )
607+ }
608+
609+ /**
610+ * Get the history of a customer entitlement
611+ * @param customerIdOrKey - The ID or Key of the customer
612+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
613+ * @param windowSize - The window size for the history
614+ * @param options - Request options including query parameters
615+ * @returns The entitlement history
616+ */
617+ public async history (
618+ customerIdOrKey : operations [ 'getCustomerEntitlementHistoryV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
619+ entitlementIdOrFeatureKey : operations [ 'getCustomerEntitlementHistoryV2' ] [ 'parameters' ] [ 'path' ] [ 'entitlementIdOrFeatureKey' ] ,
620+ windowSize : operations [ 'getCustomerEntitlementHistoryV2' ] [ 'parameters' ] [ 'query' ] [ 'windowSize' ] ,
621+ options ?: RequestOptions & {
622+ query ?: Omit <
623+ operations [ 'getCustomerEntitlementHistoryV2' ] [ 'parameters' ] [ 'query' ] ,
624+ 'windowSize'
625+ >
626+ }
627+ ) {
628+ const resp = await this . client . GET (
629+ '/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/history' ,
630+ {
631+ params : {
632+ path : { customerIdOrKey, entitlementIdOrFeatureKey } ,
633+ query : {
634+ windowSize,
635+ ...options ?. query ,
636+ } ,
637+ } ,
638+ ...options ,
639+ }
640+ )
641+
642+ return transformResponse ( resp )
643+ }
644+
645+ /**
646+ * Reset the usage of a customer entitlement
647+ * @param customerIdOrKey - The ID or Key of the customer
648+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
649+ * @param reset - The reset data
650+ * @param options - Request options
651+ * @returns The reset response
652+ */
653+ public async resetUsage (
654+ customerIdOrKey : operations [ 'resetCustomerEntitlementUsageV2' ] [ 'parameters' ] [ 'path' ] [ 'customerIdOrKey' ] ,
655+ entitlementIdOrFeatureKey : operations [ 'resetCustomerEntitlementUsageV2' ] [ 'parameters' ] [ 'path' ] [ 'entitlementIdOrFeatureKey' ] ,
656+ reset : operations [ 'resetCustomerEntitlementUsageV2' ] [ 'requestBody' ] [ 'content' ] [ 'application/json' ] ,
657+ options ?: RequestOptions
658+ ) {
659+ const resp = await this . client . POST (
660+ '/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/reset' ,
661+ {
662+ body : reset ,
663+ params : {
664+ path : { customerIdOrKey, entitlementIdOrFeatureKey } ,
665+ } ,
666+ ...options ,
667+ }
668+ )
669+
670+ return transformResponse ( resp )
671+ }
672+ }
0 commit comments