second commit
This commit is contained in:
69
lib/Data/Provider/Createcustomer/Createcustomerprovider.dart
Normal file
69
lib/Data/Provider/Createcustomer/Createcustomerprovider.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user