package com.juick.components.service; import com.juick.TokensList; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import javax.inject.Inject; import java.util.List; /** * Created by vitalyster on 15.12.2016. */ @Service public class NotificationsTokenService extends BaseRestService implements TokenService { @Inject public NotificationsTokenService(RestTemplate rest) { super(rest); } @Override public void deleteTokens(String type, List devices) { if (devices.size() > 0) { TokensList list = new TokensList(); list.setType(type); list.setTokens(devices); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON_UTF8); getRest().exchange("http://api.juick.com/notifications", HttpMethod.DELETE, new HttpEntity<>(list, headers), new ParameterizedTypeReference() { }); } } }