Skip to content

Commit

Permalink
Merge pull request #54 from trocco-io/ignore_invalid_customers
Browse files Browse the repository at this point in the history
Ignore invalid customers
  • Loading branch information
NamedPython authored Nov 19, 2024
2 parents 85cef95 + 5269e4b commit 3adca23
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/embulk/input/google_ads/GoogleAdsReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.ads.googleads.lib.GoogleAdsClient;
import com.google.ads.googleads.v16.errors.GoogleAdsException;
import com.google.ads.googleads.v16.resources.CustomerName;
import com.google.ads.googleads.v16.services.CustomerServiceClient;
import com.google.ads.googleads.v16.services.GoogleAdsRow;
Expand All @@ -15,6 +16,8 @@
import com.google.ads.googleads.v16.services.SearchGoogleAdsRequest;
import com.google.ads.googleads.v16.services.SearchGoogleAdsStreamRequest;
import com.google.ads.googleads.v16.services.SearchGoogleAdsStreamResponse;
import com.google.api.gax.rpc.DeadlineExceededException;
import com.google.api.gax.rpc.PermissionDeniedException;
import com.google.auth.oauth2.UserCredentials;
import com.google.common.base.CaseFormat;
import com.google.protobuf.Descriptors;
Expand All @@ -29,6 +32,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -315,6 +319,9 @@ private List<Long> getLoginCustomerIds(String customerId)
.filter(loginCustomerClient -> loginCustomerClient.customerClientId.equals(customerId))
.map(loginCustomerClient -> Long.valueOf(loginCustomerClient.loginCustomerId))
.collect(Collectors.toList());
} catch (GoogleAdsException | DeadlineExceededException | PermissionDeniedException e) {
logger.info("ignore invalid customer [customer id: {}]", customerId, e);
return Collections.emptyList();
}
}

Expand All @@ -331,6 +338,9 @@ private List<LoginCustomerClient> getLoginCustomerClients(String customerId)
.map(GoogleAdsRow::getCustomerClient)
.map(customerClient -> new LoginCustomerClient(customerId, customerClient.getId()))
.collect(Collectors.toList());
} catch (GoogleAdsException | DeadlineExceededException | PermissionDeniedException e) {
logger.info("ignore invalid customer [customer id: {}]", customerId, e);
return Collections.emptyList();
}
}

Expand Down

0 comments on commit 3adca23

Please sign in to comment.