2
2
3
3
4
4
import com .sharetreats .chatbot .infra .config .RestTemplateConfig ;
5
+ import com .sharetreats .chatbot .module .controller .dto .retryDtos .RetryButton ;
6
+ import com .sharetreats .chatbot .module .controller .dto .retryDtos .RetryKeyboard ;
7
+ import com .sharetreats .chatbot .module .controller .dto .retryDtos .RetryMessage ;
8
+ import com .sharetreats .chatbot .module .controller .dto .welcomeDtos .WelcomeButton ;
9
+ import com .sharetreats .chatbot .module .controller .dto .welcomeDtos .WelcomeKeyboard ;
10
+ import com .sharetreats .chatbot .module .controller .dto .welcomeDtos .WelcomeMessage ;
5
11
import lombok .AllArgsConstructor ;
6
12
import lombok .Getter ;
7
13
import lombok .NoArgsConstructor ;
10
16
import org .springframework .beans .factory .annotation .Value ;
11
17
import org .springframework .http .*;
12
18
import org .springframework .stereotype .Component ;
19
+ import org .springframework .web .client .RestTemplate ;
20
+
21
+ import java .util .Collections ;
13
22
14
23
@ Slf4j
15
24
@ RequiredArgsConstructor
@@ -24,27 +33,21 @@ public class SendInvalidTokenMessage {
24
33
static final String VIBER_SEND_MESSAGE_URL = "https://chatapi.viber.com/pa/send_message" ;
25
34
26
35
public ResponseEntity <?> execute (String accountId ) {
27
- log .info ("send invalid message" );
28
- InvalidMessage invalidMessage = new InvalidMessage (accountId , "text" , "stchatbot3" , "Validity time has expired" );
36
+ RetryMessage message = new RetryMessage (accountId ,
37
+ 1 ,
38
+ "text" ,
39
+ "Your time has expired.\n " +
40
+ "If you want to get back into service, press the \" Retry\" ." ,
41
+ new RetryKeyboard ("keyboard" , false , "#FFFFFF" ,
42
+ Collections .singletonList (new RetryButton (6 , 1 , "#29A7D9" , "reply" , "retry" , "Retry" , "center" , "middle" , "large" ))));
43
+
29
44
30
45
HttpHeaders httpHeaders = new HttpHeaders ();
31
46
httpHeaders .setContentType (MediaType .APPLICATION_JSON );
32
47
httpHeaders .set ("X-Viber-Auth-Token" , token );
48
+ HttpEntity <RetryMessage > httpEntity = new HttpEntity <>(message , httpHeaders );
33
49
34
- HttpEntity <InvalidMessage > invalidMessageHttpEntity = new HttpEntity <>(invalidMessage , httpHeaders );
35
- restTemplateConfig .restTemplate ().exchange (VIBER_SEND_MESSAGE_URL , HttpMethod .POST , invalidMessageHttpEntity , String .class );
36
- sendWelcomeMessage .execute ();
37
- return ResponseEntity .ok ().build ();
50
+ return restTemplateConfig .restTemplate ().exchange (VIBER_SEND_MESSAGE_URL , HttpMethod .POST , httpEntity , String .class );
38
51
}
39
52
40
- @ Getter
41
- @ NoArgsConstructor
42
- @ AllArgsConstructor
43
- private class InvalidMessage {
44
-
45
- private String receiver ;
46
- private String type ;
47
- private String name ;
48
- private String text ;
49
- }
50
53
}
0 commit comments