Subversion Repositories SmartDukaan

Rev

Rev 27451 | Rev 27453 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27451 Rev 27452
Line 1082... Line 1082...
1082
		// throw new Exception();
1082
		// throw new Exception();
1083
	}
1083
	}
1084
 
1084
 
1085
	public void createGeofence() throws IOException, ProfitMandiBusinessException {
1085
	public void createGeofence() throws IOException, ProfitMandiBusinessException {
1086
 
1086
 
1087
		List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
1087
		// List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
1088
		for (FofoStore fofoStore : fofoStores) {
1088
		// for (FofoStore fofoStore : fofoStores) {
1089
			if (fofoStore.getLatitude() != null && fofoStore.getLongitude() != null) {
1089
		// if (fofoStore.getLatitude() != null && fofoStore.getLongitude() != null) {
1090
				CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoStore.getId());
1090
		CustomRetailer customRetailer = retailerService.getFofoRetailer(157112773);
1091
				OkHttpClient client = new OkHttpClient();
1091
		OkHttpClient client = new OkHttpClient();
1092
				okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");
1092
		okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");
1093
				JSONObject geofe = new JSONObject();
1093
		JSONObject geofe = new JSONObject();
1094
				JSONArray geofences = new JSONArray();
1094
		JSONArray geofences = new JSONArray();
1095
				JSONObject geometry = new JSONObject();
1095
		JSONObject geometry = new JSONObject();
1096
				JSONObject geo = new JSONObject();
1096
		JSONObject geo = new JSONObject();
1097
				JSONArray coordinates = new JSONArray();
1097
		JSONArray coordinates = new JSONArray();
1098
				ArrayList<String> crds = new ArrayList<>();
1098
		ArrayList<Double> crds = new ArrayList<>();
1099
				crds.add(fofoStore.getLongitude());
1099
		crds.add(28.428435);
1100
				crds.add(fofoStore.getLatitude());
1100
		crds.add(77.3220698);
1101
 
1101
 
1102
				coordinates.put(fofoStore.getLongitude());
1102
		// coordinates.put(fofoStore.getLongitude());
1103
				coordinates.put(fofoStore.getLatitude());
1103
		// coordinates.put(fofoStore.getLatitude());
1104
				geo.put("type", "Point");
1104
		geo.put("type", "Point");
1105
				geo.put("coordinates", crds);
1105
		geo.put("coordinates", crds);
1106
				geometry.put("geometry", geo);
1106
		geometry.put("geometry", geo);
1107
				JSONObject metadata = new JSONObject();
1107
		JSONObject metadata = new JSONObject();
1108
				metadata.put("name", customRetailer.getBusinessName());
1108
		metadata.put("name", customRetailer.getBusinessName());
1109
				metadata.put("city", customRetailer.getAddress().getCity());
1109
		metadata.put("city", customRetailer.getAddress().getCity());
1110
				geometry.put("metadata", metadata);
1110
		geometry.put("metadata", metadata);
1111
				geometry.put("radius", 500);
1111
		geometry.put("radius", 500);
1112
 
1112
 
1113
				geofences.put(geometry);
1113
		geofences.put(geometry);
1114
				geofe.put("geofences", geofences);
1114
		geofe.put("geofences", geofences);
1115
				okhttp3.RequestBody body = okhttp3.RequestBody.create(mediaType, geofe.toString());
1115
		okhttp3.RequestBody body = okhttp3.RequestBody.create(mediaType, geofe.toString());
1116
				String authString = "Basic "
1116
		String authString = "Basic "
1117
						+ Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
1117
				+ Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
1118
 
1118
 
1119
				Request request1 = new Request.Builder().url("https://v3.api.hypertrack.com/geofences").post(body)
1119
		Request request1 = new Request.Builder().url("https://v3.api.hypertrack.com/geofences").post(body)
1120
						.addHeader("Authorization", authString).build();
1120
				.addHeader("Authorization", authString).build();
1121
 
1121
 
1122
				Response response = client.newCall(request1).execute();
1122
		Response response = client.newCall(request1).execute();
1123
 
1123
 
1124
				LOGGER.info("response" + response.body().string());
1124
		LOGGER.info("response" + response.body().string());
1125
			}
1125
		// }
1126
		}
1126
		// }
1127
 
1127
 
-
 
1128
		//
1128
	}
1129
	}
1129
 
1130
 
1130
	public void getAllGeofences() throws IOException, ProfitMandiBusinessException {
1131
	public void getAllGeofences() throws IOException, ProfitMandiBusinessException {
1131
 
1132
 
1132
		OkHttpClient client = new OkHttpClient();
1133
		OkHttpClient client = new OkHttpClient();