Skip to content

Commit

Permalink
Merge pull request #14 from lakasir/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sheenazien8 authored Apr 27, 2024
2 parents 77929ab + 4749e3e commit d52061e
Show file tree
Hide file tree
Showing 64 changed files with 3,430 additions and 748 deletions.
5 changes: 4 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
plugins {
id "com.android.application"
// START: FlutterFire Configuration
id 'com.google.gms.google-services'
// END: FlutterFire Configuration
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
Expand Down Expand Up @@ -49,7 +52,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.lakaksir.lakasir"
applicationId "com.lakasir.lakasir"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
Expand Down
29 changes: 29 additions & 0 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "98840745074",
"project_id": "lakasir-pos",
"storage_bucket": "lakasir-pos.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:98840745074:android:16d26e821ce5c512dddeeb",
"android_client_info": {
"package_name": "com.lakasir.lakasir"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyCEeawbXxkbIRYGvnkalmYhn2zybp6mD-Y"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
19 changes: 18 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,21 @@
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
<queries>
<!-- If your app checks for SMS support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="sms" />
</intent>
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
</queries>
</manifest>
3 changes: 3 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ buildscript {
}

dependencies {
// START: FlutterFire Configuration
classpath 'com.google.gms:google-services:4.3.15'
// END: FlutterFire Configuration
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Expand Down
1 change: 1 addition & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"flutter":{"platforms":{"android":{"default":{"projectId":"lakasir-pos","appId":"1:98840745074:android:16d26e821ce5c512dddeeb","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"lakasir-pos","configurations":{"android":"1:98840745074:android:16d26e821ce5c512dddeeb"}}}}}}
30 changes: 30 additions & 0 deletions ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyAEkX_T1BspCmVuriKNGtigYUWe0kHIaqU</string>
<key>GCM_SENDER_ID</key>
<string>98840745074</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.example.lakasir</string>
<key>PROJECT_ID</key>
<string>lakasir-pos</string>
<key>STORAGE_BUCKET</key>
<string>lakasir-pos.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:98840745074:ios:d13c376d0b34997adddeeb</string>
</dict>
</plist>
22 changes: 22 additions & 0 deletions lib/api/api_service.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import 'package:lakasir/Exceptions/unauthenticated.dart';
import 'package:lakasir/Exceptions/validation.dart';
import 'package:lakasir/utils/auth.dart';
import 'package:lakasir/utils/utils.dart';

class ApiService<T> {
final String baseUrl;
Expand All @@ -20,6 +23,8 @@ class ApiService<T> {
},
);

logApi(response);

if (response.statusCode == 401) {
logout();
throw UnauthorizedException(jsonDecode(response.body)['message']);
Expand All @@ -33,6 +38,7 @@ class ApiService<T> {
}

Future<T> postData(String endpoint, Object? request) async {
debug(request);
final token = await getToken();
final response = await http.post(
Uri.parse('$baseUrl/$endpoint'),
Expand All @@ -44,6 +50,8 @@ class ApiService<T> {
body: jsonEncode(request),
);

logApi(response);

if (response.statusCode == 401) {
logout();
throw UnauthorizedException(jsonDecode(response.body)['message']);
Expand All @@ -63,6 +71,7 @@ class ApiService<T> {
}

Future<T> putData(String endpoint, Object? request) async {
debug(request);
final token = await getToken();
final response = await http.put(
Uri.parse('$baseUrl/$endpoint'),
Expand All @@ -74,6 +83,8 @@ class ApiService<T> {
body: jsonEncode(request),
);

logApi(response);

if (response.statusCode == 401) {
logout();
throw UnauthorizedException(jsonDecode(response.body)['message']);
Expand Down Expand Up @@ -103,6 +114,8 @@ class ApiService<T> {
},
);

logApi(response);

if (response.statusCode == 401) {
logout();
throw UnauthorizedException(jsonDecode(response.body)['message']);
Expand Down Expand Up @@ -132,6 +145,7 @@ class ApiService<T> {
},
body: jsonEncode(request),
);
logApi(response);

if (response.statusCode == 401) {
logout();
Expand All @@ -149,3 +163,11 @@ class ApiService<T> {
}
}
}

void logApi(Response response) {
debug({
"url": response.request?.url,
"body": response.body,
"status": response.statusCode,
});
}
3 changes: 3 additions & 0 deletions lib/api/requests/about_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ class AboutRequest {
final String? shopName;
final String? shopLocation;
final String? businessType;
final String? otherBusinessType;
final String? photoUrl;
final String? ownerName;

AboutRequest({
this.shopName,
this.shopLocation,
this.businessType,
this.otherBusinessType,
this.photoUrl,
this.ownerName,
});
Expand All @@ -18,6 +20,7 @@ class AboutRequest {
'shop_name': shopName,
'shop_location': shopLocation,
'business_type': businessType,
'other_business_type': otherBusinessType,
'photo_url': photoUrl ?? '',
'owner_name': ownerName,
};
Expand Down
3 changes: 3 additions & 0 deletions lib/api/requests/payment_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ class PaymentRequest {
int? memberId;
double? tax;
List<PaymentRequestItem>? products;
String? note;

PaymentRequest({
this.payedMoney,
this.friendPrice,
this.products,
this.memberId,
this.tax,
this.note,
});

Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['payed_money'] = payedMoney;
data['friend_price'] = friendPrice;
data['note'] = note;
if (memberId != null) data['member_id'] = memberId;
if (tax != null) data['tax'] = tax;
if (products != null) {
Expand Down
4 changes: 2 additions & 2 deletions lib/api/requests/product_stock_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class ProductStockRequest {
final int stock;
final String? type;
final String? date;
final String? initialPrice;
final String? sellingPrice;
final double? initialPrice;
final double? sellingPrice;

ProductStockRequest({
required this.stock,
Expand Down
19 changes: 19 additions & 0 deletions lib/api/responses/abouts/about_error_response.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class AboutErrorResponse {
final String? businessType;
final String? otherBusinesType;

AboutErrorResponse({
this.businessType,
this.otherBusinesType,
});

factory AboutErrorResponse.fromJson(Map<String, dynamic> json) {
return AboutErrorResponse(
businessType:
json['business_type'] == null ? '' : json['business_type'][0],
otherBusinesType: json['other_business_type'] == null
? ''
: json['other_business_type'][0],
);
}
}
3 changes: 3 additions & 0 deletions lib/api/responses/abouts/about_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ class AboutResponse {
String? location;
String? currency;
String? photo;
String? otherBusinessType;

AboutResponse({
this.shopeName,
this.businessType,
this.otherBusinessType,
this.ownerName,
this.location,
this.currency,
Expand All @@ -19,6 +21,7 @@ class AboutResponse {
return AboutResponse(
shopeName: json['shop_name'],
businessType: json['business_type'],
otherBusinessType: json['other_business_type'],
ownerName: json['owner_name'],
location: json['shop_location'],
currency: json['currency'],
Expand Down
12 changes: 9 additions & 3 deletions lib/api/responses/domain/register_error_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class RegisterErrorResponse {
String emailOrPhone;
String password;
String? businessType;
String? otherBusinessType;

RegisterErrorResponse({
required this.shopName,
Expand All @@ -13,17 +14,22 @@ class RegisterErrorResponse {
required this.emailOrPhone,
required this.password,
required this.businessType,
required this.otherBusinessType,
});

factory RegisterErrorResponse.fromJson(Map<String, dynamic> json) {
return RegisterErrorResponse(
shopName: json['shop_name'] == null ? '' : json['shop_name'][0],
fullName: json['full_name'] == null ? '' : json['full_name'][0],
domainName: json['domain_name'] == null ? '' : json['domain_name'][0],
emailOrPhone: json['email_or_phone'] == null ? '' : json['email_or_phone'][0],
emailOrPhone:
json['email_or_phone'] == null ? '' : json['email_or_phone'][0],
password: json['password'] == null ? '' : json['password'][0],
businessType: json['business_type'] == null ? '' : json['business_type'][0],
businessType:
json['business_type'] == null ? '' : json['business_type'][0],
otherBusinessType: json['other_business_type'] == null
? ''
: json['other_business_type'][0],
);
}
}

4 changes: 3 additions & 1 deletion lib/api/responses/setting_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Setting {
bool? hideInitialPrice;
bool? hideInitialPriceUsingPin;
double? defaultTax;
int? minimumStock;

Setting({
this.currency,
Expand All @@ -29,16 +30,17 @@ class Setting {
this.hideInitialPrice = false,
this.hideInitialPriceUsingPin = false,
this.defaultTax = 0,
this.minimumStock,
});

factory Setting.fromJson(Map<String, dynamic> json) {
return Setting(
currency: json["currency"],
locale: json["locale"],
sellingMethod: json["selling_method"],
cashDrawerEnabled: json["cash_drawer_enabled"],
hideInitialPrice: json["secure_initial_price_enabled"],
hideInitialPriceUsingPin: json["secure_initial_price_using_pin"],
minimumStock: int.parse(json["minimum_stock_nofication"].toString()),
defaultTax:
json["default_tax"] == null ? 0 : json["default_tax"].toDouble(),
);
Expand Down
3 changes: 3 additions & 0 deletions lib/api/responses/transactions/history_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TransactionHistoryResponse {
String? createdAt;
String? updatedAt;
int? customerNumber;
String? note;

TransactionHistoryResponse({
required this.id,
Expand All @@ -44,6 +45,7 @@ class TransactionHistoryResponse {
this.createdAt,
this.updatedAt,
this.customerNumber,
this.note,
});

factory TransactionHistoryResponse.fromJson(Map<String, dynamic> json) {
Expand Down Expand Up @@ -77,6 +79,7 @@ class TransactionHistoryResponse {
createdAt: json['created_at'],
updatedAt: json['updated_at'],
customerNumber: json['customer_number'],
note: json['note'],
);
}
}
Loading

0 comments on commit d52061e

Please sign in to comment.