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.eansearch.client;
19
20 import org.springframework.beans.factory.annotation.Value;
21 import org.springframework.context.annotation.Bean;
22
23 import feign.Logger;
24 import feign.RequestInterceptor;
25 import lombok.Setter;
26
27 /**
28 *
29 * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
30 * @version 1.0.0
31 * @since 2023-12-11
32 */
33 // No @Configuration - otherwise it would be the default for all feign clients
34 public class EanSearchClientConfig {
35 /** format for lookups */
36 private static final String FORMAT = "json";
37 /** lookup type */
38 private static final String OP = "barcode-lookup";
39
40 /** The API-Key for accessing the EAN-Search API */
41 @Value("${eansearch.token}")
42 @Setter
43 private String apiKey;
44
45 @Bean
46 public RequestInterceptor eanSearchDefaultParameters(@Value("${eansearch.token}") final String apiKey, @Value("${eansearch.language}") final String language) {
47 return requestTemplate -> requestTemplate
48 .query("format", FORMAT)
49 .query("op", OP)
50 .query("language", language)
51 .query("token", apiKey)
52 ;
53 }
54
55
56 @Bean
57 public Logger.Level logLevel() {
58 return Logger.Level.FULL;
59 }
60 }