Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
fix: Update the PriceBook prices endpoint to support pagination (#610)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Field <robertfield@quadrimular.com>
  • Loading branch information
petro97 and field123 authored Apr 20, 2022
1 parent b4d8515 commit 164f561
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 15 deletions.
14 changes: 13 additions & 1 deletion src/endpoints/price-book-prices.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ class PriceBookPricesEndpoint {

// TODO: API - currently not working! (can get from pricebook relationships)
All({ pricebookId, token = null }) {
const { filter } = this
const { limit, offset, filter } = this

return this.request.send(
buildURL(`pricebooks/${pricebookId}/${this.endpoint}`, {
limit,
offset,
filter
}),
'GET',
Expand All @@ -29,6 +31,16 @@ class PriceBookPricesEndpoint {
return this
}

Limit(value) {
this.limit = value
return this
}

Offset(value) {
this.offset = value
return this
}

Get({ pricebookId, priceId, token = null }) {
return this.request.send(
`pricebooks/${pricebookId}/${this.endpoint}/${priceId}`,
Expand Down
45 changes: 31 additions & 14 deletions src/types/price-book-prices.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
CrudQueryableResource,
Identifiable,
Resource, ResourceList
Resource, ResourcePage
} from './core'

export interface PriceBookPriceBase {
Expand Down Expand Up @@ -43,13 +44,38 @@ export interface PriceBookPriceBase {
}
}

export interface PriceBookPricesCreateBody {
options: {
pricebookId: string
body: PriceBookPriceBase
token?: string
}
}

export interface PriceBookPricesUpdateBody {
options: {
pricebookId: string
priceId: string
body: Identifiable & PriceBookPrice
token?: string
}
}

export interface PriceBookPrice extends Identifiable, PriceBookPriceBase {
relationships: {}
}

export interface PricesFilter {}

export interface PriceBookPricesEndpoint {
export interface PriceBookPricesEndpoint
extends Omit<CrudQueryableResource<
PriceBookPrice,
PriceBookPricesCreateBody,
PriceBookPricesUpdateBody,
PricesFilter,
never,
never
>, 'Get' | 'All' | 'Filter' | 'Create' | 'Update' | 'Delete'> {
endpoint: 'prices'

Get(options: {
Expand All @@ -62,22 +88,13 @@ export interface PriceBookPricesEndpoint {
All(options: {
pricebookId: string
token?: string
}): Promise<ResourceList<PriceBookPrice>>
}): Promise<ResourcePage<PriceBookPrice>>

Filter(filter: PricesFilter): PriceBookPricesEndpoint

Create(options: {
pricebookId: string
body: PriceBookPriceBase
token?: string
}): Promise<Resource<PriceBookPrice>>
Create(PriceBookPricesCreateBody): Promise<Resource<PriceBookPrice>>

Update(options: {
pricebookId: string
priceId: string
body: Identifiable & PriceBookPrice
token?: string
}): Promise<Resource<PriceBookPrice>>
Update(PriceBookPricesUpdateBody): Promise<Resource<PriceBookPrice>>

Delete(options: {
pricebookId: string
Expand Down

0 comments on commit 164f561

Please sign in to comment.