use of com.google.api.ads.admanager.axis.v202205.LineItem in project googleads-java-lib by googleads.
the class UpdateLineItems method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param lineItemId the ID of the line item 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 lineItemId) throws RemoteException {
// Get the LineItemService.
LineItemServiceInterface lineItemService = adManagerServices.get(session, LineItemServiceInterface.class);
// Create a statement to only select a single line item by ID.
StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", lineItemId);
// Get the line item.
LineItemPage page = lineItemService.getLineItemsByStatement(statementBuilder.toStatement());
LineItem lineItem = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
// Update the line item's priority to High if possible.
if (lineItem.getLineItemType().equals(LineItemType.STANDARD)) {
lineItem.setPriority(6);
// Update the line item on the server.
LineItem[] lineItems = lineItemService.updateLineItems(new LineItem[] { lineItem });
for (LineItem updatedLineItem : lineItems) {
System.out.printf("Line item with ID %d and name '%s' was updated.%n", updatedLineItem.getId(), updatedLineItem.getName());
}
} else {
System.out.println("No line items were updated.");
}
}
use of com.google.api.ads.admanager.axis.v202205.LineItem in project xmlbeans by apache.
the class POReadOneJaxb2 method run.
private int run(CharArrayReader reader) throws Exception {
// create the xml source from the reader
StreamSource source = new StreamSource(reader);
// unmarshall the xml instance
JAXBContext context = JAXBContext.newInstance("org.openuri.easypo.jaxb2");
Unmarshaller unmarshaller = context.createUnmarshaller();
// depricated - unmarshaller.setValidating(false);
PurchaseOrder po = (PurchaseOrder) unmarshaller.unmarshal(source);
// retreive the first line item
LineItem lineitem = (LineItem) po.getLineItem().get(0);
// return the char length of the description
return lineitem.getDescription().length();
}
use of com.google.api.ads.admanager.axis.v202205.LineItem in project xmlbeans by apache.
the class POTopDownSaveJaxb2 method run.
private int run() throws Exception {
// create the purchase order
PurchaseOrder po = new PurchaseOrder();
// create and initialize the customer
Customer customer = new Customer();
customer.setName(Constants.PO_CUSTOMER_NAME);
customer.setAddress(Constants.PO_CUSTOMER_ADDR);
po.setCustomer(customer);
// set the date
// Date required in javax.xml.datatype.XMLGregorianCalendar format
GregorianCalendar gdate = new GregorianCalendar();
po.setDate(javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(Long.toString(gdate.getTimeInMillis())));
// create and initialize the line item array
for (int i = 0; i < Constants.PO_NUM_LINEITEMS; i++) {
LineItem li = new LineItem();
li.setDescription(Constants.PO_LI_DESC);
li.setPerUnitOunces(Constants.PO_LI_PUO);
li.setPrice(Constants.PO_LI_PRICE);
li.setQuantity(Constants.PO_LI_QUANTITY);
po.getLineItem().add(li);
}
// create and initialize the shipper
Shipper shipper = new Shipper();
shipper.setName(Constants.PO_SHIPPER_NAME);
shipper.setPerOunceRate(Constants.PO_SHIPPER_POR);
po.setShipper(shipper);
// grab the instance that was constructed
JAXBContext context = JAXBContext.newInstance("org.openuri.easypo.jaxb2");
Marshaller marshaller = context.createMarshaller();
StringWriter writer = new StringWriter();
marshaller.marshal(po, writer);
// calculate a hash to return
int hash = (po.getLineItem().size()) * 17;
return hash;
}
use of com.google.api.ads.admanager.axis.v202205.LineItem in project xmlbeans by apache.
the class POTopDownJaxb2 method run.
private int run() throws Exception {
// create the purchase order
PurchaseOrder po = new PurchaseOrder();
// create and initialize the customer
Customer customer = new Customer();
customer.setName(Constants.PO_CUSTOMER_NAME);
customer.setAddress(Constants.PO_CUSTOMER_ADDR);
po.setCustomer(customer);
// set the date
// Date required in javax.xml.datatype.XMLGregorianCalendar format
GregorianCalendar gdate = new GregorianCalendar();
po.setDate(javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(Long.toString(gdate.getTimeInMillis())));
// create and initialize the line item array
for (int i = 0; i < Constants.PO_NUM_LINEITEMS; i++) {
LineItem li = new LineItem();
li.setDescription(Constants.PO_LI_DESC);
li.setPerUnitOunces(Constants.PO_LI_PUO);
li.setPrice(Constants.PO_LI_PRICE);
li.setQuantity(Constants.PO_LI_QUANTITY);
po.getLineItem().add(li);
}
// create and initialize the shipper
Shipper shipper = new Shipper();
shipper.setName(Constants.PO_SHIPPER_NAME);
shipper.setPerOunceRate(Constants.PO_SHIPPER_POR);
po.setShipper(shipper);
// calculate a hash to return
int hash = (po.getLineItem().size()) * 17;
return hash;
}
Aggregations