Skip to content

Commit f2e6bd5

Browse files
authored
Merge pull request #218 from BingAds/v13.0.24.2
v13.0.24.2
2 parents 760ac06 + 637bf3c commit f2e6bd5

File tree

11 files changed

+88
-18
lines changed

11 files changed

+88
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The Bing Ads Java SDK includes and depends on the microsoft.bingads Maven artifa
1616
<dependency>
1717
<groupId>com.microsoft.bingads</groupId>
1818
<artifactId>microsoft.bingads</artifactId>
19-
<version>13.0.24.1</version>
19+
<version>13.0.24.2</version>
2020
</dependency>
2121
```
2222
If you are not using a Maven project, you must include the correct version of each dependency. You can review the complete list of Bing Ads Java SDK dependencies at the [Maven Repository](http://mvnrepository.com/artifact/com.microsoft.bingads/microsoft.bingads/).

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.microsoft.bingads</groupId>
4-
<version>13.0.24.1</version>
4+
<version>13.0.24.2</version>
55
<name>Bing Ads Java SDK</name>
66
<description>The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.</description>
77
<url>https://github.com/BingAds/BingAds-Java-SDK</url>

src/main/java/com/microsoft/bingads/RestfulServiceFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.microsoft.bingads.internal.restful.BulkService;
99
import com.microsoft.bingads.internal.restful.CustomerManagementService;
1010
import com.microsoft.bingads.internal.restful.CustomerBillingService;
11+
import com.microsoft.bingads.internal.IRestfulServiceFactory;
1112
import com.microsoft.bingads.internal.restful.AdInsightService;
1213
import com.microsoft.bingads.v13.bulk.IBulkService;
1314
import com.microsoft.bingads.v13.campaignmanagement.ICampaignManagementService;
@@ -16,9 +17,9 @@
1617
import com.microsoft.bingads.v13.customerbilling.ICustomerBillingService;
1718
import com.microsoft.bingads.v13.adinsight.IAdInsightService;
1819

19-
public class RestfulServiceFactory {
20+
public class RestfulServiceFactory implements IRestfulServiceFactory {
2021

21-
public static <T> T createServiceClient(Map<String, String> headers, ApiEnvironment environment, Class<T> serviceInterface, Supplier<T> createSoapPort) {
22+
public <T> T createServiceClient(Map<String, String> headers, ApiEnvironment environment, Class<T> serviceInterface, Supplier<T> createSoapPort) {
2223
if (serviceInterface == ICampaignManagementService.class) {
2324
return serviceInterface.cast(new CampaignManagementService(headers, environment, () -> (ICampaignManagementService)createSoapPort.get()));
2425
}

src/main/java/com/microsoft/bingads/ServiceClient.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
import jakarta.xml.ws.handler.PortInfo;
1212

1313
import com.microsoft.bingads.internal.HeaderHandler;
14+
import com.microsoft.bingads.internal.IRestfulServiceFactory;
1415
import com.microsoft.bingads.internal.MessageHandler;
1516
import com.microsoft.bingads.internal.OAuthWithAuthorizationCode;
1617
import com.microsoft.bingads.internal.ServiceFactory;
1718
import com.microsoft.bingads.internal.ServiceFactoryFactory;
19+
import com.microsoft.bingads.internal.RestfulServiceFactoryFactory;
1820
import com.microsoft.bingads.internal.ServiceUtils;
1921
import com.microsoft.bingads.internal.utilities.Lazy;
2022
import com.microsoft.bingads.v13.adinsight.IAdInsightService;
@@ -47,6 +49,7 @@ public class ServiceClient<T> {
4749

4850
private final Class<T> serviceInterface;
4951
private final ServiceFactory serviceFactory;
52+
private final IRestfulServiceFactory restfulServiceFactory;
5053
private ApiEnvironment environment;
5154
private final Lazy<Service> service;
5255

@@ -106,6 +109,8 @@ public ServiceClient(AuthorizationData authorizationData, ApiEnvironment environ
106109
this.environment = environment;
107110

108111
serviceFactory = ServiceFactoryFactory.createServiceFactory();
112+
113+
restfulServiceFactory = RestfulServiceFactoryFactory.createServiceFactory();
109114

110115
service = new Lazy<Service>(() -> {
111116
Service newService = serviceFactory.createService(this.serviceInterface, this.environment);
@@ -172,6 +177,6 @@ T createSoapPort(Map<String, String> headers) {
172177
}
173178

174179
T createRestService(Map<String, String> headers) {
175-
return RestfulServiceFactory.createServiceClient(headers, environment, serviceInterface, () -> createSoapPort(headers));
180+
return restfulServiceFactory.createServiceClient(headers, environment, serviceInterface, () -> createSoapPort(headers));
176181
}
177182
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.microsoft.bingads.internal;
2+
3+
import java.util.Map;
4+
import java.util.function.Supplier;
5+
6+
import com.microsoft.bingads.ApiEnvironment;
7+
8+
public interface IRestfulServiceFactory {
9+
10+
<T> T createServiceClient(Map<String, String> headers, ApiEnvironment environment, Class<T> serviceInterface, Supplier<T> createSoapPort);
11+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.microsoft.bingads.internal;
2+
3+
import com.microsoft.bingads.RestfulServiceFactory;
4+
import com.microsoft.bingads.internal.functionalinterfaces.Supplier;
5+
6+
public class RestfulServiceFactoryFactory {
7+
8+
private static Supplier<IRestfulServiceFactory> customServiceFactorySupplier;
9+
10+
public static Supplier<IRestfulServiceFactory> getCustomServiceFactorySupplier() {
11+
return customServiceFactorySupplier;
12+
}
13+
14+
public static void setCustomServiceFactorySupplier(Supplier<IRestfulServiceFactory> value) {
15+
customServiceFactorySupplier = value;
16+
}
17+
18+
public static IRestfulServiceFactory createServiceFactory() {
19+
return customServiceFactorySupplier == null ? new RestfulServiceFactory() : customServiceFactorySupplier.get();
20+
}
21+
}

src/main/java/com/microsoft/bingads/internal/ServiceUtils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
import com.microsoft.bingads.ApiEnvironment;
1212
import com.microsoft.bingads.InternalException;
13+
import com.microsoft.bingads.v13.bulk.IBulkService;
14+
import com.microsoft.bingads.v13.campaignmanagement.ICampaignManagementService;
15+
import com.microsoft.bingads.v13.reporting.IReportingService;
1316

1417
/**
1518
* Reserved for internal use.
@@ -105,6 +108,13 @@ public static boolean getEnableRestApi() {
105108
}
106109

107110
public static boolean getDisableRestApi(Class<?> serviceInterface) {
111+
if (serviceInterface == ICampaignManagementService.class ||
112+
serviceInterface == IBulkService.class ||
113+
serviceInterface == IReportingService.class)
114+
{
115+
return false;
116+
}
117+
108118
String propertyValue = getPropertyValue(serviceInterface.getSimpleName() + ".DisableRestApi");
109119

110120
if (propertyValue == null) {

src/main/java/com/microsoft/bingads/v13/bulk/entities/BulkKeyword.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
*/
5151
public class BulkKeyword extends SingleRecordBulkEntity {
5252

53-
private Long campaignId;
53+
private Long campaignId;
5454

5555
private Long adGroupId;
5656

src/test/java/com/microsoft/bingads/v13/api/test/operations/FakeApiTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,29 @@
1616
import org.w3c.dom.Document;
1717
import org.w3c.dom.Element;
1818

19+
import com.microsoft.bingads.internal.IRestfulServiceFactory;
20+
import com.microsoft.bingads.internal.RestfulServiceFactoryFactory;
1921
import com.microsoft.bingads.internal.ServiceFactory;
2022
import com.microsoft.bingads.internal.ServiceFactoryFactory;
2123
import com.microsoft.bingads.internal.functionalinterfaces.Supplier;
2224

2325
public class FakeApiTest {
2426
@Before
25-
public void setUp() {
26-
System.setProperty("com.microsoft.bingads.ICampaignManagementService.DisableRestApi", "true");
27-
System.setProperty("com.microsoft.bingads.IBulkService.DisableRestApi", "true");
28-
System.setProperty("com.microsoft.bingads.IReportingService.DisableRestApi", "true");
29-
System.setProperty("com.microsoft.bingads.ICustomerManagementService.DisableRestApi", "true");
30-
System.setProperty("com.microsoft.bingads.ICustomerBillingService.DisableRestApi", "true");
31-
System.setProperty("com.microsoft.bingads.IAdInsightService.DisableRestApi", "true");
32-
27+
public void setUp() {
3328
ServiceFactoryFactory.setCustomServiceFactorySupplier(new Supplier<ServiceFactory>() {
3429
@Override
3530
public ServiceFactory get() {
3631
return new FakeServiceFactory();
3732
}
3833
});
3934

35+
RestfulServiceFactoryFactory.setCustomServiceFactorySupplier(new Supplier<IRestfulServiceFactory>() {
36+
@Override
37+
public IRestfulServiceFactory get() {
38+
return new FakeServiceFactory();
39+
}
40+
});
41+
4042
FakeBulkService.reset();
4143
}
4244

src/test/java/com/microsoft/bingads/v13/api/test/operations/FakeBulkService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
import jakarta.xml.ws.EndpointReference;
1313
import jakarta.xml.ws.Response;
1414

15+
import com.microsoft.bingads.ApiEnvironment;
1516
import com.microsoft.bingads.internal.ServiceUtils;
1617
import com.microsoft.bingads.internal.functionalinterfaces.Consumer;
1718
import com.microsoft.bingads.internal.functionalinterfaces.Supplier;
19+
import com.microsoft.bingads.internal.restful.BulkService;
1820
import com.microsoft.bingads.v13.bulk.AdApiFaultDetail_Exception;
1921
import com.microsoft.bingads.v13.bulk.ApiFaultDetail_Exception;
2022
import com.microsoft.bingads.v13.bulk.DownloadCampaignsByAccountIdsRequest;
@@ -31,9 +33,14 @@
3133
import com.microsoft.bingads.v13.bulk.UploadEntityRecordsRequest;
3234
import com.microsoft.bingads.v13.bulk.UploadEntityRecordsResponse;
3335

34-
public class FakeBulkService implements IBulkService, BindingProvider {
36+
public class FakeBulkService extends BulkService implements IBulkService, BindingProvider {
3537

36-
private static Consumer<GetBulkDownloadStatusRequest> onGetBulkDownloadStatus;
38+
public FakeBulkService(Map<String, String> headers, ApiEnvironment env,
39+
java.util.function.Supplier<IBulkService> fallbackService) {
40+
super(headers, env, fallbackService);
41+
}
42+
43+
private static Consumer<GetBulkDownloadStatusRequest> onGetBulkDownloadStatus;
3744
private static Supplier<GetBulkDownloadStatusResponse> getBulkDownloadStatusResponse;
3845

3946
private static Supplier<GetBulkUploadStatusResponse> getBulkUploadStatusResponse;

0 commit comments

Comments
 (0)