69 lines
2.4 KiB
Dart
69 lines
2.4 KiB
Dart
import 'dart:convert';
|
|
import 'package:http/http.dart';
|
|
import '../../../Model/Request/Authentication/Createuser/Createdeliveryaddress/Createdeliveryaddressrequest.dart';
|
|
import '../../../Model/Request/Createcustomer/Createcustomerrequest.dart';
|
|
import '../../../Model/Response/Createcustomer/Createcustomerresponse.dart';
|
|
import '../../../Model/Response/Createcustomer/Createdeliveryaddress/Createdeliveryaddressresponsel.dart';
|
|
|
|
class CreateCustomerProvider{
|
|
|
|
Future<CreateCustomerResponse?> createCustomer(CreateCustomers data,String urldata,) async {
|
|
CreateCustomerResponse? createCustomers;
|
|
try {
|
|
|
|
final url = Uri.parse('$urldata');
|
|
|
|
final response = await post(url,
|
|
body: json.encode(data),
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
// 'Authorization': '$token',
|
|
});
|
|
print('createCustomercontactno${data.firstname}');
|
|
print('createCustomercontactno${data.contactno}');
|
|
print('createCustomerapplocationid${data.applocationid}');
|
|
print('createCustomercontactno${data}');
|
|
|
|
print('responsebodyincreatecustomer${response.body}');
|
|
print('urldatacreatecustomer ${url}');
|
|
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
|
|
|
createCustomers = CreateCustomerResponse.fromJson(parsedJson);
|
|
|
|
} catch (e) {
|
|
print(e.toString());
|
|
print("error");
|
|
}
|
|
return createCustomers;
|
|
}
|
|
|
|
Future<CreateDeliveryAddressResponse?> createDeliveryAddress(CreateDeliveryAddress data,String urldata,) async {
|
|
CreateDeliveryAddressResponse? createDeliveryAddress;
|
|
try {
|
|
|
|
final url = Uri.parse('$urldata');
|
|
|
|
final response = await post(url,
|
|
body: json.encode(data),
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
// 'Authorization': '$token',
|
|
});
|
|
print('customeridinproviderdada${data.customerid}');
|
|
print('responsebodyincreateDeliveryAddress ${response.body}');
|
|
print('urldatacreateDeliveryAddress ${url}');
|
|
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
|
|
|
createDeliveryAddress = CreateDeliveryAddressResponse.fromJson(parsedJson);
|
|
|
|
} catch (e) {
|
|
print(e.toString());
|
|
print("error");
|
|
}
|
|
return createDeliveryAddress;
|
|
}
|
|
|
|
|
|
} |