Access to the API Platform

EPC’s API documentation is on Swagger, where we host all possible services of the EPC API. The complete EPC API operations documentation is accessible at https://YOUREPC.interfacing.com/api/v1/swagger. Swagger will open immediately, allowing you to access the possible operations.

How to use Swagger

The services are organized by subject. The expansion of one of them will list every possible API request for that topic. There are three main types of queries:

  • Get: Equivalent to a SQL SELECT query
  • Put: Equivalent to a SQL UPDATE query
  • Post: Equivalent to a SQL CREATE query

Each query has its own section, which includes:

1. An example of the data / attributes included in the request

2. Parameters / filters that you can configure in the query (some are required):

JAVA Code Example of a Complete Client Using Spring Boot:

package com.interfacing.epc.sync.bpc.service;
import java.util.Collection;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
import lombok.RequiredArgsConstructor;
import reactor.core.publisher.Mono;
import com.interfacing.bpc.api.domain.BaseElement;
import com.interfacing.bpc.api.domain.NodeElement;
import com.interfacing.bpc.api.domain.patch.PatchOperation;
@Service
@RequiredArgsConstructor
public class ItemService {
    private final WebClient bpcClient;
    private final MultiValueMap<String, String> defaultQueryParams; // when retrieving objects
    private final MultiValueMap<String, String> defaultEditParams; // when editing objects
    public Mono<BaseElement> findBaseElement(@NotNull String nodeId) {
        return bpcClient.get()
                .uri(uriBuilder -> uriBuilder.path("/items/").queryParams(defaultQueryParams).build(nodeId))
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<>() {
                });
    }
    public <T extends NodeElement> Mono<T> findElement(@NotNull String nodeId, Class<T> clazz) {
        return bpcClient.get()
                .uri(uriBuilder -> uriBuilder.path("/items/").queryParams(defaultQueryParams).queryParam("detail", true).build(nodeId))
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<>() {
                });
    }
    public Mono<String> findDescription(@NotNull String nodeId) {
        return bpcClient.get()
                .uri(uriBuilder -> uriBuilder.path("/items//description").queryParams(defaultQueryParams).build(nodeId))
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<>() {
                });
    }
    public Mono<String> findRichTextDescription(@NotNull String nodeId) {
        return bpcClient.get()
                .uri(uriBuilder -> uriBuilder.path("/items//richTextDescription").queryParams(defaultQueryParams).build(nodeId))
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<>() {
                });
    }
    public Mono<String> findWebappUrl(@NotNull String nodeId) {
        return bpcClient.get()
                .uri(uriBuilder -> uriBuilder.path("/items//url/webapp").queryParams(defaultQueryParams).build(nodeId))
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<>() {
                });
    }
    public Mono<BaseElement> createItem(@NotNull NodeElement nodeElement) {
        return bpcClient.post()
                .uri(uriBuilder -> uriBuilder.path("/items").queryParams(defaultEditParams).build())
                .contentType(MediaType.APPLICATION_JSON)
                .body(BodyInserters.fromValue(nodeElement))
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<>() {
                });
    }
    public Mono<BaseElement> updateItem(@NotNull NodeElement nodeElement) {
        return bpcClient.put()
                .uri(uriBuilder -> uriBuilder.path("/items/").queryParams(defaultEditParams).build(nodeElement.getNodeId()))
                .contentType(MediaType.APPLICATION_JSON)
                .body(BodyInserters.fromValue(nodeElement))
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<>() {
                });
    }
    public Mono<Collection<BaseElement>> patchItem(@NotNull String nodeId, @NotEmpty Collection<PatchOperation> patchOperations) {
        return bpcClient.patch().uri(uriBuilder -> uriBuilder.path("/items/").queryParams(defaultEditParams).build(nodeId))
                .contentType(MediaType.APPLICATION_JSON)
                .body(BodyInserters.fromValue(patchOperations))
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<>() {
                });
    }
}

Reaktion

War das hilfreich?

Ja Nein
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Hinterlasse einen Kommentar.

Bitte stellen Sie hier keine Supportanfragen.
Visit the Support Portal

Kommentar senden