Facebook java business sdk 7.0.0 lib is missing AdsInsights class member data

177 views Asked by At

Marketing API v7.0 (java lib: facebook-java-business-sdk.7.0.0)

I recently jumped from v5.0 to v7.0 and discovered that the following fields disappeared from the AdsInsights class:

@SerializedName("hourly_stats_aggregated_by_advertiser_time_zone")
private String mHourlyStatsAggregatedByAdvertiserTimeZone = null;
  
@SerializedName("hourly_stats_aggregated_by_audience_time_zone")
private String mHourlyStatsAggregatedByAudienceTimeZone = null;
 
@SerializedName("product_id") 
private String mProductId = null;

The last lib in which these fields were present was

 facebook-java-business-sdk.6.0.0

and first disappeared in version

facebook-java-business-sdk.6.0.4

I checked the change logs and found no details regarding these missing fields and it seems like an oversight. Any idea if/when these fields will return to the latest java libs?

Thanks.

1

There are 1 answers

10
Greg Roberts On

In lieu of the fact that the reported bug hasn't been addressed in months, we were hoping to fix this by submitting code changes to the AdsInsights class in github project. Unfortunately, you're not allowed to change the autogenerated classes. So we came up with a different solution until the autogenerated classes are fixed. We created a separate maven project that ignores the autogenerated AdsInsights class file and allows us to include our own "slightly modified" version of AdsInsights. We copied and modified AdsInsights from v8.0.1 to include the missing data members and accessors that we required. The ones we require are different than the ones from the question asked, but the concept is exactly the same. If you're not sure what to change, look at the source code of v6.0.0 to see what it used to look like. Your pom should use a slightly modified artifactId so as not to conflict with any other versions you might have installed. I'm including the relevant parts of the pom we created. This solution worked perfectly for us with no issues with the functionality we added back in. `

<modelVersion>4.0.0</modelVersion>
<groupId>com.facebook.business.sdk</groupId>
<artifactId>facebook-java-business-sdk-yourcompanyname</artifactId>
<packaging>jar</packaging>
<version>8.0.1</version>
<name>facebook-java-business-sdk</name>
<description>A fork of Facebook's Business SDK containing patches/customizations needed for use cases</description>

<distributionManagement>
    <site>
        <id>documentserver</id>
        <url>${distributionManagement.baseUrl}/${project.artifactId}/${project.version}</url>
    </site>
</distributionManagement>

<properties>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <targetJdk>1.7</targetJdk>
</properties>

<dependencies>
    <dependency>
        <groupId>com.facebook.business.sdk</groupId>
        <artifactId>facebook-java-business-sdk</artifactId>
        <version>8.0.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-toolchains-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>toolchain</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <toolchains>
                    <jdk>
                        <version>${targetJdk}</version>
                    </jdk>
                </toolchains>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>${targetJdk}</source>
                <target>${targetJdk}</target>
                <verbose>true</verbose>
                <fork>true</fork>
                <compilerArgs>
                    <arg>-Xlint</arg>
                </compilerArgs>
            </configuration>
        </plugin>
        <!-- This will allow us to overwrite class files in the business SDK with our own versions defined in this project -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.facebook.business.sdk</groupId>
                                <artifactId>facebook-java-business-sdk</artifactId>
                                <version>8.0.1</version>
                                <type>jar</type>
                                <overWrite>true</overWrite>
                                <outputDirectory>${project.build.directory}/classes</outputDirectory>
                                <excludes>
                                    **/AdsInsights.class
                                </excludes>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

`