@@ -229,6 +229,74 @@ module CGRateS
229229 end
230230 end
231231
232+ describe "#set_tp_rating_profile" do
233+ it "executes the request" do
234+ client = build_client
235+ set_tp_rating_plan ( client , tp_id : "cgrates_client_test" , id : "Test_Rating_Plan" )
236+
237+ stub_api_request ( result : "OK" )
238+ response = client . set_tp_rating_profile (
239+ tp_id : "cgrates_client_test" ,
240+ id : "Test_Rating_Profile" ,
241+ load_id : "TEST" ,
242+ category : "call" ,
243+ tenant : "cgrates.org" ,
244+ subject : "my-account" ,
245+ rating_plan_activations : [
246+ {
247+ activation_time : "2025-12-03T19:55:23+07:00" ,
248+ fallback_subjects : "foobar" ,
249+ rating_plan_id : "Test_Rating_Plan"
250+ }
251+ ]
252+ )
253+ expect ( response ) . to have_attributes ( result : "OK" )
254+ expect ( WebMock ) . to have_requested_api_method ( "APIerSv1.SetTPRatingProfile" )
255+
256+ stub_api_request (
257+ result : {
258+ "LoadId" => "TEST" ,
259+ "Tenant" => "cgrates.org" ,
260+ "Category" => "call" ,
261+ "Subject" => "my-account" ,
262+ "RatingPlanActivations" => [
263+ {
264+ "ActivationTime" => "2025-12-03T19:55:23+07:00" ,
265+ "FallbackSubjects" => "foobar" ,
266+ "RatingPlanId" => "Test_Rating_Plan"
267+ }
268+ ]
269+ }
270+ )
271+
272+ response = client . get_tp_rating_profile (
273+ tp_id : "cgrates_client_test" ,
274+ load_id : "TEST" ,
275+ tenant : "cgrates.org" ,
276+ category : "call" ,
277+ subject : "my-account"
278+ )
279+
280+ expect ( response ) . to have_attributes (
281+ result : hash_including (
282+ "LoadId" => "TEST" ,
283+ "Tenant" => "cgrates.org" ,
284+ "Category" => "call" ,
285+ "Subject" => "my-account" ,
286+ "RatingPlanActivations" => [
287+ hash_including (
288+ "ActivationTime" => "2025-12-03T19:55:23+07:00" ,
289+ "FallbackSubjects" => "foobar" ,
290+ "RatingPlanId" => "Test_Rating_Plan"
291+ )
292+ ]
293+ )
294+ )
295+ expect ( WebMock ) . to have_requested_api_method ( "APIerSv1.GetTPRatingProfile" )
296+ end
297+ end
298+
299+
232300 it "handles invalid http responses" do
233301 client = build_client
234302 stub_api_request ( status : 500 )
@@ -321,5 +389,22 @@ def set_tp_destination_rate(client, **params)
321389 **params
322390 )
323391 end
392+
393+ def set_tp_rating_plan ( client , **params )
394+ set_tp_destination_rate ( client , tp_id : "cgrates_client_test" , id : "Cambodia_Mobile_Destination_Rate" )
395+ stub_api_request ( result : "OK" )
396+ client . set_tp_rating_plan (
397+ tp_id : "cgrates_client_test" ,
398+ id : "Test_Rating_Plan" ,
399+ rating_plan_bindings : [
400+ {
401+ timing_id : "*any" ,
402+ weight : 10 ,
403+ destination_rates_id : "Cambodia_Mobile_Destination_Rate"
404+ }
405+ ] ,
406+ **params
407+ )
408+ end
324409 end
325410end
0 commit comments