package kr.co.swh.lecture.opensource.project.colona;

import java.io.IOException;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import com.google.gson.Gson;

public class ColonaCall {
	public static void main(String[] args) {
		HttpClient client = HttpClients.createDefault();
		HttpGet request = new HttpGet("https://8oi9s0nnth.apigw.ntruss.com/corona19-masks/v1/stores/json?page=1&perPage=500");
		
		try {
			//	필요에 따라서는 헤더 추가
//			request.addHeader("Content-type", "application/json");
			
			//	요청
			HttpResponse response = client.execute(request);
			
			//	응답
			String result = EntityUtils.toString(response.getEntity());
			Gson gson = new Gson();
			ResponseStore stores = gson.fromJson(result, ResponseStore.class);
			
			List<Store> k = stores.getStoreInfos();
			for(Store y : k) {
				System.out.println("가게이름 : " + y.getName());
			}
			
			
		} catch (IOException e2) {
			// TODO Auto-generated catch block
			e2.printStackTrace();
		}
		
		
		
		
		
		
	}
}