-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add the coupon button for chicken days. (#215)
* feat: Add the coupon button for chicken days. * feat: Reduce the size of the button * feat: integrate coupon flow with backend Signed-off-by: Aman <[email protected]> * chor: fix lint issues Signed-off-by: Aman <[email protected]> --------- Signed-off-by: Aman <[email protected]> Co-authored-by: Aman <[email protected]>
- Loading branch information
1 parent
33a20a3
commit a709737
Showing
22 changed files
with
602 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
# This file should be version controlled. | ||
|
||
version: | ||
revision: 20e59316b8b8474554b38493b8ca888794b0234a | ||
revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
channel: stable | ||
|
||
project_type: app | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
- platform: android | ||
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
- platform: ios | ||
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
- platform: linux | ||
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
- platform: macos | ||
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
- platform: web | ||
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
- platform: windows | ||
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,20 @@ | ||
include: package:pedantic/analysis_options.yaml | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
|
||
linter: | ||
rules: | ||
constant_identifier_names: false | ||
prefer_const_constructors: false | ||
avoid_print: false | ||
sized_box_for_whitespace: false | ||
no_leading_underscores_for_local_identifiers: false | ||
library_private_types_in_public_api: false | ||
use_key_in_widget_constructors: false | ||
unnecessary_string_interpolations: false | ||
avoid_function_literals_in_foreach_calls: false | ||
avoid_unnecessary_containers: false | ||
prefer_const_constructors_in_immutables: false | ||
prefer_interpolation_to_compose_strings: false | ||
prefer_typing_uninitialized_variables: false | ||
depend_on_referenced_packages: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'package:appetizer/config/environment_config.dart'; | ||
import 'package:appetizer/constants.dart'; | ||
import 'package:appetizer/models/failure_model.dart'; | ||
import 'package:appetizer/models/menu/week_menu.dart'; | ||
import 'package:appetizer/utils/api_utils.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
class CouponApi { | ||
var headers = {'Content-Type': 'application/json'}; | ||
http.Client client = http.Client(); | ||
|
||
Future<CouponStatus> applyForCoupon(int mealId) async { | ||
var endpoint = '/api/coupon/'; | ||
var uri = EnvironmentConfig.BASE_URL + endpoint; | ||
|
||
try { | ||
await ApiUtils.addTokenToHeaders(headers); | ||
var jsonResponse = | ||
await ApiUtils.post(uri, headers: headers, body: {'meal': mealId}); | ||
|
||
return CouponStatus( | ||
status: CouponStatusEnum.A, | ||
id: jsonResponse['id'], | ||
); | ||
} on Exception catch (e) { | ||
print(e.toString()); | ||
throw Failure(Constants.GENERIC_FAILURE); | ||
} | ||
} | ||
|
||
Future<CouponStatus> cancelCoupon(int couponId) async { | ||
var endpoint = '/api/coupon/$couponId'; | ||
var uri = EnvironmentConfig.BASE_URL + endpoint; | ||
|
||
try { | ||
await ApiUtils.addTokenToHeaders(headers); | ||
await ApiUtils.delete(uri, headers: headers); | ||
|
||
return CouponStatus(status: CouponStatusEnum.N); | ||
} on Exception catch (e) { | ||
print(e.toString()); | ||
throw Failure(Constants.GENERIC_FAILURE); | ||
} | ||
} | ||
} |
Oops, something went wrong.