import 'dart:convert'; import 'package:workouttest_util/model/customer_training_plan.dart'; import 'package:workouttest_util/model/customer_training_plan_exercise.dart'; import 'package:workouttest_util/service/api.dart'; import 'package:workouttest_util/util/logging.dart'; class TrainingPlanApi with Logging { final APIClient _client = APIClient(); Future saveCustomerTrainingPlan(CustomerTrainingPlan plan) async { String body = JsonEncoder().convert(plan.toJson()); log(" ===== saving customer training plan:" + body); final String response = await _client.post("customer_training_plan/", body); final CustomerTrainingPlan saved = CustomerTrainingPlan.fromJson(jsonDecode(response)); return saved; } Future saveCustomerTrainingPlanExercise(CustomerTrainingPlanExercise planExercise) async { String body = JsonEncoder().convert(planExercise.toJson()); log(" ===== saving customer training plan exercise:" + body); final String response = await _client.post("customer_training_plan_exercise/", body); final CustomerTrainingPlanExercise saved = CustomerTrainingPlanExercise.fromJson(jsonDecode(response)); return saved; } Future updateCustomerTrainingPlan(CustomerTrainingPlan plan, int customerTrainingPlanId) async { String body = JsonEncoder().convert(plan.toJson()); log(" ===== update customer training plan:" + body); final String response = await _client.post("customer_training_plan/update/$customerTrainingPlanId", body); final CustomerTrainingPlan saved = CustomerTrainingPlan.fromJson(jsonDecode(response)); return saved; } }