package de.fau.amos.virtualledger.server.banking.adorsys.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Class for providing URLs for adorsys api. Uses the BankingApiConfiguration
 * for building the URLs
 */
@Component

public class BankingApiUrlProvider {

    private BankingApiConfiguration configuration;

    @Autowired
    public BankingApiUrlProvider(BankingApiConfiguration configuration) {
        this.configuration = configuration;
    }

    // protected empty constructor required for server to init it
    protected BankingApiUrlProvider() {
        this(null);
    }

    public String getBankAccessEndpointUrl() {
        return configuration.getBankingApiUrlAbsolute() + configuration.getBankAccessApiUrlRelative();
    }

    public String getBankAccountEndpointUrl(String bankAccessId) {
        String url = configuration.getBankingApiUrlAbsolute() + configuration.getBankAccountApiUrlRelative();
        url = url.replaceAll("\\{accessId\\}", bankAccessId);
        return url;
    }

    public String getBankAccountSyncEndpointUrl(String bankAccessId, String bankAccountId) {
        String url = configuration.getBankingApiUrlAbsolute() + configuration.getBankAccountSyncApiUrlRelative();
        url = url.replaceAll("\\{accessId\\}", bankAccessId);
        url = url.replaceAll("\\{accountId\\}", bankAccountId);
        return url;
    }
}

@@ -342,16 +342,22 @@
 private 
+final 
 BankingA
@@ -436,16 +436,22 @@
 rovider(
+final 
 BankingA
@@ -860,32 +860,38 @@
 ountEndpointUrl(
+final 
 String bankAcces
@@ -1040,34 +1040,32 @@
 All(%22%5C%5C%7BaccessId
-%5C%5C
 %7D%22, bankAccessId
@@ -1142,16 +1142,22 @@
 ointUrl(
+final 
 String b
@@ -1168,16 +1168,22 @@
 ccessId,
+ final
  String 
@@ -1354,18 +1354,16 @@
 accessId
-%5C%5C
 %7D%22, bank
@@ -1415,18 +1415,16 @@
 ccountId
-%5C%5C
 %7D%22, bank

Clean up BankingApiUrlProvider.java