getSingleProductById method
Gets a specifi product by its productId.
Implementation
Future<PrintifyGetShopSingleProductResponse> getSingleProductById({
required String baseUrl,
required String productId,
}) async {
Response? response;
try {
final dio = Dio(
BaseOptions(
contentType: 'application/json',
responseType: ResponseType.json,
baseUrl: 'https://$baseUrl/app',
),
);
response = await dio.get(
'/getProductById',
queryParameters: {
'productId': productId,
},
);
if (response.statusCode == 200) {
return PrintifyGetShopSingleProductResponse.fromJson(response.data);
} else {
throw Exception(
'Non 200 return code for getting single product with ID $productId. Response: ${response.statusCode}');
}
} catch (e) {
throw Exception(
'Exception for getting single product with ID $productId. Response: ${response?.statusCode}');
}
}