warrant 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/warrant/api_operations.rb +9 -7
- data/lib/warrant/models/feature.rb +122 -99
- data/lib/warrant/models/list_response.rb +14 -0
- data/lib/warrant/models/object.rb +230 -0
- data/lib/warrant/models/permission.rb +72 -103
- data/lib/warrant/models/pricing_tier.rb +128 -97
- data/lib/warrant/models/query_result.rb +16 -0
- data/lib/warrant/models/role.rb +72 -97
- data/lib/warrant/models/session.rb +4 -4
- data/lib/warrant/models/tenant.rb +131 -133
- data/lib/warrant/models/user.rb +180 -155
- data/lib/warrant/models/warrant.rb +196 -94
- data/lib/warrant/version.rb +1 -1
- data/lib/warrant.rb +3 -0
- metadata +5 -2
@@ -1,21 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Warrant
|
4
|
-
class PricingTier
|
4
|
+
class PricingTier < Warrant::Object
|
5
5
|
OBJECT_TYPE = "pricing-tier"
|
6
6
|
|
7
7
|
include Warrant::WarrantObject
|
8
8
|
|
9
|
-
|
9
|
+
alias :pricing_tier_id :object_id
|
10
10
|
|
11
11
|
# @!visibility private
|
12
|
-
def initialize(pricing_tier_id)
|
13
|
-
|
12
|
+
def initialize(pricing_tier_id, meta = {}, created_at = nil)
|
13
|
+
super(OBJECT_TYPE, pricing_tier_id, meta, created_at)
|
14
14
|
end
|
15
15
|
|
16
16
|
# Creates a pricing tier with the given parameters
|
17
17
|
#
|
18
|
-
# @option params [String] :
|
18
|
+
# @option params [String] :pricing tier_id User defined string identifier for this pricing tier. If not provided, Warrant will create an id for the pricing tier and return it. In this case, you should store the id in your system as you will need to provide it for any authorization requests for that pricing tier. Note that pricingTierIds in Warrant must be composed of alphanumeric chars, '-', and/or '_'. (optional)
|
19
|
+
# @option params [Hash] :meta A JSON object containing additional information about this pricing tier (e.g. name/description) to be persisted to Warrant. (optional)
|
19
20
|
#
|
20
21
|
# @return [PricingTier] created pricing tier
|
21
22
|
#
|
@@ -26,16 +27,9 @@ module Warrant
|
|
26
27
|
# @raise [Warrant::InternalError]
|
27
28
|
# @raise [Warrant::InvalidRequestError]
|
28
29
|
# @raise [Warrant::UnauthorizedError]
|
29
|
-
def self.create(params = {})
|
30
|
-
|
31
|
-
|
32
|
-
case res
|
33
|
-
when Net::HTTPSuccess
|
34
|
-
res_json = JSON.parse(res.body)
|
35
|
-
PricingTier.new(res_json['pricingTierId'])
|
36
|
-
else
|
37
|
-
APIOperations.raise_error(res)
|
38
|
-
end
|
30
|
+
def self.create(params = {}, options = {})
|
31
|
+
object = Object.create({ object_type: OBJECT_TYPE, object_id: params[:pricing_tier_id], meta: params[:meta] }, options)
|
32
|
+
return PricingTier.new(object.object_id, object.meta, object.created_at)
|
39
33
|
end
|
40
34
|
|
41
35
|
# Deletes a pricing tier with given pricing tier id
|
@@ -51,45 +45,33 @@ module Warrant
|
|
51
45
|
# @raise [Warrant::InvalidParameterError]
|
52
46
|
# @raise [Warrant::NotFoundError]
|
53
47
|
# @raise [Warrant::UnauthorizedError]
|
54
|
-
def self.delete(pricing_tier_id)
|
55
|
-
|
56
|
-
|
57
|
-
case res
|
58
|
-
when Net::HTTPSuccess
|
59
|
-
return
|
60
|
-
else
|
61
|
-
APIOperations.raise_error(res)
|
62
|
-
end
|
48
|
+
def self.delete(pricing_tier_id, options = {})
|
49
|
+
return Object.delete(OBJECT_TYPE, pricing_tier_id, options)
|
63
50
|
end
|
64
51
|
|
65
52
|
# Lists all pricing tiers for your organization
|
66
53
|
#
|
67
|
-
# @
|
68
|
-
# @
|
69
|
-
# @option filters [
|
70
|
-
# @option filters [String] :
|
71
|
-
# @option filters [String] :
|
72
|
-
# @option filters [String] :
|
73
|
-
# @option filters [String] :
|
74
|
-
# @option
|
54
|
+
# @param [Hash] filters Filters to apply to result set
|
55
|
+
# @param [Hash] options Options to apply on a per-request basis
|
56
|
+
# @option filters [Integer] :limit A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)
|
57
|
+
# @option filters [String] :prev_cursor A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)
|
58
|
+
# @option filters [String] :next_cursor A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)
|
59
|
+
# @option filters [String] :sort_by The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are +object_type+, +object_id+, and +created_at+ (optional)
|
60
|
+
# @option filters [String] :sort_order The order in which to sort the result by. Valid values are +ASC+ and +DESC+. Defaults to +ASC+. (optional)
|
61
|
+
# @option options [String] :warrant_token A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)
|
75
62
|
#
|
76
|
-
# @return [Array<
|
63
|
+
# @return [Array<PricingTier>] all pricing tiers for your organization
|
77
64
|
#
|
78
65
|
# @example List all pricing tiers
|
79
66
|
# Warrant::PricingTier.list()
|
80
67
|
#
|
81
68
|
# @raise [Warrant::InternalError]
|
82
69
|
# @raise [Warrant::UnauthorizedError]
|
83
|
-
def self.list(filters = {})
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
pricing_tiers = JSON.parse(res.body)
|
89
|
-
pricing_tiers.map{ |pricing_tier| PricingTier.new(pricing_tier['pricingTierId']) }
|
90
|
-
else
|
91
|
-
APIOperations.raise_error(res)
|
92
|
-
end
|
70
|
+
def self.list(filters = {}, options = {})
|
71
|
+
filters.merge({ object_type: "pricing-tier" })
|
72
|
+
list_response = Object.list(filters, options)
|
73
|
+
pricing_tiers = list_response.results.map{ |object| PricingTier.new(object.object_id, object.meta, object.created_at)}
|
74
|
+
return ListResponse.new(pricing_tiers, list_response.prev_cursor, list_response.next_cursor)
|
93
75
|
end
|
94
76
|
|
95
77
|
# Get a pricing_tier with the given pricing_tier_id
|
@@ -102,46 +84,79 @@ module Warrant
|
|
102
84
|
# @raise [Warrant::InvalidParameterError]
|
103
85
|
# @raise [Warrant::NotFoundError]
|
104
86
|
# @raise [Warrant::UnauthorizedError]
|
105
|
-
def self.get(pricing_tier_id)
|
106
|
-
|
87
|
+
def self.get(pricing_tier_id, options = {})
|
88
|
+
object = Object.get(OBJECT_TYPE, pricing_tier_id, options)
|
89
|
+
return PricingTier.new(object.object_id, object.meta, object.created_at)
|
90
|
+
end
|
107
91
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
92
|
+
# Updates a pricing tier with the given pricing_tier_id and params
|
93
|
+
#
|
94
|
+
# @param pricing_tier_id [String] The pricing_tier_id of the pricing tier to be updated.
|
95
|
+
# @param meta [Hash] A JSON object containing additional information about this pricing tier (e.g. name/description, etc.) to be persisted to Warrant.
|
96
|
+
#
|
97
|
+
# @return [PricingTier] updated pricing tier
|
98
|
+
#
|
99
|
+
# @example Update pricing tier "test-pricing-tier"'s name
|
100
|
+
# Warrant::PricingTier.update("test-pricing-tier", { name: "Test Tier" })
|
101
|
+
#
|
102
|
+
# @raise [Warrant::InternalError]
|
103
|
+
# @raise [Warrant::InvalidParameterError]
|
104
|
+
# @raise [Warrant::InvalidRequestError]
|
105
|
+
# @raise [Warrant::NotFoundError]
|
106
|
+
# @raise [Warrant::UnauthorizedError]
|
107
|
+
def self.update(pricing_tier_id, meta, options = {})
|
108
|
+
object = Object.update(OBJECT_TYPE, pricing_tier_id, meta, options)
|
109
|
+
return PricingTier.new(object.object_id, object.meta, object.created_at)
|
115
110
|
end
|
116
111
|
|
112
|
+
# Updates a pricing tier with the given params
|
113
|
+
#
|
114
|
+
# @param meta [Hash] A JSON object containing additional information about this pricing tier (e.g. name/description, etc.) to be persisted to Warrant.
|
115
|
+
#
|
116
|
+
# @return [PricingTier] updated pricing tier
|
117
|
+
#
|
118
|
+
# @example Update pricing tier "test-pricing-tier"'s name
|
119
|
+
# pricing_tier = Warrant::PricingTier.get("test-pricing-tier")
|
120
|
+
# pricing_tier.update({ name: "Test Tier" })
|
121
|
+
#
|
122
|
+
# @raise [Warrant::InternalError]
|
123
|
+
# @raise [Warrant::InvalidParameterError]
|
124
|
+
# @raise [Warrant::InvalidRequestError]
|
125
|
+
# @raise [Warrant::NotFoundError]
|
126
|
+
# @raise [Warrant::UnauthorizedError]
|
127
|
+
def update(meta, options = {})
|
128
|
+
return PricingTier.update(pricing_tier_id, meta)
|
129
|
+
end
|
117
130
|
|
118
131
|
# List pricing tiers for tenant
|
119
132
|
#
|
120
133
|
# @param tenant_id [String] The tenant_id of the tenant to list pricing tiers for.
|
121
|
-
# @
|
122
|
-
# @
|
134
|
+
# @param [Hash] filters Filters to apply to result set
|
135
|
+
# @param [Hash] options Options to apply on a per-request basis
|
136
|
+
# @option filters [String] :object_type Only return objects with an `objectType` matching this value
|
137
|
+
# @option filters [Integer] :limit A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)
|
138
|
+
# @option filters [String] :prev_cursor A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)
|
139
|
+
# @option filters [String] :next_cursor A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)
|
140
|
+
# @option filters [String] :sort_by The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are +object_type+, +object_id+, and +created_at+ (optional)
|
141
|
+
# @option filters [String] :sort_order The order in which to sort the result by. Valid values are +ASC+ and +DESC+. Defaults to +ASC+. (optional)
|
142
|
+
# @option options [String] :warrant_token A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)
|
123
143
|
#
|
124
144
|
# @return [Array<PricingTier>] assigned pricing tiers for the tenant
|
125
145
|
#
|
126
146
|
# @raise [Warrant::InternalError]
|
127
147
|
# @raise [Warrant::InvalidParameterError]
|
128
148
|
# @raise [Warrant::UnauthorizedError]
|
129
|
-
def self.list_for_tenant(tenant_id, filters = {})
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
when Net::HTTPSuccess
|
134
|
-
pricing_tiers = JSON.parse(res.body)
|
135
|
-
pricing_tiers.map{ |pricing_tier| PricingTier.new(pricing_tier['pricingTierId']) }
|
136
|
-
else
|
137
|
-
APIOperations.raise_error(res)
|
138
|
-
end
|
149
|
+
def self.list_for_tenant(tenant_id, filters = {}, options = {})
|
150
|
+
query_response = Warrant.query("select pricing-tier where tenant:#{tenant_id} is *", filters: filters, options: options)
|
151
|
+
pricing_tiers = query_response.results.map{ |result| PricingTier.new(result.object_id, result.meta) }
|
152
|
+
return ListResponse.new(pricing_tiers, query_response.prev_cursor, query_response.next_cursor)
|
139
153
|
end
|
140
154
|
|
141
155
|
# Assign a pricing tier to a tenant
|
142
156
|
#
|
143
157
|
# @param tenant_id [String] The tenant_id of the tenant you want to assign a pricing tier to.
|
144
158
|
# @param pricing_tier_id [String] The pricing_tier_id of the pricing tier you want to assign to a tenant.
|
159
|
+
# @param relation [String] The relation for this pricing tier to tenant association. The relation must be valid as per the +pricing tier+ object type definition.
|
145
160
|
#
|
146
161
|
# @return [Warrant] warrant assigning pricing tier to tenant
|
147
162
|
#
|
@@ -150,14 +165,15 @@ module Warrant
|
|
150
165
|
# @raise [Warrant::InvalidParameterError]
|
151
166
|
# @raise [Warrant::NotFoundError]
|
152
167
|
# @raise [Warrant::UnauthorizedError]
|
153
|
-
def self.assign_to_tenant(tenant_id, pricing_tier_id)
|
154
|
-
Warrant.create({ object_type: PricingTier::OBJECT_TYPE, object_id: pricing_tier_id },
|
168
|
+
def self.assign_to_tenant(tenant_id, pricing_tier_id, relation: "member", options: {})
|
169
|
+
Warrant.create({ object_type: PricingTier::OBJECT_TYPE, object_id: pricing_tier_id }, relation, { object_type: Tenant::OBJECT_TYPE, object_id: tenant_id }, nil, options)
|
155
170
|
end
|
156
171
|
|
157
172
|
# Remove a pricing tier from a tenant
|
158
173
|
#
|
159
174
|
# @param tenant_id [String] The tenant_id of the tenant you want to remove a pricing tier from.
|
160
175
|
# @param pricing_tier_id [String] The pricing_tier_id of the pricing tier you want to remove from a tenant.
|
176
|
+
# @param relation [String] The relation for this pricing tier to tenant association. The relation must be valid as per the +pricing tier+ object type definition.
|
161
177
|
#
|
162
178
|
# @return [nil] if remove was successful
|
163
179
|
#
|
@@ -166,37 +182,39 @@ module Warrant
|
|
166
182
|
# @raise [Warrant::NotFoundError]
|
167
183
|
# @raise [Warrant::UnauthorizedError]
|
168
184
|
# @raise [Warrant::WarrantError]
|
169
|
-
def self.remove_from_tenant(tenant_id, pricing_tier_id)
|
170
|
-
Warrant.delete({ object_type: PricingTier::OBJECT_TYPE, object_id: pricing_tier_id },
|
185
|
+
def self.remove_from_tenant(tenant_id, pricing_tier_id, relation: "member", options: {})
|
186
|
+
Warrant.delete({ object_type: PricingTier::OBJECT_TYPE, object_id: pricing_tier_id }, relation, { object_type: Tenant::OBJECT_TYPE, object_id: tenant_id }, nil, options)
|
171
187
|
end
|
172
188
|
|
173
189
|
# List pricing tiers for user
|
174
190
|
#
|
175
191
|
# @param user_id [String] The user_id of the user to list pricing tiers for.
|
176
|
-
# @
|
177
|
-
# @
|
192
|
+
# @param [Hash] filters Filters to apply to result set
|
193
|
+
# @param [Hash] options Options to apply on a per-request basis
|
194
|
+
# @option filters [String] :object_type Only return objects with an `objectType` matching this value
|
195
|
+
# @option filters [Integer] :limit A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)
|
196
|
+
# @option filters [String] :prev_cursor A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)
|
197
|
+
# @option filters [String] :next_cursor A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)
|
198
|
+
# @option filters [String] :sort_by The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are +object_type+, +object_id+, and +created_at+ (optional)
|
199
|
+
# @option filters [String] :sort_order The order in which to sort the result by. Valid values are +ASC+ and +DESC+. Defaults to +ASC+. (optional)
|
200
|
+
# @option options [String] :warrant_token A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)
|
178
201
|
#
|
179
202
|
# @return [Array<PricingTier>] assigned pricing tiers for the user
|
180
203
|
#
|
181
204
|
# @raise [Warrant::InternalError]
|
182
205
|
# @raise [Warrant::InvalidParameterError]
|
183
206
|
# @raise [Warrant::UnauthorizedError]
|
184
|
-
def self.list_for_user(user_id, filters = {})
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
when Net::HTTPSuccess
|
189
|
-
pricing_tiers = JSON.parse(res.body)
|
190
|
-
pricing_tiers.map{ |pricing_tier| PricingTier.new(pricing_tier['pricingTierId']) }
|
191
|
-
else
|
192
|
-
APIOperations.raise_error(res)
|
193
|
-
end
|
207
|
+
def self.list_for_user(user_id, filters = {}, options = {})
|
208
|
+
query_response = Warrant.query("select pricing-tier where user:#{user_id} is *", filters: filters, options: options)
|
209
|
+
pricing_tiers = query_response.results.map{ |result| PricingTier.new(result.object_id, result.meta) }
|
210
|
+
return ListResponse.new(pricing_tiers, query_response.prev_cursor, query_response.next_cursor)
|
194
211
|
end
|
195
212
|
|
196
213
|
# Assign a pricing tier to a user
|
197
214
|
#
|
198
215
|
# @param user_id [String] The user_id of the user you want to assign a pricing tier to.
|
199
216
|
# @param pricing_tier_id [String] The pricing_tier_id of the pricing tier you want to assign to a user.
|
217
|
+
# @param relation [String] The relation for this pricing tier to user association. The relation must be valid as per the +pricing tier+ object type definition.
|
200
218
|
#
|
201
219
|
# @return [Warrant] warrant assigning pricing tier to user
|
202
220
|
#
|
@@ -205,14 +223,15 @@ module Warrant
|
|
205
223
|
# @raise [Warrant::InvalidParameterError]
|
206
224
|
# @raise [Warrant::NotFoundError]
|
207
225
|
# @raise [Warrant::UnauthorizedError]
|
208
|
-
def self.assign_to_user(user_id, pricing_tier_id)
|
209
|
-
Warrant.create({ object_type: PricingTier::OBJECT_TYPE, object_id: pricing_tier_id },
|
226
|
+
def self.assign_to_user(user_id, pricing_tier_id, relation: "member", options: {})
|
227
|
+
Warrant.create({ object_type: PricingTier::OBJECT_TYPE, object_id: pricing_tier_id }, relation, { object_type: User::OBJECT_TYPE, object_id: user_id }, nil, options)
|
210
228
|
end
|
211
229
|
|
212
230
|
# Remove a pricing tier from a user
|
213
231
|
#
|
214
232
|
# @param user_id [String] The user_id of the user you want to remove a pricing tier from.
|
215
233
|
# @param pricing_tier_id [String] The pricing_tier_id of the pricing tier you want to remove from a user.
|
234
|
+
# @param relation [String] The relation for this pricing tier to user association. The relation must be valid as per the +pricing tier+ object type definition.
|
216
235
|
#
|
217
236
|
# @return [nil] if remove was successful
|
218
237
|
#
|
@@ -221,27 +240,35 @@ module Warrant
|
|
221
240
|
# @raise [Warrant::NotFoundError]
|
222
241
|
# @raise [Warrant::UnauthorizedError]
|
223
242
|
# @raise [Warrant::WarrantError]
|
224
|
-
def self.remove_from_user(user_id, pricing_tier_id)
|
225
|
-
Warrant.delete({ object_type: PricingTier::OBJECT_TYPE, object_id: pricing_tier_id },
|
243
|
+
def self.remove_from_user(user_id, pricing_tier_id, relation: "member", options: {})
|
244
|
+
Warrant.delete({ object_type: PricingTier::OBJECT_TYPE, object_id: pricing_tier_id }, relation, { object_type: User::OBJECT_TYPE, object_id: user_id }, nil, options)
|
226
245
|
end
|
227
246
|
|
228
247
|
# List features for a pricing tier
|
229
248
|
#
|
230
|
-
# @
|
231
|
-
# @
|
249
|
+
# @param [Hash] filters Filters to apply to result set
|
250
|
+
# @param [Hash] options Options to apply on a per-request basis
|
251
|
+
# @option filters [String] :object_type Only return objects with an `objectType` matching this value
|
252
|
+
# @option filters [Integer] :limit A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)
|
253
|
+
# @option filters [String] :prev_cursor A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)
|
254
|
+
# @option filters [String] :next_cursor A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)
|
255
|
+
# @option filters [String] :sort_by The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are +object_type+, +object_id+, and +created_at+ (optional)
|
256
|
+
# @option filters [String] :sort_order The order in which to sort the result by. Valid values are +ASC+ and +DESC+. Defaults to +ASC+. (optional)
|
257
|
+
# @option options [String] :warrant_token A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)
|
232
258
|
#
|
233
259
|
# @return [Array<Feature>] assigned features for the pricing tier
|
234
260
|
#
|
235
261
|
# @raise [Warrant::InternalError]
|
236
262
|
# @raise [Warrant::InvalidParameterError]
|
237
263
|
# @raise [Warrant::UnauthorizedError]
|
238
|
-
def list_features(filters = {})
|
239
|
-
return Feature.list_for_pricing_tier(pricing_tier_id, filters)
|
264
|
+
def list_features(filters = {}, options = {})
|
265
|
+
return Feature.list_for_pricing_tier(pricing_tier_id, filters, options)
|
240
266
|
end
|
241
267
|
|
242
268
|
# Assign a feature to a pricing tier
|
243
269
|
#
|
244
270
|
# @param feature_id [String] The feature_id of the feature you want to assign to the pricing tier.
|
271
|
+
# @param relation [String] The relation for this feature to pricing tier association. The relation must be valid as per the +feature+ object type definition.
|
245
272
|
#
|
246
273
|
# @return [Feature] assigned feature
|
247
274
|
#
|
@@ -250,13 +277,14 @@ module Warrant
|
|
250
277
|
# @raise [Warrant::InvalidParameterError]
|
251
278
|
# @raise [Warrant::NotFoundError]
|
252
279
|
# @raise [Warrant::UnauthorizedError]
|
253
|
-
def assign_feature(feature_id)
|
254
|
-
return Feature.assign_to_pricing_tier(pricing_tier_id, feature_id)
|
280
|
+
def assign_feature(feature_id, relation: "member", options: {})
|
281
|
+
return Feature.assign_to_pricing_tier(pricing_tier_id, feature_id, relation: relation, options: options)
|
255
282
|
end
|
256
283
|
|
257
284
|
# Remove a feature from a pricing tier
|
258
285
|
#
|
259
286
|
# @param feature_id [String] The feature_id of the feature you want to assign from the pricing tier.
|
287
|
+
# @param relation [String] The relation for this feature to pricing tier association. The relation must be valid as per the +feature+ object type definition.
|
260
288
|
#
|
261
289
|
# @return [nil] if remove was successful
|
262
290
|
#
|
@@ -265,13 +293,15 @@ module Warrant
|
|
265
293
|
# @raise [Warrant::NotFoundError]
|
266
294
|
# @raise [Warrant::UnauthorizedError]
|
267
295
|
# @raise [Warrant::WarrantError]
|
268
|
-
def remove_feature(feature_id)
|
269
|
-
return Feature.remove_from_pricing_tier(pricing_tier_id, feature_id)
|
296
|
+
def remove_feature(feature_id, relation: "member", options: {})
|
297
|
+
return Feature.remove_from_pricing_tier(pricing_tier_id, feature_id, relation: relation, options: options)
|
270
298
|
end
|
271
299
|
|
272
300
|
# Check whether a pricing tier has a given feature
|
273
301
|
#
|
274
302
|
# @param feature_id [String] The feature_id of the feature to check whether the pricing tier has access to.
|
303
|
+
# @param relation [String] The relation for this feature to pricing tier association. The relation must be valid as per the +feature+ object type definition.
|
304
|
+
# @param [Hash] options Options to apply on a per-request basis
|
275
305
|
# @option options [Hash] :context Object containing key-value pairs that specifies the context the warrant should be checked in. (optional)
|
276
306
|
# @option options [Boolean] :debug Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)
|
277
307
|
#
|
@@ -281,16 +311,17 @@ module Warrant
|
|
281
311
|
# @raise [Warrant::InvalidParameterError]
|
282
312
|
# @raise [Warrant::NotFoundError]
|
283
313
|
# @raise [Warrant::UnauthorizedError]
|
284
|
-
def has_feature?(feature_id,
|
285
|
-
return Warrant.has_feature?(
|
314
|
+
def has_feature?(feature_id, relation: "member", options: {})
|
315
|
+
return Warrant.has_feature?({
|
286
316
|
feature_id: feature_id,
|
317
|
+
relation: relation,
|
287
318
|
subject: {
|
288
319
|
object_type: "pricing-tier",
|
289
320
|
object_id: pricing_tier_id
|
290
321
|
},
|
291
|
-
context:
|
292
|
-
debug:
|
293
|
-
)
|
322
|
+
context: options[:context],
|
323
|
+
debug: options[:debug]
|
324
|
+
}, options)
|
294
325
|
end
|
295
326
|
|
296
327
|
def warrant_object_type
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Warrant
|
4
|
+
class QueryResult
|
5
|
+
attr_accessor :object_type, :object_id, :warrant, :is_implicit, :meta
|
6
|
+
|
7
|
+
# @!visibility private
|
8
|
+
def initialize(object_type, object_id, warrant, is_implicit, meta)
|
9
|
+
@object_type = object_type
|
10
|
+
@object_id = object_id
|
11
|
+
@warrant = warrant
|
12
|
+
@is_implicit = is_implicit
|
13
|
+
@meta = meta
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|