Skip to content

Commit

Permalink
Merge pull request #5 from quantcdn/feat/meta-sorting
Browse files Browse the repository at this point in the history
Feat: Add sorting options for meta queries.
  • Loading branch information
steveworley authored Jan 10, 2024
2 parents 72a371a + bf2dd06 commit 02d5c0f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,18 @@ export class QuantClient {
* @returns Promise<any>
* The repsonse object.
*/
meta: async (): Promise<any> => {
return await this._project.get('global-meta')
meta: async (filters?: types.MetaFilters): Promise<any> => {
const qs: { sort_direction?: string, sort_field?: string } = {}

if (filters?.sort_direction != null) {
qs.sort_direction = filters.sort_direction
}

if (filters?.sort_field != null) {
qs.sort_field = filters.sort_field
}

return await this._project.get('global-meta', qs)
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Client {

export interface ProjectApi {
ping: () => Promise<any>
meta: () => Promise<any>
meta: (filter?: types.MetaFilters) => Promise<any>
markup: (payload: types.MarkupPayload) => Promise<any>
file: (payload: types.FilePayload) => Promise<any>
publish: (payload: types.PublishPayload) => Promise<any>
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ export interface WafLog {
method: string
user_agent: string
}

export interface MetaFilters {
sort_field: string
sort_direction: string
}

0 comments on commit 02d5c0f

Please sign in to comment.