@@ -42,6 +42,19 @@ def executions(owner_type, owner_id, page, per_page, from, to)
4242 executions
4343 end
4444
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+
4558 def all
4659 data = connection . get ( '/subscriptions' ) . body
4760 subscriptions = data . fetch ( 'subscriptions' ) . map do |subscription_data |
@@ -210,11 +223,21 @@ def create_auto_refill(plan_id, is_enabled)
210223 handle_errors_and_respond ( response )
211224 end
212225
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+
213231 def get_auto_refill ( plan_id )
214232 response = connection . get ( "/auto_refill?plan_id=#{ plan_id } " )
215233 handle_errors_and_respond ( response ) { |r | Travis ::API ::V3 ::Models ::AutoRefill . new ( r ) }
216234 end
217235
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+
218241 private
219242
220243 def handle_subscription_response ( response )
0 commit comments