package org.example.tampoposerverdtram.resources;

import java.util.*;

public class Pairs {
	private Map<String, Pair> value = new HashMap<>();
	private Client client = ClientBuilder.newClient();
	public Map<String, Pair> getValue() {
		return new HashMap<>(this.value);
	}
	public Pair getPair(String pid) {
		return this.value.get(pid);
	}
	public void updateFromDeletedFriendPair(Map<String, Object> deletedFriendPair) {
		Map<String, Pair> temp_if39;
		if (this.value.containsKey(deletedFriendPair.get("pairId"))) {
			this.value.remove(deletedFriendPair.get("pairId"));
			temp_if39 = this.value;
		} else {
			temp_if39 = this.value;
		}
		this.value = temp_if39;
	}
	public void postFriend(String user1Id, Map<String, Map<String, Object>> users, String pairId, String user0Id) {
		String pairId = client.target("http://localhost:8080").path("/pairId").request().get(String.class);
		Map<String, Map<String, Object>> users_json = client.target("http://localhost:8080").path("/users").request().get(HashMap.class);
		Map<String, Map<String, Object>> users = new HashMap<>();
		users = users_json;
		Map<String, Pair> temp_if42;
		if (user0Id.equals(user1Id)) {
			temp_if42 = this.value;
		} else {
			Map<String, Pair> temp_if41;
		if ((users.containsKey(user0Id)&&users.containsKey(user1Id))) {
			this.value.put(pairId,new Pair(friends));
			temp_if41 = this.value;
		} else {
			temp_if41 = this.value;
		}
			temp_if42 = temp_if41;
		}
		this.value = temp_if42;
	}
}