Search in sources :

Example 21 with Order

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

the class UpdateOrders method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param orderId the ID of the order to update.
 * @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) throws RemoteException {
    // Get the OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to only select a single order by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", orderId);
    // Get the order.
    OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
    Order order = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the order's notes.
    order.setNotes("Spoke to advertiser. All is well.");
    // Update the order on the server.
    Order[] orders = orderService.updateOrders(new Order[] { order });
    for (Order updatedOrder : orders) {
        System.out.printf("Order with ID %d and name '%s' was updated.%n", updatedOrder.getId(), updatedOrder.getName());
    }
}
Also used : Order(com.google.api.ads.admanager.axis.v202205.Order) OrderPage(com.google.api.ads.admanager.axis.v202205.OrderPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) OrderServiceInterface(com.google.api.ads.admanager.axis.v202205.OrderServiceInterface)

Example 22 with Order

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

the class StatementBuilderTest method testOrderBy.

@Test
public void testOrderBy() {
    StatementBuilder statementBuilder = new StatementBuilder();
    Statement statement = statementBuilder.orderBy("id ASC").toStatement();
    assertEquals("ORDER BY id ASC", statement.getQuery());
}
Also used : Statement(com.google.api.ads.admanager.axis.v202205.Statement) Test(org.junit.Test)

Example 23 with Order

use of com.google.api.ads.admanager.axis.v202205.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 24 with Order

use of com.google.api.ads.admanager.axis.v202205.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 25 with Order

use of com.google.api.ads.admanager.axis.v202205.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)

Aggregations

Random (java.util.Random)7 Order (uk.co.mattburns.pwinty.v2_3.Order)7 Pwinty (uk.co.mattburns.pwinty.v2_3.Pwinty)7 Order (uk.co.mattburns.pwinty.v2_6.Order)7 Pwinty (uk.co.mattburns.pwinty.v2_6.Pwinty)7 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)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 Order (com.google.api.ads.admanager.axis.v202205.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202205.OrderServiceInterface)5 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)4 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 OrderPage (com.google.api.ads.admanager.axis.v202202.OrderPage)4