uspto-patents-view-api
Version:
An api wrapper for the patent view api run by the uspto
33 lines (28 loc) • 678 B
text/typescript
export interface BuildArgs {
and?: SearchTerm[];
or?: SearchTerm[];
}
export interface SearchTerm {
[]: {
[]: string;
};
}
export interface QueryObject {
[]: SearchTerm[];
}
export abstract class QueryBuilder {
static build(args: BuildArgs): QueryObject {
if (args.and) {
return this.generateQuery('_and', args.and);
}
if (args.or) {
return this.generateQuery('_or', args.or);
}
throw Error('Need to supply some search paramter');
}
private static generateQuery(type: string, searchTerms: SearchTerm[]) {
return {
[]: searchTerms
};
}
}