1. 快速开始

代码示例(SDK)

查询客户列表,关联查询客户分类的id及名称

public class OpenapiRequestDemo {
  private static Openapi client;

  public static void main(String[] args) {
    testList();
  }

  public static void testList() {
    PostListRequest request = new PostListRequest();
    ApiParams apiParams = new ApiParams();
    apiParams.setJson("{\n" +
            "  \"objectType\":\"Customer\",\n" +
            "  \"criteriaStr\": \"id is not null\",\n" +
            "  \"fields\": [\n" +
            "    \"id\",\n" +
            "    \"name\",\n" +
            "    {\n" +
            "      \"fieldName\": \"category\",\n" +
            "      \"fields\": [\n" +
            "        \"id\",\n" +
            "        \"name\"" +
            "      ]\n" +
            "    },\n" +
            "    \"code\"\n" +
            "  ]\n" +
            "}");
    SdkRequestConfig build = request.sdkRequestConfig().copyBuilder()
            .customHeader("Content-Type", "application/json")
            .customHeader("Access-Key-Id", "your access key id")
            .customHeader("Open-Id", "your open id")
            .build();
    request.sdkRequestConfig(build);
    request.setApiParams(apiParams);
    PostListResult postListResult = getClient().postList(request);
    ApiResponse apiResponse = postListResult.getApiResponse();
    System.out.println(apiResponse.getJson());
  }

  public static Openapi getClient() {
    if (client == null) {
      String accessKey = "accessKey";
      String accessSecret = "accessSecret";
      BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, accessSecret);
      client = Openapi.builder()
              .connectionConfiguration(new ConnectionConfiguration()
                      .maxConnections(100)
                      .connectionMaxIdleMillis(1000))
              .timeoutConfiguration(new TimeoutConfiguration()
                      .httpRequestTimeout(3000)
                      .totalExecutionTimeout(10000)
                      .socketTimeout(2000))
              .iamCredentials(new AWSStaticCredentialsProvider(awsCredentials))
              .build();
    }
    return client;
  }
}

响应示例

{
  "data": {
    "list": [
      {
        "id": "5FRANP5010L0001",
        "name": "客户A",
        "category": {
          "id": "X9P0AP5025L0001",
          "name": "A"
        },
        "code": "0010000005"
      },
      {
        "id": "7N94JP501AR0001",
        "name": "客户B",
        "category": {
          "id": "X9P0AP5025L0001",
          "name": "A"
        },
        "code": "0010000004"
      },
      {
        "id": "DBP0AP5025L0001",
        "name": "客户C",
        "category": {
          "id": "W27RAP5021A0001",
          "name": "B类"
        },
        "code": "0010000001"
      }
    ]
  },
  "errors": []
}

results matching ""

    No results matching ""