![JAR search and dependency download from the Maven repository](/logo.png)
com.echobox.api.tiktok.connection.BusinessConnection Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.echobox.api.tiktok.connection;
import com.echobox.api.tiktok.client.Parameter;
import com.echobox.api.tiktok.client.TikTokClient;
import com.echobox.api.tiktok.model.BusinessId;
import com.echobox.api.tiktok.model.TikTokBusiness;
import com.echobox.api.tiktok.model.response.BusinessGetResponse;
import lombok.AllArgsConstructor;
import java.util.ArrayList;
import java.util.List;
/**
* Connection class for insights endpoints
*
* @author paulp
*/
@AllArgsConstructor
public class BusinessConnection extends ConnectionBase {
private static final String ENDPOINT_GET = "/business/get/";
private final TikTokClient tikTokClient;
/**
* Get all the insights and analytics about a TikTok business account's follower base and
* profile engagement.
* @see Get profile data of a Business Account
*
* @param businessId the business id
* @param fields the fields to populate for the business account insights
* @return the profile data of the business account returned by the API
*/
public TikTokBusiness get(BusinessId businessId, String... fields) {
List parameters = new ArrayList<>();
parameters.add(Parameter.with("business_id", businessId.getId()));
if (fields.length > 0) {
String fieldsValue = formatFields(fields);
parameters.add(Parameter.with("fields", fieldsValue));
}
BusinessGetResponse response = tikTokClient.fetchObject(ENDPOINT_GET,
BusinessGetResponse.class, parameters.toArray(new Parameter[0]));
return response.getData();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy