@@ -42,6 +42,19 @@ def executions(owner_type, owner_id, page, per_page, from, to)
42
42
executions
43
43
end
44
44
45
+ def calculate_credits ( users , executions )
46
+ response = connection . post ( "/usage/credits_calculator" , users : users , executions : executions )
47
+ response . body . map do |calculator_data |
48
+ Travis ::API ::V3 ::Models ::CreditsResult . new ( calculator_data )
49
+ end
50
+ end
51
+
52
+ def credits_calculator_default_config
53
+ response = connection . get ( '/usage/credits_calculator/default_config' )
54
+
55
+ Travis ::API ::V3 ::Models ::CreditsCalculatorConfig . new ( response . body )
56
+ end
57
+
45
58
def all
46
59
data = connection . get ( '/subscriptions' ) . body
47
60
subscriptions = data . fetch ( 'subscriptions' ) . map do |subscription_data |
@@ -210,11 +223,21 @@ def create_auto_refill(plan_id, is_enabled)
210
223
handle_errors_and_respond ( response )
211
224
end
212
225
226
+ def update_auto_refill ( addon_id , threshold , amount )
227
+ response = connection . patch ( '/auto_refill' , { id : addon_id , threshold : threshold , amount : amount } )
228
+ handle_errors_and_respond ( response )
229
+ end
230
+
213
231
def get_auto_refill ( plan_id )
214
232
response = connection . get ( "/auto_refill?plan_id=#{ plan_id } " )
215
233
handle_errors_and_respond ( response ) { |r | Travis ::API ::V3 ::Models ::AutoRefill . new ( r ) }
216
234
end
217
235
236
+ def cancel_v2_subscription ( id , reason_data )
237
+ response = connection . post ( "/v2/subscriptions/#{ id } /cancel" , reason_data )
238
+ handle_subscription_response ( response )
239
+ end
240
+
218
241
private
219
242
220
243
def handle_subscription_response ( response )
0 commit comments