Exemplo n.º 1
0
  static void printCampaignCriterionIdentifiers(
      ArrayOfNullableOflong criterionIds, ArrayOfBatchErrorCollection partialErrors) {
    if (criterionIds == null) {
      return;
    }

    int count = criterionIds.getLongs().size();

    for (int i = 0; i < count; i++) {
      if (criterionIds.getLongs().get(i) != null) {
        outputStatusMessage(
            String.format(
                "Successfully added campaign criterion with ID, %d\n\n",
                criterionIds.getLongs().get(i)));
      } else {
        outputStatusMessage(String.format("Failed to add campaign criterion at index, %d\n\n", i));

        BatchErrorCollection error = partialErrors.getBatchErrorCollections().get(i);

        outputStatusMessage(String.format("\tIndex: %d\n", error.getIndex()));
        outputStatusMessage(String.format("\tCode: %d\n", error.getCode()));
        outputStatusMessage(String.format("\tErrorCode: %s\n", error.getErrorCode()));
        outputStatusMessage(String.format("\tMessage: %s\n", error.getMessage()));

        if (error.getBatchErrors() != null) {
          for (BatchError batchError : error.getBatchErrors().getBatchErrors()) {
            outputStatusMessage(String.format("\tIndex: %d\n", batchError.getIndex()));
            outputStatusMessage(String.format("\tCode: %d\n", batchError.getCode()));
            outputStatusMessage(String.format("\tErrorCode: %s\n", batchError.getErrorCode()));
            outputStatusMessage(String.format("\tMessage: %s\n\n", batchError.getMessage()));
          }
        }
      }
    }
  }
Exemplo n.º 2
0
  static void printAdIdentifiers(ArrayOfNullableOflong adIds, ArrayOfBatchError partialErrors) {
    if (adIds == null) {
      return;
    }

    int count = adIds.getLongs().size();

    for (int i = 0; i < count; i++) {
      if (adIds.getLongs().get(i) != null) {
        // A shopping campaign should contain only product ads.

        outputStatusMessage(
            String.format(
                "Successfully added a product ad with ID, %d\n\n", adIds.getLongs().get(i)));
      } else {
        outputStatusMessage(String.format("Failed to add product ad at index, %d\n\n", i));

        BatchError error = partialErrors.getBatchErrors().get(i);

        outputStatusMessage(String.format("\tIndex: %d\n", error.getIndex()));
        outputStatusMessage(String.format("\tCode: %d\n", error.getCode()));
        outputStatusMessage(String.format("\tErrorCode: %s\n", error.getErrorCode()));
        outputStatusMessage(String.format("\tMessage: %s\n", error.getMessage()));

        // If the error is an editorial error, get more details.

        if (error.getType() == "EditorialError"
            && error.getErrorCode() == "CampaignServiceEditorialValidationError") {
          outputStatusMessage(
              String.format(
                  "\tDisapprovedText: %s\n", ((EditorialError) error).getDisapprovedText()));
          outputStatusMessage(
              String.format("\tLocation: %s\n", ((EditorialError) error).getLocation()));
          outputStatusMessage(
              String.format(
                  "\tPublisherCountry: %s\n", ((EditorialError) error).getPublisherCountry()));
          outputStatusMessage(
              String.format("\tReasonCode: %s\n", ((EditorialError) error).getReasonCode()));
        }
      }
    }
  }