Class Api1cClient

java.lang.Object
org.bgerp.plugin.inventoru.sync1c.service.Api1cClient

public class Api1cClient extends Object
HTTP client for 1C ERP REST API. One instance per 1C instance (holds auth credentials).
  • Constructor Details

  • Method Details

    • getStocks

      public List<Api1cStock> getStocks(String warehouseName, String locationName) throws Exception
      Calls POST /hs/gtd_numbers/stocks and returns the list of stock records.
      Parameters:
      warehouseName - 1C warehouse name (engineer full name or warehouse title)
      locationName - 1C location (construction site / object)
      Returns:
      the stock rows of the warehouse, empty when it holds nothing
      Throws:
      Exception - when 1C could not be reached or answered with something that is not a list
    • testConnection

      public String testConnection(String warehouseName)
      Checks that this connector really talks to 1C — and talks about stocks. What it used to check was that the address answered something other than 401 or a server error; a 404, a 405 and a page of HTML all passed as success. That is how a broken exchange kept reporting a working one for a day. Now the answer goes through the same parsing the import does, and a warehouse name is asked for by name, so what is verified is the call the poller will make.
      Parameters:
      warehouseName - name of a warehouse in 1C to ask about, empty to ask about none
      Returns:
      null when 1C answered with a list of stocks, otherwise what went wrong
    • sendWriteoff

      public String sendWriteoff(int processId, String warehouseId, List<Api1cClient.WriteoffItem> items, Map<String,String> fields)
      Sends write-off items to 1C: POST of the write-off method of the connector. There is one entry point on purpose. An overload without fields used to stand beside it and quietly skipped every hs.writeoff.* setting — a caller picking it by accident would send a body the service of the customer refuses, and nothing in the name said so.
      Parameters:
      processId - BGERP process ID (used as external reference in 1C)
      warehouseId - 1C UUID of the warehouse
      items - list of items to write off
      fields - fields beyond the fixed ones — operation, contract and the like, see ExportService.writeoffFields(Sync1cConnector, int, int); empty for the body as it always was
      Returns:
      null on success, error message on failure