native channel setResponse(num: Int) {
	out restClients.{num}.response(prev: Str, setResponse(response)) = response
}

native channel changeState(num: Int) {
	in restClients.{num}.state(state: Int, changeState(newState: Int)) = newState
}


channel creatClient{
	out restClients(clients: List, create(url:Str, method:Str)) = append(clients, {
		"url": url,
		"method": method,
		"body": nil,
		"response": "",
		"header": nil,
		"state": 0	
	})
}

channel onResponse(num: Int) {
	in restClients.{num}.response(res: Str, changeRes(newRes)) = newRes
	out restClients.{num}.state(state: Int, changeRes(newRes)) = 0
}

channel setUrl(num: Int) {
	out restClients.{num}.url(curUrl: Str, setUrl(newUrl)) = newUrl
}

channel addBody(num: Int) {
	out restClients.{num}.body(body: Map, addBody(key: Str, value: Str)) = insert(body, key, value)
}

channel addHeader(num: Int) {
	out restClients.{num}.header(header: Map, addHeader(key: Str, value: Str)) = insert(header, key, value)
}

channel setState(num: Int) {
	out restClients.{num}.state(nowState: Int, setState(newState)) = newState
}
