1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package de.kaiserpfalzedv.services.sms77.client;
19
20 import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
21
22 import java.util.Set;
23
24 import org.springframework.cloud.openfeign.FeignClient;
25 import org.springframework.web.bind.annotation.RequestMapping;
26 import org.springframework.web.bind.annotation.RequestMethod;
27 import org.springframework.web.bind.annotation.RequestParam;
28
29 import de.kaiserpfalzedv.services.sms77.model.Balance;
30 import de.kaiserpfalzedv.services.sms77.model.NumberFormatCheckResult;
31 import de.kaiserpfalzedv.services.sms77.model.Sms;
32 import de.kaiserpfalzedv.services.sms77.model.SmsResult;
33 import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
34 import io.github.resilience4j.ratelimiter.annotation.RateLimiter;
35 import io.github.resilience4j.retry.annotation.Retry;
36 import io.micrometer.core.annotation.Counted;
37 import io.micrometer.core.annotation.Timed;
38 import jakarta.validation.constraints.NotBlank;
39 import jakarta.validation.constraints.NotNull;
40 import jakarta.validation.constraints.Size;
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 @FeignClient(name = "sms77", configuration = Sms77ClientConfig.class, path = "/api")
89 @SuppressWarnings("JavadocLinkAsPlainText")
90 @RateLimiter(name = "sms77client")
91 public interface Sms77Client {
92
93
94
95
96
97
98 @RequestMapping(method = RequestMethod.POST, value = "/sms", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
99 @Timed("sms77.send-sms-json.time")
100 @Counted("sms77.send-sms-json.count")
101 @Retry(name = "sendSMS")
102 @CircuitBreaker(name = "sendSMS")
103
104
105 SmsResult sendSMS(@NotNull final Sms sms);
106
107
108
109
110
111
112
113
114 @RequestMapping(method = RequestMethod.POST, value = "/sms", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
115 @Timed("sms77.send-sms-query.time")
116 @Counted("sms77.send-sms-query.count")
117 @Retry(name = "sendSMS")
118 @CircuitBreaker(name = "sendSMS")
119 SmsResult sendSMS(
120 @Size(min = 1, max = 10) @RequestParam("to") @NotNull final Set<String> number,
121
122 @Size(max = 1520) @RequestParam("text") @NotNull final String text);
123
124
125
126
127
128
129
130 @Timed("sms77.balance.time")
131 @Counted("sms77.balance.count")
132 @Retry(name = "balanceSMS")
133 @CircuitBreaker(name = "balanceSMS")
134 @RequestMapping(method = RequestMethod.GET, value = "/balance", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
135 Balance balance();
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159 @Timed("sms77.number-format-check.multi.time")
160 @Counted("sms77.number-format-check.multi.count")
161 @Retry(name = "lookupSMS")
162 @CircuitBreaker(name = "lookupSMS")
163 @RequestMapping(method = RequestMethod.GET, value = "/lookup", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
164 Set<NumberFormatCheckResult> checkMultipleNumberFormats(
165 @RequestParam("number") @NotBlank final String numbersWithComma);
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181 @Timed("sms77.number-format-check.multi.time")
182 @Counted("sms77.number-format-check.multi.count")
183 @Retry(name = "checkNumberFormatSMS")
184 @CircuitBreaker(name = "checkNumberFormatSMS")
185 @RequestMapping(method = RequestMethod.GET, value = "/lookup", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
186 NumberFormatCheckResult checkNumberFormat(@RequestParam("number") @NotBlank final String number);
187 }