View Javadoc
1   package org.oxerr.viagogo.client.rescu.impl.webhook;
2   
3   import static jakarta.ws.rs.core.Response.Status.NOT_FOUND;
4   
5   import java.io.IOException;
6   
7   import org.oxerr.viagogo.client.rescu.resource.ViagogoException;
8   import org.oxerr.viagogo.client.rescu.resource.webhook.WebhookResource;
9   import org.oxerr.viagogo.client.webhook.WebhookService;
10  import org.oxerr.viagogo.model.response.webhook.Webhook;
11  import org.oxerr.viagogo.model.response.webhook.Webhooks;
12  
13  import si.mazi.rescu.HttpStatusIOException;
14  
15  public class WebhookServiceImpl implements WebhookService {
16  
17  	private final WebhookResource webhookResource;
18  
19  	public WebhookServiceImpl(WebhookResource webhookResource) {
20  		this.webhookResource = webhookResource;
21  	}
22  
23  	@Override
24  	public Webhooks getWebhooks(Integer page, Integer pageSize, String sort) throws IOException {
25  		return this.webhookResource.getWebhooks(page, pageSize, sort);
26  	}
27  
28  	@Override
29  	public Webhook createWebhook(Webhook webhook) throws IOException {
30  		return this.webhookResource.createWebhook(webhook);
31  	}
32  
33  	@Override
34  	public Webhook getWebhook(Integer id) throws IOException {
35  		return this.webhookResource.getWebhook(id);
36  	}
37  
38  	@Override
39  	public Webhook updateWebhook(Integer id, Webhook webhook) throws IOException {
40  		return this.webhookResource.updateWebhook(id, webhook);
41  	}
42  
43  	@Override
44  	public void deleteWebhook(Integer id) throws IOException {
45  		try {
46  			this.webhookResource.deleteWebhook(id);
47  		} catch (ViagogoException | HttpStatusIOException e) {
48  			if (e.getHttpStatusCode() != NOT_FOUND.getStatusCode()) {
49  				throw e;
50  			}
51  		}
52  	}
53  
54  	@Override
55  	public void ping(Integer id) throws IOException {
56  		this.webhookResource.ping(id);
57  	}
58  
59  }