<commit_before>package name.webdizz.fault.tolerance.gateway.endpoint;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.AllArgsConstructor;
import lombok.Data;
import name.webdizz.fault.tolerance.inventory.client.InventoryRequester;
import name.webdizz.fault.tolerance.inventory.client.command.TimeOutInventoryRequestCommand;
import name.webdizz.fault.tolerance.inventory.domain.Inventory;
import name.webdizz.fault.tolerance.inventory.domain.Product;
import name.webdizz.fault.tolerance.inventory.domain.Store;

@RestController
@RequestMapping("/api/products")
public class ProductDetailsEndpoint {

    private final InventoryRequester inventoryRequester;

    @Autowired
    public ProductDetailsEndpoint(final InventoryRequester inventoryRequester) {
        this.inventoryRequester = inventoryRequester;
    }

    @RequestMapping("/{store}/{product}")
    public ProductDetails inventory(@PathVariable("store") String storeId, @PathVariable("product") String productId) {
        Store store = new Store(storeId);
        Product product = new Product(productId);
        Inventory inventory = new TimeOutInventoryRequestCommand(inventoryRequester, store, product, 1000).execute();
        return new ProductDetails(inventory);
    }

    @Data
    @AllArgsConstructor
    class ProductDetails {
        private Inventory inventory;
    }
}<commit_msg>Switch to another command to call inventory service<commit_after>package name.webdizz.fault.tolerance.gateway.endpoint;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.AllArgsConstructor;
import lombok.Data;
import name.webdizz.fault.tolerance.inventory.client.InventoryRequester;
import name.webdizz.fault.tolerance.inventory.client.command.CircuitBreakerInventoryRequestCommand;
import name.webdizz.fault.tolerance.inventory.domain.Inventory;
import name.webdizz.fault.tolerance.inventory.domain.Product;
import name.webdizz.fault.tolerance.inventory.domain.Store;

@RestController
@RequestMapping("/api/products")
public class ProductDetailsEndpoint {

    private final InventoryRequester inventoryRequester;

    @Autowired
    public ProductDetailsEndpoint(final InventoryRequester inventoryRequester) {
        this.inventoryRequester = inventoryRequester;
    }

    @RequestMapping("/{store}/{product}")
    public ProductDetails inventory(@PathVariable("store") String storeId, @PathVariable("product") String productId) {
        Store store = new Store(storeId);
        Product product = new Product(productId);
        Inventory inventory = new CircuitBreakerInventoryRequestCommand(inventoryRequester, store, product, false).execute();
        return new ProductDetails(inventory);
    }

    @Data
    @AllArgsConstructor
    class ProductDetails {
        private Inventory inventory;
    }
}
{'fraction_non_alphanumeric': 0.09002813379180995, 'fraction_numerical': 0.0012503907471084713, 'mean_word_length': 5.374501992031872, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6445836', 'n_tokens_mistral': 875, 'n_tokens_neox': 855, 'n_words': 155}