node-paymo-api 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +6 -0
- package/README.md +24 -1
- package/dist/abstract.d.ts +23 -0
- package/dist/abstract.js +210 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +18 -0
- package/dist/remote.d.ts +9 -0
- package/dist/remote.js +80 -0
- package/dist/resources/_template_/index.d.ts +18 -0
- package/dist/resources/_template_/index.js +34 -0
- package/dist/resources/_template_/types.d.ts +25 -0
- package/dist/resources/_template_/types.js +2 -0
- package/dist/resources/bookings/index.d.ts +18 -0
- package/dist/resources/bookings/index.js +49 -0
- package/dist/resources/bookings/types.d.ts +49 -0
- package/dist/resources/bookings/types.js +2 -0
- package/dist/resources/clientcontacts/index.d.ts +18 -0
- package/dist/resources/clientcontacts/index.js +34 -0
- package/dist/resources/clientcontacts/types.d.ts +59 -0
- package/dist/resources/clientcontacts/types.js +2 -0
- package/dist/resources/clients/index.d.ts +18 -0
- package/dist/resources/clients/index.js +34 -0
- package/dist/resources/clients/types.d.ts +71 -0
- package/dist/resources/clients/types.js +2 -0
- package/dist/resources/comments/Comments.d.ts +18 -0
- package/dist/resources/comments/Comments.js +34 -0
- package/dist/resources/comments/Threads.d.ts +28 -0
- package/dist/resources/comments/Threads.js +25 -0
- package/dist/resources/comments/index.d.ts +2 -0
- package/dist/resources/comments/index.js +7 -0
- package/dist/resources/comments/types.d.ts +77 -0
- package/dist/resources/comments/types.js +2 -0
- package/dist/resources/company/index.d.ts +12 -0
- package/dist/resources/company/index.js +25 -0
- package/dist/resources/company/types.d.ts +44 -0
- package/dist/resources/company/types.js +2 -0
- package/dist/resources/discussions/index.d.ts +18 -0
- package/dist/resources/discussions/index.js +34 -0
- package/dist/resources/discussions/types.d.ts +43 -0
- package/dist/resources/discussions/types.js +2 -0
- package/dist/resources/entries/index.d.ts +18 -0
- package/dist/resources/entries/index.js +47 -0
- package/dist/resources/entries/types.d.ts +53 -0
- package/dist/resources/entries/types.js +2 -0
- package/dist/resources/estimates/EstimateItem.d.ts +3 -0
- package/dist/resources/estimates/EstimateItem.js +5 -0
- package/dist/resources/estimates/Estimates.d.ts +18 -0
- package/dist/resources/estimates/Estimates.js +34 -0
- package/dist/resources/estimates/index.d.ts +2 -0
- package/dist/resources/estimates/index.js +7 -0
- package/dist/resources/estimates/types.d.ts +76 -0
- package/dist/resources/estimates/types.js +2 -0
- package/dist/resources/estimatetemplates/index.d.ts +18 -0
- package/dist/resources/estimatetemplates/index.js +34 -0
- package/dist/resources/estimatetemplates/types.d.ts +34 -0
- package/dist/resources/estimatetemplates/types.js +2 -0
- package/dist/resources/expenses/index.d.ts +18 -0
- package/dist/resources/expenses/index.js +34 -0
- package/dist/resources/expenses/types.d.ts +46 -0
- package/dist/resources/expenses/types.js +2 -0
- package/dist/resources/files/index.d.ts +18 -0
- package/dist/resources/files/index.js +45 -0
- package/dist/resources/files/types.d.ts +44 -0
- package/dist/resources/files/types.js +2 -0
- package/dist/resources/index.d.ts +117 -0
- package/dist/resources/index.js +200 -0
- package/dist/resources/invoices/InvoiceItem.d.ts +3 -0
- package/dist/resources/invoices/InvoiceItem.js +5 -0
- package/dist/resources/invoices/Invoices.d.ts +18 -0
- package/dist/resources/invoices/Invoices.js +34 -0
- package/dist/resources/invoices/index.d.ts +2 -0
- package/dist/resources/invoices/index.js +7 -0
- package/dist/resources/invoices/types.d.ts +87 -0
- package/dist/resources/invoices/types.js +2 -0
- package/dist/resources/invoicetemplates/index.d.ts +18 -0
- package/dist/resources/invoicetemplates/index.js +34 -0
- package/dist/resources/invoicetemplates/types.d.ts +34 -0
- package/dist/resources/invoicetemplates/types.js +2 -0
- package/dist/resources/milestones/index.d.ts +18 -0
- package/dist/resources/milestones/index.js +34 -0
- package/dist/resources/milestones/types.d.ts +40 -0
- package/dist/resources/milestones/types.js +2 -0
- package/dist/resources/projects/index.d.ts +20 -0
- package/dist/resources/projects/index.js +39 -0
- package/dist/resources/projects/types.d.ts +86 -0
- package/dist/resources/projects/types.js +14 -0
- package/dist/resources/projectstatuses/index.d.ts +18 -0
- package/dist/resources/projectstatuses/index.js +34 -0
- package/dist/resources/projectstatuses/types.d.ts +32 -0
- package/dist/resources/projectstatuses/types.js +2 -0
- package/dist/resources/projecttemplates/index.d.ts +18 -0
- package/dist/resources/projecttemplates/index.js +34 -0
- package/dist/resources/projecttemplates/types.d.ts +29 -0
- package/dist/resources/projecttemplates/types.js +2 -0
- package/dist/resources/reports/index.d.ts +18 -0
- package/dist/resources/reports/index.js +34 -0
- package/dist/resources/reports/types.d.ts +90 -0
- package/dist/resources/reports/types.js +2 -0
- package/dist/resources/sessions/index.d.ts +18 -0
- package/dist/resources/sessions/index.js +35 -0
- package/dist/resources/sessions/types.d.ts +28 -0
- package/dist/resources/sessions/types.js +2 -0
- package/dist/resources/tasklists/index.d.ts +18 -0
- package/dist/resources/tasklists/index.js +34 -0
- package/dist/resources/tasklists/types.d.ts +35 -0
- package/dist/resources/tasklists/types.js +2 -0
- package/dist/resources/tasks/index.d.ts +18 -0
- package/dist/resources/tasks/index.js +34 -0
- package/dist/resources/tasks/types.d.ts +64 -0
- package/dist/resources/tasks/types.js +2 -0
- package/dist/resources/users/index.d.ts +22 -0
- package/dist/resources/users/index.js +40 -0
- package/dist/resources/users/types.d.ts +86 -0
- package/dist/resources/users/types.js +2 -0
- package/dist/resources/usertasks/index.d.ts +18 -0
- package/dist/resources/usertasks/index.js +41 -0
- package/dist/resources/usertasks/types.d.ts +31 -0
- package/dist/resources/usertasks/types.js +2 -0
- package/dist/resources/workflows/index.d.ts +18 -0
- package/dist/resources/workflows/index.js +34 -0
- package/dist/resources/workflows/types.d.ts +31 -0
- package/dist/resources/workflows/types.js +2 -0
- package/dist/resources/workflowstatuses/index.d.ts +18 -0
- package/dist/resources/workflowstatuses/index.js +34 -0
- package/dist/resources/workflowstatuses/types.d.ts +35 -0
- package/dist/resources/workflowstatuses/types.js +2 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.js +2 -0
- package/package.json +13 -3
- package/src/abstract.ts +220 -0
- package/src/index.ts +23 -0
- package/src/remote.ts +77 -0
- package/src/resources/_template_/index.ts +38 -0
- package/src/resources/_template_/types.ts +40 -0
- package/src/resources/bookings/index.ts +61 -0
- package/src/resources/bookings/types.ts +60 -0
- package/src/resources/clientcontacts/index.ts +38 -0
- package/src/resources/clientcontacts/types.ts +69 -0
- package/src/resources/clients/index.ts +38 -0
- package/src/resources/clients/types.ts +100 -0
- package/src/resources/comments/Comments.ts +38 -0
- package/src/resources/comments/Threads.ts +28 -0
- package/src/resources/comments/index.ts +2 -0
- package/src/resources/comments/types.ts +105 -0
- package/src/resources/company/index.ts +23 -0
- package/src/resources/company/types.ts +52 -0
- package/src/resources/discussions/index.ts +38 -0
- package/src/resources/discussions/types.ts +53 -0
- package/src/resources/entries/index.ts +52 -0
- package/src/resources/entries/types.ts +67 -0
- package/src/resources/estimates/EstimateItem.ts +6 -0
- package/src/resources/estimates/Estimates.ts +38 -0
- package/src/resources/estimates/index.ts +2 -0
- package/src/resources/estimates/types.ts +89 -0
- package/src/resources/estimatetemplates/index.ts +38 -0
- package/src/resources/estimatetemplates/types.ts +46 -0
- package/src/resources/expenses/index.ts +38 -0
- package/src/resources/expenses/types.ts +58 -0
- package/src/resources/files/index.ts +50 -0
- package/src/resources/files/types.ts +58 -0
- package/src/resources/index.ts +289 -0
- package/src/resources/invoices/InvoiceItem.ts +6 -0
- package/src/resources/invoices/Invoices.ts +38 -0
- package/src/resources/invoices/index.ts +2 -0
- package/src/resources/invoices/types.ts +102 -0
- package/src/resources/invoicetemplates/index.ts +38 -0
- package/src/resources/invoicetemplates/types.ts +46 -0
- package/src/resources/milestones/index.ts +38 -0
- package/src/resources/milestones/types.ts +52 -0
- package/src/resources/projects/index.ts +47 -0
- package/src/resources/projects/types.ts +134 -0
- package/src/resources/projectstatuses/index.ts +38 -0
- package/src/resources/projectstatuses/types.ts +44 -0
- package/src/resources/projecttemplates/index.ts +40 -0
- package/src/resources/projecttemplates/types.ts +43 -0
- package/src/resources/reports/index.ts +38 -0
- package/src/resources/reports/types.ts +104 -0
- package/src/resources/sessions/index.ts +39 -0
- package/src/resources/sessions/types.ts +43 -0
- package/src/resources/tasklists/index.ts +38 -0
- package/src/resources/tasklists/types.ts +48 -0
- package/src/resources/tasks/index.ts +38 -0
- package/src/resources/tasks/types.ts +76 -0
- package/src/resources/users/index.ts +48 -0
- package/src/resources/users/types.ts +124 -0
- package/src/resources/usertasks/index.ts +46 -0
- package/src/resources/usertasks/types.ts +43 -0
- package/src/resources/workflows/index.ts +38 -0
- package/src/resources/workflows/types.ts +43 -0
- package/src/resources/workflowstatuses/index.ts +38 -0
- package/src/resources/workflowstatuses/types.ts +47 -0
- package/src/types.ts +40 -0
- package/tsconfig.json +12 -0
- package/lib/index.ts +0 -6
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { FilterOperator, GenericListConfig, Merge, PaymoCurrency } from "../../types"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// PAYMO API DOCS - 2019-12-11 /estimates /estimates/####
|
|
5
|
+
// =================================================================================================
|
|
6
|
+
|
|
7
|
+
export interface EstimatesTypeRead {
|
|
8
|
+
readonly id: number
|
|
9
|
+
readonly created_on: string
|
|
10
|
+
readonly updated_on: string
|
|
11
|
+
readonly subtotal : number
|
|
12
|
+
readonly total : number
|
|
13
|
+
readonly tax_amount : number
|
|
14
|
+
readonly tax2_amount : number
|
|
15
|
+
readonly permalink : string
|
|
16
|
+
readonly pdf_link : string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface EstimatesTypeUpdate {
|
|
20
|
+
number?: string
|
|
21
|
+
client_id?: number
|
|
22
|
+
template_id?: number
|
|
23
|
+
status?: 'draft' | 'sent' | 'viewed' |'accepted' | 'invoiced' | 'void'
|
|
24
|
+
currency?: PaymoCurrency
|
|
25
|
+
date?: string
|
|
26
|
+
tax?: number
|
|
27
|
+
tax2?: number
|
|
28
|
+
tax_on_tax?: boolean
|
|
29
|
+
bill_to?: string
|
|
30
|
+
company_info?: string
|
|
31
|
+
footer?: string
|
|
32
|
+
notes?: string
|
|
33
|
+
tax_text?:string
|
|
34
|
+
tax2_text?:string
|
|
35
|
+
title?:string
|
|
36
|
+
invoice_id?:number
|
|
37
|
+
estimateitems?: EstimateItemTypeCreate[] // Not sure if this is how you update items or not !
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type EstimatesTypeResponse = Merge<EstimatesTypeUpdate, Merge<EstimatesTypeRead, {
|
|
41
|
+
estimateitems?: EstimateItemTypeRead[]
|
|
42
|
+
}>>
|
|
43
|
+
|
|
44
|
+
export interface EstimatesTypeCreate extends EstimatesTypeUpdate {
|
|
45
|
+
client_id: number
|
|
46
|
+
currency: PaymoCurrency
|
|
47
|
+
items?:EstimateItemTypeCreate[]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface EstimatesTypeFilter extends EstimatesTypeUpdate {
|
|
51
|
+
created_on?: string
|
|
52
|
+
updated_on?: string
|
|
53
|
+
subtotal?: number
|
|
54
|
+
total?: number
|
|
55
|
+
tax_amount?: number
|
|
56
|
+
tax2_amount?: number
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface EstimatesFilterCondition extends EstimatesTypeFilter {
|
|
60
|
+
_custom?: {
|
|
61
|
+
[k: string]: {
|
|
62
|
+
key?: Extract<keyof EstimatesTypeFilter, string>
|
|
63
|
+
operator?:FilterOperator
|
|
64
|
+
value: string | number | boolean | null | number[]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface EstimatesListConfig extends GenericListConfig {
|
|
70
|
+
filter?:EstimatesFilterCondition
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface EstimateItemTypeCreate {
|
|
74
|
+
item: string
|
|
75
|
+
description: string
|
|
76
|
+
price_unit: number
|
|
77
|
+
quantity: number
|
|
78
|
+
apply_tax?: boolean
|
|
79
|
+
seq?: number | null
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface EstimateItemTypeRead extends EstimateItemTypeCreate {
|
|
83
|
+
readonly id: number
|
|
84
|
+
readonly estimate_id: number
|
|
85
|
+
apply_tax: boolean
|
|
86
|
+
seq: number | null
|
|
87
|
+
readonly created_on: string
|
|
88
|
+
readonly updated_on: string
|
|
89
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AbstractResource, AbstractResourceInterface } from '../../abstract'
|
|
2
|
+
import { AuthInterface } from "../../types"
|
|
3
|
+
import { EstimateTemplatesListConfig, EstimateTemplatesTypeCreate, EstimateTemplatesTypeResponse, EstimateTemplatesTypeUpdate } from "./types"
|
|
4
|
+
|
|
5
|
+
export interface EstimateTemplatesHandler extends AbstractResourceInterface {
|
|
6
|
+
get: (id: number) => Promise<EstimateTemplatesTypeResponse | null>
|
|
7
|
+
list: (config?: EstimateTemplatesListConfig) => Promise<EstimateTemplatesTypeResponse[]>
|
|
8
|
+
create: (d: EstimateTemplatesTypeCreate) => Promise<EstimateTemplatesTypeResponse | null>
|
|
9
|
+
update: (id: number, data: EstimateTemplatesTypeUpdate) => Promise<EstimateTemplatesTypeResponse | null>
|
|
10
|
+
delete: (id: number) => Promise<boolean>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class EstimateTemplates extends AbstractResource implements EstimateTemplatesHandler {
|
|
14
|
+
constructor(auth: AuthInterface) {
|
|
15
|
+
super(auth, 'estimatetemplates')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get = async (id: number) => {
|
|
19
|
+
return (await this.baseGet(id)) as EstimateTemplatesTypeResponse | null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
list = async (config: EstimateTemplatesListConfig = {}) => {
|
|
23
|
+
return (await this.baseList(config)) as EstimateTemplatesTypeResponse[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
create = async (data: EstimateTemplatesTypeCreate) => {
|
|
27
|
+
return (await this.baseCreate(data)) as EstimateTemplatesTypeResponse | null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
update = async (id: number, data: EstimateTemplatesTypeUpdate) => {
|
|
31
|
+
return (await this.baseUpdate(id, data)) as EstimateTemplatesTypeResponse | null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
delete = async (id: number) => {
|
|
35
|
+
return await this.baseDelete(id)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FilterOperator, GenericListConfig, Merge } from "../../types"
|
|
2
|
+
|
|
3
|
+
// PAYMO API DOCS - 2019-12-11 /estimatetemplates /estimatetemplates/####
|
|
4
|
+
// =================================================================================================
|
|
5
|
+
|
|
6
|
+
export interface EstimateTemplatesTypeRead {
|
|
7
|
+
readonly id: number
|
|
8
|
+
readonly created_on: string
|
|
9
|
+
readonly updated_on: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface EstimateTemplatesTypeUpdate {
|
|
13
|
+
name?:string
|
|
14
|
+
title?:string
|
|
15
|
+
html?:string
|
|
16
|
+
css?:string
|
|
17
|
+
is_default?:boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type EstimateTemplatesTypeResponse = Merge<EstimateTemplatesTypeUpdate, Merge<EstimateTemplatesTypeRead, {
|
|
21
|
+
|
|
22
|
+
}>>
|
|
23
|
+
|
|
24
|
+
export interface EstimateTemplatesTypeCreate extends EstimateTemplatesTypeUpdate {
|
|
25
|
+
name: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface EstimateTemplatesTypeFilter {
|
|
29
|
+
id?:number
|
|
30
|
+
name?: string
|
|
31
|
+
is_default?: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface EstimateTemplatesFilterCondition extends EstimateTemplatesTypeFilter {
|
|
35
|
+
_custom?: {
|
|
36
|
+
[k: string]: {
|
|
37
|
+
key?: Extract<keyof EstimateTemplatesTypeFilter, string>
|
|
38
|
+
operator?:FilterOperator
|
|
39
|
+
value: string | number | boolean | null | number[]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface EstimateTemplatesListConfig extends GenericListConfig {
|
|
45
|
+
filter?:EstimateTemplatesFilterCondition
|
|
46
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AbstractResource, AbstractResourceInterface } from '../../abstract'
|
|
2
|
+
import { AuthInterface } from "../../types"
|
|
3
|
+
import { ExpensesListConfig, ExpensesTypeCreate, ExpensesTypeResponse, ExpensesTypeUpdate } from "./types"
|
|
4
|
+
|
|
5
|
+
export interface ExpensesHandler extends AbstractResourceInterface {
|
|
6
|
+
get: (id: number) => Promise<ExpensesTypeResponse | null>
|
|
7
|
+
list: (config?: ExpensesListConfig) => Promise<ExpensesTypeResponse[]>
|
|
8
|
+
create: (d: ExpensesTypeCreate) => Promise<ExpensesTypeResponse | null>
|
|
9
|
+
update: (id: number, data: ExpensesTypeUpdate) => Promise<ExpensesTypeResponse | null>
|
|
10
|
+
delete: (id: number) => Promise<boolean>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class Expenses extends AbstractResource implements ExpensesHandler {
|
|
14
|
+
constructor(auth: AuthInterface) {
|
|
15
|
+
super(auth, 'expenses')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get = async (id: number) => {
|
|
19
|
+
return (await this.baseGet(id)) as ExpensesTypeResponse | null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
list = async (config: ExpensesListConfig = {}) => {
|
|
23
|
+
return (await this.baseList(config)) as ExpensesTypeResponse[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
create = async (data: ExpensesTypeCreate) => {
|
|
27
|
+
return (await this.baseCreate(data)) as ExpensesTypeResponse | null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
update = async (id: number, data: ExpensesTypeUpdate) => {
|
|
31
|
+
return (await this.baseUpdate(id, data)) as ExpensesTypeResponse | null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
delete = async (id: number) => {
|
|
35
|
+
return await this.baseDelete(id)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { FilterOperator, GenericListConfig, Merge, PaymoCurrency } from "../../types"
|
|
2
|
+
|
|
3
|
+
// PAYMO API DOCS - 2019-12-11 /expenses /expenses/####
|
|
4
|
+
// =================================================================================================
|
|
5
|
+
|
|
6
|
+
export interface ExpensesTypeRead {
|
|
7
|
+
readonly id: number
|
|
8
|
+
readonly created_on: string
|
|
9
|
+
readonly updated_on: string
|
|
10
|
+
readonly image_thumb_large?: string
|
|
11
|
+
readonly image_thumb_medium?: string
|
|
12
|
+
readonly image_thumb_small?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ExpensesTypeUpdate {
|
|
16
|
+
client_id?: number
|
|
17
|
+
project_id?: number
|
|
18
|
+
user_id?: number
|
|
19
|
+
amount?: number
|
|
20
|
+
currency?: PaymoCurrency
|
|
21
|
+
date?: string
|
|
22
|
+
notes?: string
|
|
23
|
+
invoiced?: boolean
|
|
24
|
+
invoice_item_id?: number
|
|
25
|
+
tags?: string[]
|
|
26
|
+
file?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type ExpensesTypeResponse = Merge<ExpensesTypeUpdate, Merge<ExpensesTypeRead, {
|
|
30
|
+
|
|
31
|
+
}>>
|
|
32
|
+
|
|
33
|
+
export interface ExpensesTypeCreate extends ExpensesTypeUpdate {
|
|
34
|
+
client_id: number
|
|
35
|
+
currency: PaymoCurrency
|
|
36
|
+
amount: number
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ExpensesTypeFilter {
|
|
40
|
+
client_id?: number
|
|
41
|
+
project_id?: number
|
|
42
|
+
user_id?: number
|
|
43
|
+
invoice_item_id?: number
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ExpensesFilterCondition extends ExpensesTypeFilter {
|
|
47
|
+
_custom?: {
|
|
48
|
+
[k: string]: {
|
|
49
|
+
key?: Extract<keyof ExpensesTypeFilter, string>
|
|
50
|
+
operator?:FilterOperator
|
|
51
|
+
value: string | number | boolean | null | number[]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface ExpensesListConfig extends GenericListConfig {
|
|
57
|
+
filter?:ExpensesFilterCondition
|
|
58
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AbstractResource, AbstractResourceInterface } from '../../abstract'
|
|
2
|
+
import { AuthInterface } from "../../types"
|
|
3
|
+
import { FilesListConfig, FilesTypeCreate, FilesTypeResponse, FilesTypeUpdate } from "./types"
|
|
4
|
+
|
|
5
|
+
export interface FilesHandler extends AbstractResourceInterface {
|
|
6
|
+
get: (id: number) => Promise<FilesTypeResponse | null>
|
|
7
|
+
list: (config?: FilesListConfig) => Promise<FilesTypeResponse[]>
|
|
8
|
+
create: (d: FilesTypeCreate) => Promise<FilesTypeResponse | null>
|
|
9
|
+
update: (id: number, data: FilesTypeUpdate) => Promise<FilesTypeResponse | null>
|
|
10
|
+
delete: (id: number) => Promise<boolean>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class Files extends AbstractResource implements FilesHandler {
|
|
14
|
+
constructor(auth: AuthInterface) {
|
|
15
|
+
super(auth, 'files')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get = async (id: number) => {
|
|
19
|
+
return (await this.baseGet(id)) as FilesTypeResponse | null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
list = async (config: FilesListConfig = {}) => {
|
|
23
|
+
const validConfig =
|
|
24
|
+
!!config &&
|
|
25
|
+
config.filter &&
|
|
26
|
+
(config.filter.project_id ||
|
|
27
|
+
config.filter.task_id ||
|
|
28
|
+
config.filter.discussion_id ||
|
|
29
|
+
config.filter.comment_id)
|
|
30
|
+
if (!validConfig) {
|
|
31
|
+
console.log('File list requires at least one valid filter condition')
|
|
32
|
+
return []
|
|
33
|
+
}
|
|
34
|
+
return (await this.baseList(config)) as FilesTypeResponse[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Does not work yet, needs multipart upload system
|
|
38
|
+
create = async (data: FilesTypeCreate) => {
|
|
39
|
+
return (await this.baseCreate(data)) as FilesTypeResponse | null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
update = async (id: number, data: FilesTypeUpdate) => {
|
|
43
|
+
return (await this.baseUpdate(id, data)) as FilesTypeResponse | null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
delete = async (id: number) => {
|
|
47
|
+
return await this.baseDelete(id)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { FilterOperator, GenericListConfig, Merge } from "../../types"
|
|
2
|
+
|
|
3
|
+
// PAYMO API DOCS - 2019-12-11 /files /files/####
|
|
4
|
+
// =================================================================================================
|
|
5
|
+
|
|
6
|
+
export interface FilesTypeRead {
|
|
7
|
+
readonly id: number
|
|
8
|
+
readonly created_on: string
|
|
9
|
+
readonly updated_on: string
|
|
10
|
+
readonly user_id: number | null
|
|
11
|
+
readonly project_id: number | null
|
|
12
|
+
readonly discussion_id: number | null
|
|
13
|
+
readonly task_id: number | null
|
|
14
|
+
readonly comment_id: number | null
|
|
15
|
+
readonly token: string
|
|
16
|
+
readonly size: number
|
|
17
|
+
readonly mime: string
|
|
18
|
+
readonly file: string
|
|
19
|
+
readonly image_thumb_large?: string
|
|
20
|
+
readonly image_thumb_medium?: string
|
|
21
|
+
readonly image_thumb_small?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface FilesTypeUpdate {
|
|
25
|
+
original_filename?: string
|
|
26
|
+
description?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type FilesTypeResponse = Merge<FilesTypeUpdate, Merge<FilesTypeRead, {
|
|
30
|
+
|
|
31
|
+
}>>
|
|
32
|
+
|
|
33
|
+
// This is not the actual CREATE type as it is a multi-part upload
|
|
34
|
+
export interface FilesTypeCreate extends FilesTypeUpdate {
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface FilesTypeFilter {
|
|
39
|
+
original_filename?: string
|
|
40
|
+
project_id?: number
|
|
41
|
+
discussion_id?: number
|
|
42
|
+
task_id?: number
|
|
43
|
+
comment_id?: number
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface FilesFilterCondition extends FilesTypeFilter {
|
|
47
|
+
_custom?: {
|
|
48
|
+
[k: string]: {
|
|
49
|
+
key?: Extract<keyof FilesTypeFilter, string>
|
|
50
|
+
operator?:FilterOperator
|
|
51
|
+
value: string | number | boolean | null | number[]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface FilesListConfig extends GenericListConfig {
|
|
57
|
+
filter?:FilesFilterCondition
|
|
58
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { AuthInterface } from '../types'
|
|
2
|
+
import { Projects, ProjectsHandler } from './projects'
|
|
3
|
+
import { Clients, ClientsHandler } from './clients'
|
|
4
|
+
import { Users, UsersHandler } from "./users"
|
|
5
|
+
import { Bookings, BookingsHandler } from "./bookings"
|
|
6
|
+
import { ClientContacts, ClientContactsHandler } from "./clientcontacts"
|
|
7
|
+
import { Comments, CommentsHandler, Threads, ThreadsHandler } from "./comments"
|
|
8
|
+
import { Company, CompanyHandler } from "./company"
|
|
9
|
+
import { Discussions, DiscussionsHandler } from "./discussions"
|
|
10
|
+
import { EstimateTemplates, EstimateTemplatesHandler } from "./estimatetemplates"
|
|
11
|
+
import { Estimates, EstimatesHandler } from "./estimates"
|
|
12
|
+
import { Expenses, ExpensesHandler } from "./expenses"
|
|
13
|
+
import { Files, FilesHandler } from "./files"
|
|
14
|
+
import { InvoiceTemplates, InvoiceTemplatesHandler } from "./invoicetemplates"
|
|
15
|
+
import { Invoices, InvoicesHandler } from "./invoices"
|
|
16
|
+
import { Milestones, MilestonesHandler } from "./milestones"
|
|
17
|
+
import { ProjectTemplates, ProjectTemplatesHandler } from "./projecttemplates"
|
|
18
|
+
import { ProjectStatuses, ProjectStatusesHandler } from "./projectstatuses"
|
|
19
|
+
import { Reports, ReportsHandler } from "./reports"
|
|
20
|
+
import { Sessions, SessionsHandler } from "./sessions"
|
|
21
|
+
import { TaskLists, TaskListsHandler } from "./tasklists"
|
|
22
|
+
import { Tasks, TasksHandler } from "./tasks"
|
|
23
|
+
import { TimeEntries, TimeEntriesHandler } from "./entries"
|
|
24
|
+
import { UserTasks, UserTasksHandler } from "./usertasks"
|
|
25
|
+
import { Workflows, WorkflowsHandler } from "./workflows"
|
|
26
|
+
import { WorkflowStatuses, WorkflowStatusesHandler } from "./workflowstatuses"
|
|
27
|
+
|
|
28
|
+
export interface PaymoHandlersContainerInterface {
|
|
29
|
+
projects?: ProjectsHandler
|
|
30
|
+
clients?: ClientsHandler
|
|
31
|
+
users?: UsersHandler
|
|
32
|
+
bookings?: BookingsHandler
|
|
33
|
+
clientcontacts?: ClientContacts
|
|
34
|
+
comments?: Comments
|
|
35
|
+
threads?: Threads
|
|
36
|
+
company?: Company
|
|
37
|
+
discussions?: Discussions
|
|
38
|
+
estimatetemplates?: EstimateTemplates
|
|
39
|
+
estimates?: Estimates
|
|
40
|
+
expenses?: Expenses
|
|
41
|
+
files?: Files
|
|
42
|
+
invoicetemplates?: InvoiceTemplates
|
|
43
|
+
invoices?: Invoices
|
|
44
|
+
milestones?: Milestones
|
|
45
|
+
projecttemplates?: ProjectTemplates
|
|
46
|
+
projectstatuses?: ProjectStatuses
|
|
47
|
+
reports?: Reports
|
|
48
|
+
sessions?: Sessions
|
|
49
|
+
tasklists?: TaskLists
|
|
50
|
+
tasks?: Tasks
|
|
51
|
+
entries?: TimeEntries
|
|
52
|
+
usertasks?: UserTasks
|
|
53
|
+
workflows?: Workflows
|
|
54
|
+
workflowstatuses?: WorkflowStatuses
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface PaymoResourceHandlerInterface {
|
|
58
|
+
isApiUser: (a: string) => boolean
|
|
59
|
+
projects: () => ProjectsHandler
|
|
60
|
+
clients: () => ClientsHandler
|
|
61
|
+
users: () => UsersHandler
|
|
62
|
+
bookings: () => BookingsHandler
|
|
63
|
+
clientcontacts: () => ClientContactsHandler
|
|
64
|
+
comments: () => CommentsHandler
|
|
65
|
+
threads: () => ThreadsHandler
|
|
66
|
+
company: () => CompanyHandler
|
|
67
|
+
discussions: () => DiscussionsHandler
|
|
68
|
+
estimatetemplates: () => EstimateTemplatesHandler
|
|
69
|
+
estimates: () => EstimatesHandler
|
|
70
|
+
expenses: () => ExpensesHandler
|
|
71
|
+
files: () => FilesHandler
|
|
72
|
+
invoicetemplates: () => InvoiceTemplatesHandler
|
|
73
|
+
invoices: () => InvoicesHandler
|
|
74
|
+
milestones: () => MilestonesHandler
|
|
75
|
+
projecttemplates: ()=> ProjectTemplatesHandler
|
|
76
|
+
projectstatuses: () => ProjectStatusesHandler
|
|
77
|
+
reports: () => ReportsHandler
|
|
78
|
+
sessions: () => SessionsHandler
|
|
79
|
+
tasklists: ()=>TaskListsHandler
|
|
80
|
+
tasks: ()=>TasksHandler
|
|
81
|
+
entries: ()=>TimeEntriesHandler
|
|
82
|
+
usertasks: ()=>UserTasksHandler
|
|
83
|
+
workflows: ()=>WorkflowsHandler
|
|
84
|
+
workflowstatuses: ()=>WorkflowStatusesHandler
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const PaymoResourceHandler = class implements PaymoResourceHandlerInterface {
|
|
88
|
+
auth: AuthInterface = {
|
|
89
|
+
userApi: '',
|
|
90
|
+
password: '',
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
handlers: PaymoHandlersContainerInterface = {}
|
|
94
|
+
|
|
95
|
+
constructor(u: string, p: string | null) {
|
|
96
|
+
this.auth = {
|
|
97
|
+
userApi: u,
|
|
98
|
+
password: p || 'paymoApi',
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
isApiUser = (apiUser: string) => {
|
|
103
|
+
return this.auth.userApi === apiUser
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
projects = (): ProjectsHandler => {
|
|
107
|
+
if (!this.handlers.projects) {
|
|
108
|
+
this.handlers.projects = new Projects(this.auth)
|
|
109
|
+
}
|
|
110
|
+
return this.handlers.projects
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
clients = (): ClientsHandler => {
|
|
114
|
+
if (!this.handlers.clients) {
|
|
115
|
+
this.handlers.clients = new Clients(this.auth)
|
|
116
|
+
}
|
|
117
|
+
return this.handlers.clients
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
users = (): UsersHandler => {
|
|
121
|
+
if (!this.handlers.users) {
|
|
122
|
+
this.handlers.users = new Users(this.auth)
|
|
123
|
+
}
|
|
124
|
+
return this.handlers.users
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
bookings = (): BookingsHandler => {
|
|
128
|
+
if (!this.handlers.bookings) {
|
|
129
|
+
this.handlers.bookings = new Bookings(this.auth)
|
|
130
|
+
}
|
|
131
|
+
return this.handlers.bookings
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
clientcontacts = (): ClientContactsHandler => {
|
|
135
|
+
if (!this.handlers.clientcontacts) {
|
|
136
|
+
this.handlers.clientcontacts = new ClientContacts(this.auth)
|
|
137
|
+
}
|
|
138
|
+
return this.handlers.clientcontacts
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
comments = (): CommentsHandler => {
|
|
142
|
+
if (!this.handlers.comments) {
|
|
143
|
+
this.handlers.comments = new Comments(this.auth)
|
|
144
|
+
}
|
|
145
|
+
return this.handlers.comments
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
threads = (): ThreadsHandler => {
|
|
149
|
+
if (!this.handlers.threads) {
|
|
150
|
+
this.handlers.threads = new Threads(this.auth)
|
|
151
|
+
}
|
|
152
|
+
return this.handlers.threads
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
company = (): CompanyHandler => {
|
|
156
|
+
if (!this.handlers.company) {
|
|
157
|
+
this.handlers.company = new Company(this.auth)
|
|
158
|
+
}
|
|
159
|
+
return this.handlers.company
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
discussions = (): DiscussionsHandler => {
|
|
163
|
+
if (!this.handlers.discussions) {
|
|
164
|
+
this.handlers.discussions = new Discussions(this.auth)
|
|
165
|
+
}
|
|
166
|
+
return this.handlers.discussions
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
estimatetemplates = (): EstimateTemplatesHandler => {
|
|
170
|
+
if (!this.handlers.estimatetemplates) {
|
|
171
|
+
this.handlers.estimatetemplates = new EstimateTemplates(this.auth)
|
|
172
|
+
}
|
|
173
|
+
return this.handlers.estimatetemplates
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
estimates = (): EstimatesHandler => {
|
|
177
|
+
if (!this.handlers.estimates) {
|
|
178
|
+
this.handlers.estimates = new Estimates(this.auth)
|
|
179
|
+
}
|
|
180
|
+
return this.handlers.estimates
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
expenses = (): ExpensesHandler => {
|
|
184
|
+
if (!this.handlers.expenses) {
|
|
185
|
+
this.handlers.expenses = new Expenses(this.auth)
|
|
186
|
+
}
|
|
187
|
+
return this.handlers.expenses
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
files = (): FilesHandler => {
|
|
191
|
+
if (!this.handlers.files) {
|
|
192
|
+
this.handlers.files = new Files(this.auth)
|
|
193
|
+
}
|
|
194
|
+
return this.handlers.files
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
invoicetemplates = (): InvoiceTemplatesHandler => {
|
|
198
|
+
if (!this.handlers.invoicetemplates) {
|
|
199
|
+
this.handlers.invoicetemplates = new InvoiceTemplates(this.auth)
|
|
200
|
+
}
|
|
201
|
+
return this.handlers.invoicetemplates
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
invoices = (): InvoicesHandler => {
|
|
205
|
+
if (!this.handlers.invoices) {
|
|
206
|
+
this.handlers.invoices = new Invoices(this.auth)
|
|
207
|
+
}
|
|
208
|
+
return this.handlers.invoices
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
milestones = (): MilestonesHandler => {
|
|
212
|
+
if (!this.handlers.milestones) {
|
|
213
|
+
this.handlers.milestones = new Milestones(this.auth)
|
|
214
|
+
}
|
|
215
|
+
return this.handlers.milestones
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
projecttemplates = (): ProjectTemplatesHandler => {
|
|
219
|
+
if (!this.handlers.projecttemplates) {
|
|
220
|
+
this.handlers.projecttemplates = new ProjectTemplates(this.auth)
|
|
221
|
+
}
|
|
222
|
+
return this.handlers.projecttemplates
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
projectstatuses = (): ProjectStatusesHandler => {
|
|
226
|
+
if (!this.handlers.projectstatuses) {
|
|
227
|
+
this.handlers.projectstatuses = new ProjectStatuses(this.auth)
|
|
228
|
+
}
|
|
229
|
+
return this.handlers.projectstatuses
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
reports = (): ReportsHandler => {
|
|
233
|
+
if (!this.handlers.reports) {
|
|
234
|
+
this.handlers.reports = new Reports(this.auth)
|
|
235
|
+
}
|
|
236
|
+
return this.handlers.reports
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
sessions = (): SessionsHandler => {
|
|
240
|
+
if (!this.handlers.sessions) {
|
|
241
|
+
this.handlers.sessions = new Sessions(this.auth)
|
|
242
|
+
}
|
|
243
|
+
return this.handlers.sessions
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
tasklists = (): TaskListsHandler => {
|
|
247
|
+
if (!this.handlers.tasklists) {
|
|
248
|
+
this.handlers.tasklists = new TaskLists(this.auth)
|
|
249
|
+
}
|
|
250
|
+
return this.handlers.tasklists
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
tasks = (): TasksHandler => {
|
|
254
|
+
if (!this.handlers.tasks) {
|
|
255
|
+
this.handlers.tasks = new Tasks(this.auth)
|
|
256
|
+
}
|
|
257
|
+
return this.handlers.tasks
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
entries = (): TimeEntriesHandler => {
|
|
261
|
+
if (!this.handlers.entries) {
|
|
262
|
+
this.handlers.entries = new TimeEntries(this.auth)
|
|
263
|
+
}
|
|
264
|
+
return this.handlers.entries
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
usertasks = (): UserTasksHandler => {
|
|
268
|
+
if (!this.handlers.usertasks) {
|
|
269
|
+
this.handlers.usertasks = new UserTasks(this.auth)
|
|
270
|
+
}
|
|
271
|
+
return this.handlers.usertasks
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
workflows = (): WorkflowsHandler => {
|
|
275
|
+
if (!this.handlers.workflows) {
|
|
276
|
+
this.handlers.workflows = new Workflows(this.auth)
|
|
277
|
+
}
|
|
278
|
+
return this.handlers.workflows
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
workflowstatuses = (): WorkflowStatusesHandler => {
|
|
282
|
+
if (!this.handlers.workflowstatuses) {
|
|
283
|
+
this.handlers.workflowstatuses = new WorkflowStatuses(this.auth)
|
|
284
|
+
}
|
|
285
|
+
return this.handlers.workflowstatuses
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export default PaymoResourceHandler
|