11import WarrantModule from "./WarrantModule" ;
22import WarrantClient from "../WarrantClient" ;
33import { CreateFeatureParams , ListFeatureOptions } from "../types/Feature" ;
4+ import { WarrantRequestOptions } from "../types/WarrantRequestOptions" ;
45import Warrant , { WarrantObject } from "../types/Warrant" ;
56import { ObjectType } from "../types/ObjectType" ;
67
@@ -14,11 +15,12 @@ export default class Feature implements WarrantObject {
1415 //
1516 // Static methods
1617 //
17- public static async create ( feature : CreateFeatureParams ) : Promise < Feature > {
18+ public static async create ( feature : CreateFeatureParams , options : WarrantRequestOptions = { } ) : Promise < Feature > {
1819 try {
1920 const response = await WarrantClient . httpClient . post ( {
2021 url : "/v1/features" ,
2122 data : feature ,
23+ options,
2224 } ) ;
2325
2426 return new Feature ( response . featureId ) ;
@@ -27,10 +29,11 @@ export default class Feature implements WarrantObject {
2729 }
2830 }
2931
30- public static async get ( featureId : string ) : Promise < Feature > {
32+ public static async get ( featureId : string , options : WarrantRequestOptions = { } ) : Promise < Feature > {
3133 try {
3234 const response = await WarrantClient . httpClient . get ( {
3335 url : `/v1/features/${ featureId } ` ,
36+ options,
3437 } ) ;
3538
3639 return new Feature ( response . featureId ) ;
@@ -39,21 +42,23 @@ export default class Feature implements WarrantObject {
3942 }
4043 }
4144
42- public static async delete ( featureId : string ) : Promise < void > {
45+ public static async delete ( featureId : string , options : WarrantRequestOptions = { } ) : Promise < void > {
4346 try {
4447 return await WarrantClient . httpClient . delete ( {
4548 url : `/v1/features/${ featureId } ` ,
49+ options,
4650 } ) ;
4751 } catch ( e ) {
4852 throw e ;
4953 }
5054 }
5155
52- public static async listFeatures ( listOptions : ListFeatureOptions = { } ) : Promise < Feature [ ] > {
56+ public static async listFeatures ( listOptions : ListFeatureOptions = { } , options : WarrantRequestOptions = { } ) : Promise < Feature [ ] > {
5357 try {
5458 const response = await WarrantClient . httpClient . get ( {
5559 url : "/v1/features" ,
5660 params : listOptions ,
61+ options,
5762 } ) ;
5863
5964 return response . map ( ( feature : Feature ) => new Feature ( feature . featureId ) ) ;
@@ -62,11 +67,12 @@ export default class Feature implements WarrantObject {
6267 }
6368 }
6469
65- public static async listFeaturesForPricingTier ( pricingTierId : string , listOptions : ListFeatureOptions = { } ) : Promise < Feature [ ] > {
70+ public static async listFeaturesForPricingTier ( pricingTierId : string , listOptions : ListFeatureOptions = { } , options : WarrantRequestOptions = { } ) : Promise < Feature [ ] > {
6671 try {
6772 const response = await WarrantClient . httpClient . get ( {
6873 url : `/v1/pricing-tiers/${ pricingTierId } /features` ,
6974 params : listOptions ,
75+ options,
7076 } ) ;
7177
7278 return response . map ( ( feature : Feature ) => new Feature ( feature . featureId ) ) ;
@@ -75,7 +81,7 @@ export default class Feature implements WarrantObject {
7581 }
7682 }
7783
78- public static async assignFeatureToPricingTier ( pricingTierId : string , featureId : string ) : Promise < Warrant > {
84+ public static async assignFeatureToPricingTier ( pricingTierId : string , featureId : string , options : WarrantRequestOptions = { } ) : Promise < Warrant > {
7985 return WarrantModule . create ( {
8086 object : {
8187 objectType : ObjectType . Feature ,
@@ -86,10 +92,10 @@ export default class Feature implements WarrantObject {
8692 objectType : ObjectType . PricingTier ,
8793 objectId : pricingTierId ,
8894 }
89- } ) ;
95+ } , options ) ;
9096 }
9197
92- public static async removeFeatureFromPricingTier ( pricingTierId : string , featureId : string ) : Promise < void > {
98+ public static async removeFeatureFromPricingTier ( pricingTierId : string , featureId : string , options : WarrantRequestOptions = { } ) : Promise < void > {
9399 return WarrantModule . delete ( {
94100 object : {
95101 objectType : ObjectType . Feature ,
@@ -100,14 +106,15 @@ export default class Feature implements WarrantObject {
100106 objectType : ObjectType . PricingTier ,
101107 objectId : pricingTierId ,
102108 }
103- } ) ;
109+ } , options ) ;
104110 }
105111
106- public static async listFeaturesForTenant ( tenantId : string , listOptions : ListFeatureOptions = { } ) : Promise < Feature [ ] > {
112+ public static async listFeaturesForTenant ( tenantId : string , listOptions : ListFeatureOptions = { } , options : WarrantRequestOptions = { } ) : Promise < Feature [ ] > {
107113 try {
108114 const response = await WarrantClient . httpClient . get ( {
109115 url : `/v1/tenants/${ tenantId } /features` ,
110116 params : listOptions ,
117+ options,
111118 } ) ;
112119
113120 return response . map ( ( feature : Feature ) => new Feature ( feature . featureId ) ) ;
@@ -116,7 +123,7 @@ export default class Feature implements WarrantObject {
116123 }
117124 }
118125
119- public static async assignFeatureToTenant ( tenantId : string , featureId : string ) : Promise < Warrant > {
126+ public static async assignFeatureToTenant ( tenantId : string , featureId : string , options : WarrantRequestOptions = { } ) : Promise < Warrant > {
120127 return WarrantModule . create ( {
121128 object : {
122129 objectType : ObjectType . Feature ,
@@ -127,10 +134,10 @@ export default class Feature implements WarrantObject {
127134 objectType : ObjectType . Tenant ,
128135 objectId : tenantId ,
129136 }
130- } ) ;
137+ } , options ) ;
131138 }
132139
133- public static async removeFeatureFromTenant ( tenantId : string , featureId : string ) : Promise < void > {
140+ public static async removeFeatureFromTenant ( tenantId : string , featureId : string , options : WarrantRequestOptions = { } ) : Promise < void > {
134141 return WarrantModule . delete ( {
135142 object : {
136143 objectType : ObjectType . Feature ,
@@ -141,14 +148,15 @@ export default class Feature implements WarrantObject {
141148 objectType : ObjectType . Tenant ,
142149 objectId : tenantId ,
143150 }
144- } ) ;
151+ } , options ) ;
145152 }
146153
147- public static async listFeaturesForUser ( userId : string , listOptions : ListFeatureOptions = { } ) : Promise < Feature [ ] > {
154+ public static async listFeaturesForUser ( userId : string , listOptions : ListFeatureOptions = { } , options : WarrantRequestOptions = { } ) : Promise < Feature [ ] > {
148155 try {
149156 const response = await WarrantClient . httpClient . get ( {
150157 url : `/v1/users/${ userId } /features` ,
151158 params : listOptions ,
159+ options,
152160 } ) ;
153161
154162 return response . map ( ( feature : Feature ) => new Feature ( feature . featureId ) ) ;
@@ -157,7 +165,7 @@ export default class Feature implements WarrantObject {
157165 }
158166 }
159167
160- public static async assignFeatureToUser ( userId : string , featureId : string ) : Promise < Warrant > {
168+ public static async assignFeatureToUser ( userId : string , featureId : string , options : WarrantRequestOptions = { } ) : Promise < Warrant > {
161169 return WarrantModule . create ( {
162170 object : {
163171 objectType : ObjectType . Feature ,
@@ -168,10 +176,10 @@ export default class Feature implements WarrantObject {
168176 objectType : ObjectType . User ,
169177 objectId : userId ,
170178 }
171- } ) ;
179+ } , options ) ;
172180 }
173181
174- public static async removeFeatureFromUser ( userId : string , featureId : string ) : Promise < void > {
182+ public static async removeFeatureFromUser ( userId : string , featureId : string , options : WarrantRequestOptions = { } ) : Promise < void > {
175183 return WarrantModule . delete ( {
176184 object : {
177185 objectType : ObjectType . Feature ,
@@ -182,7 +190,7 @@ export default class Feature implements WarrantObject {
182190 objectType : ObjectType . User ,
183191 objectId : userId ,
184192 }
185- } ) ;
193+ } , options ) ;
186194 }
187195
188196 // WarrantObject methods
0 commit comments