![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@dmgt/google-ad-manager-api
Advanced tools
A fully typed library to access Google's Ad Manager.
npm install google-auth-library @dmgt/google-ad-manager-api
import {
GoogleAdManager,
In,
Not,
Like,
getByStatement,
} from '@dmgt/google-ad-manager-api'
import { JWT } from 'google-auth-lbrary'
const jwt = new JWT({
key: 'MY_JWT_KEY',
email: 'MY_JWT_EMAIL',
scopes: ['https://www.googleapis.com/auth/dfp'],
})
const api = new GoogleAdManager({
applicationName: 'MY_APPLICATION_NAME',
networkCode: 123456789,
authorize: () => jwt.authorize(),
})
const client = await api.createLineItemServiceClient()
const [response] = await getByStatement(client, 'lineItems', {
limit: 10,
where: {
orderId: In(1, 2, 3),
id: Not(11222),
name: Like('foo %'),
orderName: 'Foo',
},
})
expect(response.rval?.results).toHaveLength(10)
The following will produce the same result albeit more verbose:
import {
LineItemService,
In,
Not,
Like,
pql,
} from '@dmgt/google-ad-manager-api'
const [response] = await client.getLineItemsByStatementAsync({
filterStatement: {
query: pql<LineItemService.LineItems>({
limit: 10,
where: {
orderId: In(1, 2, 3),
id: Not(11222),
name: Like('foo %'),
orderName: 'Foo',
},
}),
},
})
You can also type the pql
function with JSDocs:
/**
* @typedef {import('@dmgt/google-ad-manager-api').PQL<
* import('@dmgt/google-ad-manager-api').LineItemService.LineItems
* >} LineItemsPQL
*/
const [response] = await client.getLineItemsByStatementAsync({
filterStatement: {
query: /** @type {LineItemsPQL} */ (pql)({
limit: 10,
where: {
orderId: In(1, 2, 3),
id: Not(11222),
name: Like('foo %'),
orderName: 'Foo',
},
}),
},
})
When quering large amounts of data, you'd generally want to use GAM's pagination feature. Use the iterate
function to help iterate through all individual items in paginated queries.
import {
GoogleAdManager,
iterate,
getByStatement,
} from '@dmgt/google-ad-manager-api'
import { JWT } from 'google-auth-lbrary'
const jwt = new JWT({
key: 'MY_JWT_KEY',
email: 'MY_JWT_EMAIL',
scopes: ['https://www.googleapis.com/auth/dfp'],
})
const api = new GoogleAdManager({
applicationName: 'MY_APPLICATION_NAME',
networkCode: 123456789,
authorize: () => jwt.authorize(),
})
const client = await api.createLineItemServiceClient()
for await (const result of iterate({
executeQuery: (limit, offset) =>
getByStatement(client, 'lineItems', {
limit,
offset,
}),
})) {
console.info(result)
}
FAQs
Typed Google Ad Manager API
The npm package @dmgt/google-ad-manager-api receives a total of 324 weekly downloads. As such, @dmgt/google-ad-manager-api popularity was classified as not popular.
We found that @dmgt/google-ad-manager-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.