Skip to content

Commit

Permalink
feat: add get all coupon api
Browse files Browse the repository at this point in the history
  • Loading branch information
NanoNish committed Aug 28, 2023
1 parent b56f835 commit ce9bc3f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/data/constants/api_endpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ApiEndpoints {

static const String coupon = '/api/coupon';
static const String couponWithId = '/api/coupon/{couponId}';
static const String allCoupons = '/api/coupon/all';

static const String submittedFeedback = '/api/feedback/all/';
static const String responseOfFeedback = '/api/feedback/response/list/';
Expand Down
6 changes: 6 additions & 0 deletions lib/data/services/remote/api_service.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:appetizer/data/constants/api_endpoints.dart';
import 'package:appetizer/domain/models/appetizer_version.dart';
import 'package:appetizer/domain/models/coupon/coupon.dart';
import 'package:appetizer/domain/models/feedback/appetizer_feedback.dart';
import 'package:appetizer/domain/models/feedback/feedback_response.dart';
import 'package:appetizer/domain/models/leaves/paginated_leaves.dart';
Expand Down Expand Up @@ -40,6 +41,11 @@ abstract class ApiService {
@Body() Map<String, dynamic> map,
);

@GET(ApiEndpoints.allCoupons)
Future<List<Coupon>> getAllCoupon(
@Body() Map<String, dynamic> map,
);

// Feedback API

@GET(ApiEndpoints.submittedFeedback)
Expand Down
11 changes: 11 additions & 0 deletions lib/domain/repositories/coupon_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:appetizer/data/services/remote/api_service.dart';
import 'package:appetizer/domain/models/coupon/coupon.dart';
import 'package:appetizer/domain/models/failure_model.dart';
import 'package:appetizer/domain/models/menu/week_menu.dart';
import 'package:appetizer/domain/models/user/user.dart';
import 'package:flutter/foundation.dart';

class CouponRepository {
Expand Down Expand Up @@ -34,4 +35,14 @@ class CouponRepository {
throw Failure(AppConstants.GENERIC_FAILURE);
}
}

Future<List<Coupon>> getAllCoupon(User user) async {
Map<String, dynamic> map = {};
try {
return await _apiService.getAllCoupon(map);
} catch (e) {
debugPrint(e.toString());
throw Failure(AppConstants.GENERIC_FAILURE);
}
}
}

0 comments on commit ce9bc3f

Please sign in to comment.