Search in sources :

Example 16 with Order

use of com.google.api.ads.admanager.axis.v202108.Order in project pwinty-java-sdk by OddPrints.

the class OrderUpdater method updateAddress.

public void updateAddress(int orderIdToUpdate) {
    Pwinty pwinty = getPwinty(environment);
    System.out.println(pwinty.getOrder(orderIdToUpdate));
    Order order = pwinty.getOrder(orderIdToUpdate);
    order.setRecipientName("");
    order.setAddress1("");
    order.setAddress2("");
    order.setAddressTownOrCity("");
    order.setStateOrCounty("");
    order.setPostalOrZipCode("");
}
Also used : Order(uk.co.mattburns.pwinty.v2_3.Order) Pwinty(uk.co.mattburns.pwinty.v2_3.Pwinty)

Example 17 with Order

use of com.google.api.ads.admanager.axis.v202108.Order in project pwinty-java-sdk by OddPrints.

the class OrderUpdater method decodeAddress.

public void decodeAddress(int orderIdToUpdate) {
    Pwinty pwinty = getPwinty(environment);
    System.out.println(pwinty.getOrder(orderIdToUpdate));
    Order order = pwinty.getOrder(orderIdToUpdate);
    order.setRecipientName(decode(order.getRecipientName()));
    order.setAddress1(decode(order.getAddress1()));
    order.setAddress2(decode(order.getAddress2()));
    order.setAddressTownOrCity(decode(order.getAddressTownOrCity()));
    order.setStateOrCounty(decode(order.getStateOrCounty()));
    order.setPostalOrZipCode(decode(order.getPostalOrZipCode()));
}
Also used : Order(uk.co.mattburns.pwinty.v2_3.Order) Pwinty(uk.co.mattburns.pwinty.v2_3.Pwinty)

Example 18 with Order

use of com.google.api.ads.admanager.axis.v202108.Order in project pwinty-java-sdk by OddPrints.

the class OrderUpdater method updateUseTrackedShipping.

public int updateUseTrackedShipping(int orderIdToUpdate, boolean useTrackedShipping) {
    Pwinty pwinty = getPwinty(environment);
    System.out.println(pwinty.getOrder(orderIdToUpdate));
    Order order = pwinty.getOrder(orderIdToUpdate);
    order = order.createCloneWithTrackedShipping(useTrackedShipping);
    System.out.println(order);
    if (order.getShippingInfo().getShipments().get(0).isTracked() != useTrackedShipping) {
        throw new RuntimeException("Couldn't set useTrackedShipping to " + useTrackedShipping + ". Is it available with current quality / country settings?");
    }
    System.out.println(pwinty.getOrder(order.getId()));
    System.out.println("**** NOTE: ORDER NUMBER HAS NOW CHANGED !! ****");
    System.out.println("New order number is : " + order.getId());
    return order.getId();
}
Also used : Order(uk.co.mattburns.pwinty.v2_3.Order) Pwinty(uk.co.mattburns.pwinty.v2_3.Pwinty)

Example 19 with Order

use of com.google.api.ads.admanager.axis.v202108.Order in project googleads-java-lib by googleads.

the class CreateVideoLineItems method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param orderId the ID of the order that the line item will belong to.
 * @param targetedVideoAdUnitId the ID of the d unit that the line item will target.
 * @param contentId the ID of the video content that the line item will target.
 * @param contentBundleId the ID of the video content bundle that the line item will target.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long orderId, String targetedVideoAdUnitId, long contentId, long contentBundleId, long cmsMetadataValueId) throws RemoteException {
    // Get the LineItemService.
    LineItemServiceInterface lineItemService = adManagerServices.get(session, LineItemServiceInterface.class);
    // Create content targeting.
    ContentTargeting contentTargeting = new ContentTargeting();
    contentTargeting.setTargetedContentIds(new long[] { contentId });
    contentTargeting.setTargetedVideoContentBundleIds(new long[] { contentBundleId });
    // Target only video players
    RequestPlatformTargeting requestPlatformTargeting = new RequestPlatformTargeting();
    requestPlatformTargeting.setTargetedRequestPlatforms(new RequestPlatform[] { RequestPlatform.VIDEO_PLAYER });
    // Create inventory targeting.
    InventoryTargeting inventoryTargeting = new InventoryTargeting();
    inventoryTargeting.setTargetedAdUnits(new AdUnitTargeting[] { new AdUnitTargeting(targetedVideoAdUnitId, true) });
    // Create video position targeting.
    VideoPosition videoPosition = new VideoPosition();
    videoPosition.setPositionType(VideoPositionType.PREROLL);
    VideoPositionTarget videoPositionTarget = new VideoPositionTarget();
    videoPositionTarget.setVideoPosition(videoPosition);
    VideoPositionTargeting videoPositionTargeting = new VideoPositionTargeting();
    videoPositionTargeting.setTargetedPositions(new VideoPositionTarget[] { videoPositionTarget });
    // Create custom targeting for CmsMetadataValues.
    CmsMetadataCriteria contentCustomCriteria = new CmsMetadataCriteria();
    contentCustomCriteria.setCmsMetadataValueIds(new long[] { cmsMetadataValueId });
    contentCustomCriteria.setOperator(CmsMetadataCriteriaComparisonOperator.EQUALS);
    CustomCriteriaSet customCriteriaSet = new CustomCriteriaSet();
    customCriteriaSet.setChildren(new CustomCriteriaNode[] { contentCustomCriteria });
    customCriteriaSet.setLogicalOperator(CustomCriteriaSetLogicalOperator.AND);
    // Create targeting.
    Targeting targeting = new Targeting();
    targeting.setContentTargeting(contentTargeting);
    targeting.setInventoryTargeting(inventoryTargeting);
    targeting.setVideoPositionTargeting(videoPositionTargeting);
    targeting.setRequestPlatformTargeting(requestPlatformTargeting);
    targeting.setCustomTargeting(customCriteriaSet);
    // Create local line item object.
    LineItem lineItem = new LineItem();
    lineItem.setName("Video line item #" + new Random().nextInt(Integer.MAX_VALUE));
    lineItem.setOrderId(orderId);
    lineItem.setTargeting(targeting);
    // Allow the line item to be booked even if there is not enough inventory.
    lineItem.setAllowOverbook(true);
    // Set the line item type to SPONSORSHIP.
    lineItem.setLineItemType(LineItemType.SPONSORSHIP);
    // Set the environment type to video.
    lineItem.setEnvironmentType(EnvironmentType.VIDEO_PLAYER);
    // Set the creative rotation type to optimized.
    lineItem.setCreativeRotationType(CreativeRotationType.OPTIMIZED);
    // Create the master creative placeholder.
    CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
    creativeMasterPlaceholder.setSize(new Size(640, 360, false));
    // Create companion creative placeholders.
    CreativePlaceholder companionCreativePlaceholder = new CreativePlaceholder();
    companionCreativePlaceholder.setSize(new Size(300, 250, false));
    // Set companion creative placeholders.
    creativeMasterPlaceholder.setCompanions(new CreativePlaceholder[] { companionCreativePlaceholder });
    // Set the size of creatives that can be associated with this line item.
    lineItem.setCreativePlaceholders(new CreativePlaceholder[] { creativeMasterPlaceholder });
    // Set delivery of video companions to optional.
    lineItem.setCompanionDeliveryOption(CompanionDeliveryOption.OPTIONAL);
    // Set the maximum video creative length for this line item to 15 seconds.
    lineItem.setVideoMaxDuration(15000L);
    // Set the length of the line item to run.
    lineItem.setStartDateTimeType(StartDateTimeType.IMMEDIATELY);
    lineItem.setEndDateTime(DateTimes.toDateTime(Instant.now().plus(Duration.standardDays(30L)), "America/New_York"));
    // Set the cost per day to $1.
    lineItem.setCostType(CostType.CPD);
    lineItem.setCostPerUnit(new Money("USD", 1000000L));
    // Set the percentage to be 100%.
    Goal goal = new Goal();
    goal.setGoalType(GoalType.DAILY);
    goal.setUnits(100L);
    lineItem.setPrimaryGoal(goal);
    // Create the line item on the server.
    LineItem[] lineItems = lineItemService.createLineItems(new LineItem[] { lineItem });
    for (LineItem createdLineItem : lineItems) {
        System.out.printf("A video line item with ID %d and name '%s' was created.%n", createdLineItem.getId(), createdLineItem.getName());
    }
}
Also used : RequestPlatformTargeting(com.google.api.ads.admanager.axis.v202108.RequestPlatformTargeting) Targeting(com.google.api.ads.admanager.axis.v202108.Targeting) AdUnitTargeting(com.google.api.ads.admanager.axis.v202108.AdUnitTargeting) RequestPlatformTargeting(com.google.api.ads.admanager.axis.v202108.RequestPlatformTargeting) ContentTargeting(com.google.api.ads.admanager.axis.v202108.ContentTargeting) InventoryTargeting(com.google.api.ads.admanager.axis.v202108.InventoryTargeting) VideoPositionTargeting(com.google.api.ads.admanager.axis.v202108.VideoPositionTargeting) LineItemServiceInterface(com.google.api.ads.admanager.axis.v202108.LineItemServiceInterface) Size(com.google.api.ads.admanager.axis.v202108.Size) LineItem(com.google.api.ads.admanager.axis.v202108.LineItem) ContentTargeting(com.google.api.ads.admanager.axis.v202108.ContentTargeting) InventoryTargeting(com.google.api.ads.admanager.axis.v202108.InventoryTargeting) VideoPositionTargeting(com.google.api.ads.admanager.axis.v202108.VideoPositionTargeting) CustomCriteriaSet(com.google.api.ads.admanager.axis.v202108.CustomCriteriaSet) VideoPosition(com.google.api.ads.admanager.axis.v202108.VideoPosition) CreativePlaceholder(com.google.api.ads.admanager.axis.v202108.CreativePlaceholder) Money(com.google.api.ads.admanager.axis.v202108.Money) Goal(com.google.api.ads.admanager.axis.v202108.Goal) AdUnitTargeting(com.google.api.ads.admanager.axis.v202108.AdUnitTargeting) Random(java.util.Random) VideoPositionTarget(com.google.api.ads.admanager.axis.v202108.VideoPositionTarget) CmsMetadataCriteria(com.google.api.ads.admanager.axis.v202108.CmsMetadataCriteria)

Example 20 with Order

use of com.google.api.ads.admanager.axis.v202108.Order in project googleads-java-lib by googleads.

the class GetOrdersStartingSoon method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select orders.
    StatementBuilder statementBuilder = new StatementBuilder().where("status = :status and startDateTime >= :now and startDateTime <= :soon").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", OrderStatus.APPROVED.toString()).withBindVariableValue("now", DateTimes.toDateTime(Instant.now(), "America/New_York")).withBindVariableValue("soon", DateTimes.toDateTime(Instant.now().plus(Duration.standardDays(5L)), "America/New_York"));
    // Retrieve a small amount of orders at a time, paging through
    // until all orders have been retrieved.
    int totalResultSetSize = 0;
    do {
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each order.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Order order : page.getResults()) {
                System.out.printf("%d) Order with ID %d and name '%s' was found.%n", i++, order.getId(), order.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : Order(com.google.api.ads.admanager.axis.v202111.Order) OrderPage(com.google.api.ads.admanager.axis.v202111.OrderPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) OrderServiceInterface(com.google.api.ads.admanager.axis.v202111.OrderServiceInterface)

Aggregations

Order (uk.co.mattburns.pwinty.v2_3.Order)7 Pwinty (uk.co.mattburns.pwinty.v2_3.Pwinty)7 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)6 Random (java.util.Random)6 Order (com.google.api.ads.admanager.axis.v202108.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202108.OrderServiceInterface)5 Order (com.google.api.ads.admanager.axis.v202111.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202111.OrderServiceInterface)5 Order (com.google.api.ads.admanager.axis.v202202.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202202.OrderServiceInterface)5 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 OrderPage (com.google.api.ads.admanager.axis.v202108.OrderPage)4 OrderPage (com.google.api.ads.admanager.axis.v202111.OrderPage)4 AdUnitTargeting (com.google.api.ads.admanager.axis.v202108.AdUnitTargeting)3 CreativePlaceholder (com.google.api.ads.admanager.axis.v202108.CreativePlaceholder)3 Goal (com.google.api.ads.admanager.axis.v202108.Goal)3 InventoryTargeting (com.google.api.ads.admanager.axis.v202108.InventoryTargeting)3 LineItem (com.google.api.ads.admanager.axis.v202108.LineItem)3 LineItemServiceInterface (com.google.api.ads.admanager.axis.v202108.LineItemServiceInterface)3