View Javadoc
1   /*
2    * Copyright (c) 2023 Kaiserpfalz EDV-Service, Roland T. Lichti
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Lesser General Public
6    * License as published by the Free Software Foundation; either
7    * version 3 of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   * Lesser General Public License for more details.
13   *
14   * You should have received a copy of the GNU Lesser General Public License
15   * along with this program; if not, write to the Free Software Foundation,
16   * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17   */
18  package de.kaiserpfalzedv.services.sms77.client;
19  
20  import org.springframework.beans.factory.annotation.Value;
21  import org.springframework.context.annotation.Bean;
22  
23  import feign.RequestInterceptor;
24  import lombok.Setter;
25  
26  /**
27   *
28   * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
29   * @version 1.0.0
30   * @since 2023-12-11
31   */
32  // No @Configuration - otherwise it would be the default for all feign clients
33  public class Sms77ClientConfig {
34      /** Query param 'json' */
35      private static final String JSON = "1";
36  
37      /** format for lookups */
38      private static final String FORMAT = "format";
39  
40      /** The API-Key for accessing the Seven.io-API */
41      @Value("${sms77.token}")
42      @Setter
43      private String apiKey;
44  
45      @Bean
46      public RequestInterceptor sevenIoDefaultParameters(@Value("${sms77.token}") final String apiKey) {
47          return requestTemplate -> requestTemplate
48              .query("json", JSON)
49              .query("type", FORMAT)
50              .header("X-Api-Key", apiKey)
51              ;
52      }
53  }