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.
Files changed (194) hide show
  1. package/.prettierrc +6 -0
  2. package/README.md +24 -1
  3. package/dist/abstract.d.ts +23 -0
  4. package/dist/abstract.js +210 -0
  5. package/dist/index.d.ts +6 -0
  6. package/dist/index.js +18 -0
  7. package/dist/remote.d.ts +9 -0
  8. package/dist/remote.js +80 -0
  9. package/dist/resources/_template_/index.d.ts +18 -0
  10. package/dist/resources/_template_/index.js +34 -0
  11. package/dist/resources/_template_/types.d.ts +25 -0
  12. package/dist/resources/_template_/types.js +2 -0
  13. package/dist/resources/bookings/index.d.ts +18 -0
  14. package/dist/resources/bookings/index.js +49 -0
  15. package/dist/resources/bookings/types.d.ts +49 -0
  16. package/dist/resources/bookings/types.js +2 -0
  17. package/dist/resources/clientcontacts/index.d.ts +18 -0
  18. package/dist/resources/clientcontacts/index.js +34 -0
  19. package/dist/resources/clientcontacts/types.d.ts +59 -0
  20. package/dist/resources/clientcontacts/types.js +2 -0
  21. package/dist/resources/clients/index.d.ts +18 -0
  22. package/dist/resources/clients/index.js +34 -0
  23. package/dist/resources/clients/types.d.ts +71 -0
  24. package/dist/resources/clients/types.js +2 -0
  25. package/dist/resources/comments/Comments.d.ts +18 -0
  26. package/dist/resources/comments/Comments.js +34 -0
  27. package/dist/resources/comments/Threads.d.ts +28 -0
  28. package/dist/resources/comments/Threads.js +25 -0
  29. package/dist/resources/comments/index.d.ts +2 -0
  30. package/dist/resources/comments/index.js +7 -0
  31. package/dist/resources/comments/types.d.ts +77 -0
  32. package/dist/resources/comments/types.js +2 -0
  33. package/dist/resources/company/index.d.ts +12 -0
  34. package/dist/resources/company/index.js +25 -0
  35. package/dist/resources/company/types.d.ts +44 -0
  36. package/dist/resources/company/types.js +2 -0
  37. package/dist/resources/discussions/index.d.ts +18 -0
  38. package/dist/resources/discussions/index.js +34 -0
  39. package/dist/resources/discussions/types.d.ts +43 -0
  40. package/dist/resources/discussions/types.js +2 -0
  41. package/dist/resources/entries/index.d.ts +18 -0
  42. package/dist/resources/entries/index.js +47 -0
  43. package/dist/resources/entries/types.d.ts +53 -0
  44. package/dist/resources/entries/types.js +2 -0
  45. package/dist/resources/estimates/EstimateItem.d.ts +3 -0
  46. package/dist/resources/estimates/EstimateItem.js +5 -0
  47. package/dist/resources/estimates/Estimates.d.ts +18 -0
  48. package/dist/resources/estimates/Estimates.js +34 -0
  49. package/dist/resources/estimates/index.d.ts +2 -0
  50. package/dist/resources/estimates/index.js +7 -0
  51. package/dist/resources/estimates/types.d.ts +76 -0
  52. package/dist/resources/estimates/types.js +2 -0
  53. package/dist/resources/estimatetemplates/index.d.ts +18 -0
  54. package/dist/resources/estimatetemplates/index.js +34 -0
  55. package/dist/resources/estimatetemplates/types.d.ts +34 -0
  56. package/dist/resources/estimatetemplates/types.js +2 -0
  57. package/dist/resources/expenses/index.d.ts +18 -0
  58. package/dist/resources/expenses/index.js +34 -0
  59. package/dist/resources/expenses/types.d.ts +46 -0
  60. package/dist/resources/expenses/types.js +2 -0
  61. package/dist/resources/files/index.d.ts +18 -0
  62. package/dist/resources/files/index.js +45 -0
  63. package/dist/resources/files/types.d.ts +44 -0
  64. package/dist/resources/files/types.js +2 -0
  65. package/dist/resources/index.d.ts +117 -0
  66. package/dist/resources/index.js +200 -0
  67. package/dist/resources/invoices/InvoiceItem.d.ts +3 -0
  68. package/dist/resources/invoices/InvoiceItem.js +5 -0
  69. package/dist/resources/invoices/Invoices.d.ts +18 -0
  70. package/dist/resources/invoices/Invoices.js +34 -0
  71. package/dist/resources/invoices/index.d.ts +2 -0
  72. package/dist/resources/invoices/index.js +7 -0
  73. package/dist/resources/invoices/types.d.ts +87 -0
  74. package/dist/resources/invoices/types.js +2 -0
  75. package/dist/resources/invoicetemplates/index.d.ts +18 -0
  76. package/dist/resources/invoicetemplates/index.js +34 -0
  77. package/dist/resources/invoicetemplates/types.d.ts +34 -0
  78. package/dist/resources/invoicetemplates/types.js +2 -0
  79. package/dist/resources/milestones/index.d.ts +18 -0
  80. package/dist/resources/milestones/index.js +34 -0
  81. package/dist/resources/milestones/types.d.ts +40 -0
  82. package/dist/resources/milestones/types.js +2 -0
  83. package/dist/resources/projects/index.d.ts +20 -0
  84. package/dist/resources/projects/index.js +39 -0
  85. package/dist/resources/projects/types.d.ts +86 -0
  86. package/dist/resources/projects/types.js +14 -0
  87. package/dist/resources/projectstatuses/index.d.ts +18 -0
  88. package/dist/resources/projectstatuses/index.js +34 -0
  89. package/dist/resources/projectstatuses/types.d.ts +32 -0
  90. package/dist/resources/projectstatuses/types.js +2 -0
  91. package/dist/resources/projecttemplates/index.d.ts +18 -0
  92. package/dist/resources/projecttemplates/index.js +34 -0
  93. package/dist/resources/projecttemplates/types.d.ts +29 -0
  94. package/dist/resources/projecttemplates/types.js +2 -0
  95. package/dist/resources/reports/index.d.ts +18 -0
  96. package/dist/resources/reports/index.js +34 -0
  97. package/dist/resources/reports/types.d.ts +90 -0
  98. package/dist/resources/reports/types.js +2 -0
  99. package/dist/resources/sessions/index.d.ts +18 -0
  100. package/dist/resources/sessions/index.js +35 -0
  101. package/dist/resources/sessions/types.d.ts +28 -0
  102. package/dist/resources/sessions/types.js +2 -0
  103. package/dist/resources/tasklists/index.d.ts +18 -0
  104. package/dist/resources/tasklists/index.js +34 -0
  105. package/dist/resources/tasklists/types.d.ts +35 -0
  106. package/dist/resources/tasklists/types.js +2 -0
  107. package/dist/resources/tasks/index.d.ts +18 -0
  108. package/dist/resources/tasks/index.js +34 -0
  109. package/dist/resources/tasks/types.d.ts +64 -0
  110. package/dist/resources/tasks/types.js +2 -0
  111. package/dist/resources/users/index.d.ts +22 -0
  112. package/dist/resources/users/index.js +40 -0
  113. package/dist/resources/users/types.d.ts +86 -0
  114. package/dist/resources/users/types.js +2 -0
  115. package/dist/resources/usertasks/index.d.ts +18 -0
  116. package/dist/resources/usertasks/index.js +41 -0
  117. package/dist/resources/usertasks/types.d.ts +31 -0
  118. package/dist/resources/usertasks/types.js +2 -0
  119. package/dist/resources/workflows/index.d.ts +18 -0
  120. package/dist/resources/workflows/index.js +34 -0
  121. package/dist/resources/workflows/types.d.ts +31 -0
  122. package/dist/resources/workflows/types.js +2 -0
  123. package/dist/resources/workflowstatuses/index.d.ts +18 -0
  124. package/dist/resources/workflowstatuses/index.js +34 -0
  125. package/dist/resources/workflowstatuses/types.d.ts +35 -0
  126. package/dist/resources/workflowstatuses/types.js +2 -0
  127. package/dist/types.d.ts +25 -0
  128. package/dist/types.js +2 -0
  129. package/package.json +13 -3
  130. package/src/abstract.ts +220 -0
  131. package/src/index.ts +23 -0
  132. package/src/remote.ts +77 -0
  133. package/src/resources/_template_/index.ts +38 -0
  134. package/src/resources/_template_/types.ts +40 -0
  135. package/src/resources/bookings/index.ts +61 -0
  136. package/src/resources/bookings/types.ts +60 -0
  137. package/src/resources/clientcontacts/index.ts +38 -0
  138. package/src/resources/clientcontacts/types.ts +69 -0
  139. package/src/resources/clients/index.ts +38 -0
  140. package/src/resources/clients/types.ts +100 -0
  141. package/src/resources/comments/Comments.ts +38 -0
  142. package/src/resources/comments/Threads.ts +28 -0
  143. package/src/resources/comments/index.ts +2 -0
  144. package/src/resources/comments/types.ts +105 -0
  145. package/src/resources/company/index.ts +23 -0
  146. package/src/resources/company/types.ts +52 -0
  147. package/src/resources/discussions/index.ts +38 -0
  148. package/src/resources/discussions/types.ts +53 -0
  149. package/src/resources/entries/index.ts +52 -0
  150. package/src/resources/entries/types.ts +67 -0
  151. package/src/resources/estimates/EstimateItem.ts +6 -0
  152. package/src/resources/estimates/Estimates.ts +38 -0
  153. package/src/resources/estimates/index.ts +2 -0
  154. package/src/resources/estimates/types.ts +89 -0
  155. package/src/resources/estimatetemplates/index.ts +38 -0
  156. package/src/resources/estimatetemplates/types.ts +46 -0
  157. package/src/resources/expenses/index.ts +38 -0
  158. package/src/resources/expenses/types.ts +58 -0
  159. package/src/resources/files/index.ts +50 -0
  160. package/src/resources/files/types.ts +58 -0
  161. package/src/resources/index.ts +289 -0
  162. package/src/resources/invoices/InvoiceItem.ts +6 -0
  163. package/src/resources/invoices/Invoices.ts +38 -0
  164. package/src/resources/invoices/index.ts +2 -0
  165. package/src/resources/invoices/types.ts +102 -0
  166. package/src/resources/invoicetemplates/index.ts +38 -0
  167. package/src/resources/invoicetemplates/types.ts +46 -0
  168. package/src/resources/milestones/index.ts +38 -0
  169. package/src/resources/milestones/types.ts +52 -0
  170. package/src/resources/projects/index.ts +47 -0
  171. package/src/resources/projects/types.ts +134 -0
  172. package/src/resources/projectstatuses/index.ts +38 -0
  173. package/src/resources/projectstatuses/types.ts +44 -0
  174. package/src/resources/projecttemplates/index.ts +40 -0
  175. package/src/resources/projecttemplates/types.ts +43 -0
  176. package/src/resources/reports/index.ts +38 -0
  177. package/src/resources/reports/types.ts +104 -0
  178. package/src/resources/sessions/index.ts +39 -0
  179. package/src/resources/sessions/types.ts +43 -0
  180. package/src/resources/tasklists/index.ts +38 -0
  181. package/src/resources/tasklists/types.ts +48 -0
  182. package/src/resources/tasks/index.ts +38 -0
  183. package/src/resources/tasks/types.ts +76 -0
  184. package/src/resources/users/index.ts +48 -0
  185. package/src/resources/users/types.ts +124 -0
  186. package/src/resources/usertasks/index.ts +46 -0
  187. package/src/resources/usertasks/types.ts +43 -0
  188. package/src/resources/workflows/index.ts +38 -0
  189. package/src/resources/workflows/types.ts +43 -0
  190. package/src/resources/workflowstatuses/index.ts +38 -0
  191. package/src/resources/workflowstatuses/types.ts +47 -0
  192. package/src/types.ts +40 -0
  193. package/tsconfig.json +12 -0
  194. package/lib/index.ts +0 -6
@@ -0,0 +1,38 @@
1
+ import { AbstractResource, AbstractResourceInterface } from '../../abstract'
2
+ import { AuthInterface } from "../../types"
3
+ import { ReportsListConfig, ReportsTypeCreate, ReportsTypeResponse, ReportsTypeUpdate } from "./types"
4
+
5
+ export interface ReportsHandler extends AbstractResourceInterface {
6
+ get: (id: number) => Promise<ReportsTypeResponse | null>
7
+ list: (config?: ReportsListConfig) => Promise<ReportsTypeResponse[]>
8
+ create: (d: ReportsTypeCreate) => Promise<ReportsTypeResponse | null>
9
+ update: (id: number, data: ReportsTypeUpdate) => Promise<ReportsTypeResponse | null>
10
+ delete: (id: number) => Promise<boolean>
11
+ }
12
+
13
+ export class Reports extends AbstractResource implements ReportsHandler {
14
+ constructor(auth: AuthInterface) {
15
+ super(auth, 'reports')
16
+ }
17
+
18
+ get = async (id: number) => {
19
+ return (await this.baseGet(id)) as ReportsTypeResponse | null
20
+ }
21
+
22
+ list = async (config: ReportsListConfig = {}) => {
23
+ return (await this.baseList(config)) as ReportsTypeResponse[]
24
+ }
25
+
26
+ create = async (data: ReportsTypeCreate) => {
27
+ return (await this.baseCreate(data)) as ReportsTypeResponse | null
28
+ }
29
+
30
+ update = async (id: number, data: ReportsTypeUpdate) => {
31
+ return (await this.baseUpdate(id, data)) as ReportsTypeResponse | null
32
+ }
33
+
34
+ delete = async (id: number) => {
35
+ return await this.baseDelete(id)
36
+ }
37
+
38
+ }
@@ -0,0 +1,104 @@
1
+ import { FilterOperator, GenericListConfig, Merge } from "../../types"
2
+
3
+ // PAYMO API DOCS - 2019-12-11 /reports /reports/####
4
+ // =================================================================================================
5
+
6
+ type ReportsDateIntervals = 'today' | 'yesterday' | 'this_month' | 'last_month' | 'this_week' | 'last_week' | 'this_year' | 'last_year' | 'all_time'
7
+
8
+ interface ReportsIncludeOptions {
9
+ days?: boolean
10
+ clients?: boolean
11
+ users?: boolean
12
+ projects?: boolean
13
+ tasklists?: boolean
14
+ tasks?: boolean
15
+ billed?: boolean
16
+ entries?: boolean
17
+ }
18
+
19
+ interface ReportsExtraOptions {
20
+ exclude_billed_entries?: boolean
21
+ exclude_unbilled_entries?: boolean
22
+ exclude_billable_tasks?: boolean
23
+ exclude_nonbillable_tasks?: boolean
24
+ exclude_flat_rate_tasks?: boolean
25
+ exclude_flats?: boolean
26
+ enable_time_rounding?: boolean
27
+ rounding_step?: number // In minutes
28
+ display_charts?: boolean
29
+ display_costs?: boolean
30
+ display_entries_descriptions?: boolean
31
+ display_seconds?: boolean
32
+ display_tasks_codes?: boolean
33
+ display_tasks_descriptions?: boolean
34
+ display_tasks_complete_status?: boolean
35
+ display_tasks_remaining_time_budgets?: boolean
36
+ display_tasks_time_budget?: boolean
37
+ display_projects_budgets?: boolean
38
+ display_projects_codes?: boolean
39
+ display_projects_descriptions?: boolean
40
+ display_projects_remaining_budgets?: boolean
41
+ display_users_positions?: boolean
42
+ order?: Array<keyof ReportsIncludeOptions>
43
+ }
44
+
45
+ export interface ReportsTypeRead {
46
+ readonly id: number
47
+ readonly created_on: string
48
+ readonly updated_on: string
49
+ }
50
+
51
+ export interface ReportsTypeUpdate {
52
+ name?: string
53
+ user_id?: number
54
+ type?: 'static' | 'live' | 'temp'
55
+ start_date?: string
56
+ end_date?: string
57
+ date_interval?: ReportsDateIntervals
58
+ shared?: boolean
59
+ }
60
+
61
+ export type ReportsTypeResponse = Merge<ReportsTypeUpdate, Merge<ReportsTypeRead, {
62
+ info: any // Parameters used in the creation
63
+ content?: { items: any[] } // Mix of response data types, @todo Can be narrowed down later
64
+ permalink: string
65
+ shared: boolean
66
+ share_client_id?: number
67
+ }>>
68
+
69
+ export type ReportsTypeCreate = ReportsTypeCreateWithInterval | ReportsTypeCreateWithDates
70
+
71
+ interface ReportsTypeCommon extends ReportsTypeUpdate {
72
+ projects?: number[] | 'all' | 'all_active' | 'all_archived' | string // string must be status_id=STATUS_ID
73
+ clients?: number[] | 'all' | 'all_active'
74
+ users?: number[] | 'all' | 'all_active' | 'all_archived'
75
+ include?: ReportsIncludeOptions
76
+ extra?: ReportsExtraOptions
77
+ }
78
+
79
+ interface ReportsTypeCreateWithInterval extends ReportsTypeCommon {
80
+ date_interval: ReportsDateIntervals
81
+ }
82
+
83
+ interface ReportsTypeCreateWithDates extends ReportsTypeCommon {
84
+ start_date: string
85
+ end_date: string
86
+ }
87
+
88
+ export interface ReportsTypeFilter {
89
+
90
+ }
91
+
92
+ export interface ReportsFilterCondition extends ReportsTypeFilter {
93
+ _custom?: {
94
+ [k: string]: {
95
+ key?: Extract<keyof ReportsTypeFilter, string>
96
+ operator?:FilterOperator
97
+ value: string | number | boolean | null | number[]
98
+ }
99
+ }
100
+ }
101
+
102
+ export interface ReportsListConfig extends GenericListConfig {
103
+ filter?:ReportsFilterCondition
104
+ }
@@ -0,0 +1,39 @@
1
+ import { AbstractResource, AbstractResourceInterface } from '../../abstract'
2
+ import { AuthInterface } from "../../types"
3
+ import { SessionsListConfig, SessionsTypeCreate, SessionsTypeResponse, SessionsTypeUpdate } from "./types"
4
+
5
+ export interface SessionsHandler extends AbstractResourceInterface {
6
+ get: (id: number) => Promise<SessionsTypeResponse | null>
7
+ list: (config?: SessionsListConfig) => Promise<SessionsTypeResponse[]>
8
+ create: (d: SessionsTypeCreate) => Promise<SessionsTypeResponse | null>
9
+ update: (id: number, data: SessionsTypeUpdate) => Promise<SessionsTypeResponse | null>
10
+ delete: (id: number) => Promise<boolean>
11
+ }
12
+
13
+ export class Sessions extends AbstractResource implements SessionsHandler {
14
+ constructor(auth: AuthInterface) {
15
+ super(auth, 'sessions')
16
+ }
17
+
18
+ get = async (id: number) => {
19
+ return (await this.baseGet(id)) as SessionsTypeResponse | null
20
+ }
21
+
22
+ list = async (config: SessionsListConfig = {}) => {
23
+ return (await this.baseList(config)) as SessionsTypeResponse[]
24
+ }
25
+
26
+ create = async (data: SessionsTypeCreate) => {
27
+ return (await this.baseCreate(data)) as SessionsTypeResponse | null
28
+ }
29
+
30
+ // There is no update method for sessions. Create, List, Get, or Delete only
31
+ update = async (id: number, data: SessionsTypeUpdate) => {
32
+ return null
33
+ }
34
+
35
+ delete = async (id: number) => {
36
+ return await this.baseDelete(id)
37
+ }
38
+
39
+ }
@@ -0,0 +1,43 @@
1
+ import { FilterOperator, GenericListConfig, Merge } from "../../types"
2
+
3
+ // PAYMO API DOCS - 2019-12-11 /sessions /sessions/####
4
+ // =================================================================================================
5
+
6
+ export interface SessionsTypeRead {
7
+ readonly id: string
8
+ readonly ip: string
9
+ readonly created_on: string
10
+ readonly updated_on: string
11
+ readonly expires_on: string
12
+ readonly user_id: number
13
+ }
14
+
15
+ export interface SessionsTypeUpdate {
16
+
17
+ }
18
+
19
+ export type SessionsTypeResponse = Merge<SessionsTypeUpdate, Merge<SessionsTypeRead, {
20
+
21
+ }>>
22
+
23
+ export interface SessionsTypeCreate {
24
+
25
+ }
26
+
27
+ export interface SessionsTypeFilter {
28
+
29
+ }
30
+
31
+ export interface SessionsFilterCondition extends SessionsTypeFilter {
32
+ _custom?: {
33
+ [k: string]: {
34
+ key?: Extract<keyof SessionsTypeFilter, string>
35
+ operator?:FilterOperator
36
+ value: string | number | boolean | null | number[]
37
+ }
38
+ }
39
+ }
40
+
41
+ export interface SessionsListConfig extends GenericListConfig {
42
+ filter?:SessionsFilterCondition
43
+ }
@@ -0,0 +1,38 @@
1
+ import { AbstractResource, AbstractResourceInterface } from '../../abstract'
2
+ import { AuthInterface } from "../../types"
3
+ import { TaskListsListConfig, TaskListsTypeCreate, TaskListsTypeResponse, TaskListsTypeUpdate } from "./types"
4
+
5
+ export interface TaskListsHandler extends AbstractResourceInterface {
6
+ get: (id: number) => Promise<TaskListsTypeResponse | null>
7
+ list: (config?: TaskListsListConfig) => Promise<TaskListsTypeResponse[]>
8
+ create: (d: TaskListsTypeCreate) => Promise<TaskListsTypeResponse | null>
9
+ update: (id: number, data: TaskListsTypeUpdate) => Promise<TaskListsTypeResponse | null>
10
+ delete: (id: number) => Promise<boolean>
11
+ }
12
+
13
+ export class TaskLists extends AbstractResource implements TaskListsHandler {
14
+ constructor(auth: AuthInterface) {
15
+ super(auth, 'tasklists')
16
+ }
17
+
18
+ get = async (id: number) => {
19
+ return (await this.baseGet(id)) as TaskListsTypeResponse | null
20
+ }
21
+
22
+ list = async (config: TaskListsListConfig = {}) => {
23
+ return (await this.baseList(config)) as TaskListsTypeResponse[]
24
+ }
25
+
26
+ create = async (data: TaskListsTypeCreate) => {
27
+ return (await this.baseCreate(data)) as TaskListsTypeResponse | null
28
+ }
29
+
30
+ update = async (id: number, data: TaskListsTypeUpdate) => {
31
+ return (await this.baseUpdate(id, data)) as TaskListsTypeResponse | null
32
+ }
33
+
34
+ delete = async (id: number) => {
35
+ return await this.baseDelete(id)
36
+ }
37
+
38
+ }
@@ -0,0 +1,48 @@
1
+ import { FilterOperator, GenericListConfig, Merge } from '../../types'
2
+
3
+ // PAYMO API DOCS - 2019-12-11 /tasklists /tasklists/####
4
+ // =================================================================================================
5
+
6
+ export interface TaskListsTypeRead {
7
+ readonly id: number
8
+ readonly created_on: string
9
+ readonly updated_on: string
10
+ readonly project_id: number
11
+ }
12
+
13
+ export interface TaskListsTypeUpdate {
14
+ name?: string
15
+ seq?: number | null
16
+ milestone_id?: number
17
+ tasks_order?: number[]
18
+ }
19
+
20
+ export type TaskListsTypeResponse = Merge<
21
+ TaskListsTypeUpdate,
22
+ Merge<TaskListsTypeRead, {}>
23
+ >
24
+
25
+ export interface TaskListsTypeCreate extends TaskListsTypeUpdate {
26
+ name: string
27
+ project_id: number
28
+ }
29
+
30
+ export interface TaskListsTypeFilter {
31
+ name?:string
32
+ project_id?: number
33
+ milestone_id?: number
34
+ }
35
+
36
+ export interface TaskListsFilterCondition extends TaskListsTypeFilter {
37
+ _custom?: {
38
+ [k: string]: {
39
+ key?: Extract<keyof TaskListsTypeFilter, string>
40
+ operator?: FilterOperator
41
+ value: string | number | boolean | null | number[]
42
+ }
43
+ }
44
+ }
45
+
46
+ export interface TaskListsListConfig extends GenericListConfig {
47
+ filter?: TaskListsFilterCondition
48
+ }
@@ -0,0 +1,38 @@
1
+ import { AbstractResource, AbstractResourceInterface } from '../../abstract'
2
+ import { AuthInterface } from "../../types"
3
+ import { TasksListConfig, TasksTypeCreate, TasksTypeResponse, TasksTypeUpdate } from "./types"
4
+
5
+ export interface TasksHandler extends AbstractResourceInterface {
6
+ get: (id: number) => Promise<TasksTypeResponse | null>
7
+ list: (config?: TasksListConfig) => Promise<TasksTypeResponse[]>
8
+ create: (d: TasksTypeCreate) => Promise<TasksTypeResponse | null>
9
+ update: (id: number, data: TasksTypeUpdate) => Promise<TasksTypeResponse | null>
10
+ delete: (id: number) => Promise<boolean>
11
+ }
12
+
13
+ export class Tasks extends AbstractResource implements TasksHandler {
14
+ constructor(auth: AuthInterface) {
15
+ super(auth, 'tasks')
16
+ }
17
+
18
+ get = async (id: number) => {
19
+ return (await this.baseGet(id)) as TasksTypeResponse | null
20
+ }
21
+
22
+ list = async (config: TasksListConfig = {}) => {
23
+ return (await this.baseList(config)) as TasksTypeResponse[]
24
+ }
25
+
26
+ create = async (data: TasksTypeCreate) => {
27
+ return (await this.baseCreate(data)) as TasksTypeResponse | null
28
+ }
29
+
30
+ update = async (id: number, data: TasksTypeUpdate) => {
31
+ return (await this.baseUpdate(id, data)) as TasksTypeResponse | null
32
+ }
33
+
34
+ delete = async (id: number) => {
35
+ return await this.baseDelete(id)
36
+ }
37
+
38
+ }
@@ -0,0 +1,76 @@
1
+ import { FilterOperator, GenericListConfig, Merge } from "../../types"
2
+
3
+ // PAYMO API DOCS - 2019-12-11 /tasks /tasks/####
4
+ // =================================================================================================
5
+
6
+ export interface TasksTypeRead {
7
+ readonly id: number
8
+ readonly created_on: string
9
+ readonly updated_on: string
10
+ readonly project_id: number
11
+ }
12
+
13
+ export interface TasksTypeUpdate {
14
+ name?:string
15
+ code?:string
16
+ tasklist_id?: number
17
+ seq?: number | null
18
+ description?: string
19
+ complete?: boolean
20
+ due_date?: string
21
+ user_id?: number
22
+ users?: number[] | null
23
+ billable?: boolean
24
+ flat_billing?: boolean
25
+ price_per_hour?: number
26
+ budget_hours?: number
27
+ estimated_price?: number
28
+ invoiced?: boolean
29
+ invoice_item_id?: number
30
+ priority?: 25 | 50 | 75 | 100
31
+ status_id?: number
32
+ }
33
+
34
+ export type TasksTypeResponse = Merge<TasksTypeUpdate, Merge<TasksTypeRead, {
35
+ completed_by?:number
36
+ cover_file_id?: number
37
+ start_date?:string
38
+ recurring_profile_id?:number
39
+ billing_type?:string
40
+ }>>
41
+
42
+ interface TasksTypeCreateCommon extends TasksTypeUpdate {
43
+ name: string
44
+ }
45
+
46
+ interface TasksTypeCreateWithTaskList extends TasksTypeCreateCommon {
47
+ tasklist_id: number
48
+ }
49
+
50
+ interface TasksTypeCreateWithProject extends TasksTypeCreateCommon {
51
+ project_id: number
52
+ }
53
+
54
+ export type TasksTypeCreate = TasksTypeCreateWithProject | TasksTypeCreateWithTaskList
55
+
56
+ export interface TasksTypeFilter {
57
+ project_id?:number
58
+ tasklist_id?: number
59
+ complete?: boolean
60
+ users?: number | (number|string)[] | 'anyone'
61
+ mytasks?: boolean
62
+ }
63
+
64
+ export interface TasksFilterCondition extends TasksTypeFilter {
65
+ _custom?: {
66
+ [k: string]: {
67
+ key?: Extract<keyof TasksTypeFilter, string>
68
+ operator?:FilterOperator
69
+ value: string | number | boolean | null | number[]
70
+ }
71
+ }
72
+ }
73
+
74
+ export interface TasksListConfig extends GenericListConfig {
75
+ filter?:TasksFilterCondition
76
+ }
@@ -0,0 +1,48 @@
1
+ import { AbstractResource, AbstractResourceInterface } from '../../abstract'
2
+ import { AuthInterface } from "../../types"
3
+ import { UsersListConfig, UserTypeCreate, UserTypeResponse, UserTypeUpdate } from "./types"
4
+
5
+ export interface UsersHandler extends AbstractResourceInterface {
6
+ get: (id: number) => Promise<UserTypeResponse | null>
7
+ list: (config?: UsersListConfig) => Promise<UserTypeResponse[]>
8
+ create: (d: UserTypeCreate) => Promise<UserTypeResponse | null>
9
+ update: (id: number, data: UserTypeUpdate) => Promise<UserTypeResponse | null>
10
+ delete: (id: number) => Promise<boolean>
11
+ retire: (id: number) => Promise<UserTypeResponse | null>
12
+ activate: (id: number) => Promise<UserTypeResponse | null>
13
+ }
14
+
15
+ export class Users extends AbstractResource implements UsersHandler {
16
+ constructor(auth: AuthInterface) {
17
+ super(auth, 'users')
18
+ }
19
+
20
+ get = async (id: number) => {
21
+ return (await this.baseGet(id)) as UserTypeResponse | null
22
+ }
23
+
24
+ list = async (config: UsersListConfig = {}) => {
25
+ return (await this.baseList(config)) as UserTypeResponse[]
26
+ }
27
+
28
+ create = async (data: UserTypeCreate) => {
29
+ return (await this.baseCreate(data)) as UserTypeResponse | null
30
+ }
31
+
32
+ update = async (id: number, data: UserTypeUpdate) => {
33
+ return (await this.baseUpdate(id, data)) as UserTypeResponse | null
34
+ }
35
+
36
+ delete = async (id: number) => {
37
+ return await this.baseDelete(id)
38
+ }
39
+
40
+ retire = async (id: number) => {
41
+ return await this.update(id, {active:false})
42
+ }
43
+
44
+ activate = async (id: number) => {
45
+ return await this.update(id, {active:true})
46
+ }
47
+
48
+ }
@@ -0,0 +1,124 @@
1
+ import { FilterOperator, GenericListConfig, Merge } from "../../types"
2
+
3
+ // PAYMO API DOCS - 2019-11-23 /users /users/####
4
+ // =================================================================================================
5
+ // id integer (read-only) Unique user identifier
6
+ // name text Full name
7
+ // email email Email address. There are no two active users in Paymo with the same email address. Email is used to receive notifications from Paymo as well as to log into Paymo.
8
+ // type text Account type. Available options: Admin, Employee.
9
+ // active boolean If true the user is active and can use Paymo, otherwise it is retired (archived).
10
+ // timezone text User timezone. List of available options
11
+ // phone text Phone number
12
+ // skype text Skype account name
13
+ // position text Job position description
14
+ // workday_hours decimal Number of working hours in a day. It is used to compute user performance.
15
+ // price_per_hour decimal Price per hour. It is used in invoicing to compute the cost of worked time.
16
+ // created_on datetime (read-only) Date and time when the user was created
17
+ // updated_on datetime (read-only) Date and time when the user was last updated
18
+ // image url User profile image URL
19
+ // image_thumb_large url (read-only) User profile image large size thumbnail URL
20
+ // image_thumb_medium url (read-only) User profile image medium size thumbnail URL
21
+ // image_thumb_small url (read-only) User profile image small size thumbnail URL
22
+ // date_format text Format for displaying dates in the application. Available options: Y-m-d, d/m/Y, m/d/Y, d.m.Y.
23
+ // time_format text Format for displaying time values. Available options: H:i for 24-hour format, h:i a for 12-hour format.
24
+ // decimal_sep text Decimal separator for displaying numeric values
25
+ // thousands_sep text Thousands separator for displaying numeric values
26
+ // week_start text Numeric value in the range 0-6 representing the day the week starts, 0 being Sunday, 6 being Saturday.
27
+ // language text Paymo user interface language
28
+ // theme text Paymo user interface theme name
29
+ // assigned_projects list List of projects ids to which the user is assigned
30
+ // managed_projects list List of projects ids that the user manages. This list is a subset of assigned_projects.
31
+ // is_online boolean (read-only) If true the user is logged into Paymo.
32
+ // password text (only for create/update requests) User password when creating or updating a user.
33
+
34
+ export interface UserTypeRead {
35
+ readonly id: number
36
+ readonly created_on: string
37
+ readonly updated_on: string
38
+ readonly image_thumb_large?: string
39
+ readonly image_thumb_medium?: string
40
+ readonly image_thumb_small?: string
41
+ readonly is_online?: boolean
42
+ }
43
+
44
+ export interface UserTypeUpdate {
45
+ name?: string
46
+ email?: string
47
+ type?: "Admin" | "Employee"
48
+ active?: boolean
49
+ timezone?: string
50
+ phone?: string
51
+ skype?: string
52
+ position?: string
53
+ workday_hours?: number
54
+ price_per_hour?:number
55
+ image?: string
56
+ date_format?:"Y-m-d"|"d/m/Y"|"m/d/Y"|"d.m.Y"
57
+ time_format?:"H:i"|"h:i"
58
+ decimal_sep?:string
59
+ thousands_sep?:string
60
+ week_start?:"0"|"1"|"2"|"3"|"4"|"5"|"6"
61
+ language?:string
62
+ theme?:string
63
+ assigned_projects?:number[]
64
+ managed_projects?:number[]
65
+ password?:string
66
+ }
67
+
68
+ export type UserTypeResponse = Merge<UserTypeUpdate, Merge<UserTypeRead, {
69
+ additional_privileges:any[]
70
+ annual_leave_days_number:number|null
71
+ image:string|null
72
+ phone:string|null
73
+ position:string|null
74
+ price_per_hour:string|null
75
+ skype:string|null
76
+ user_hash:string
77
+ workflows:number[]
78
+ }>>
79
+
80
+ export interface UserTypeCreate extends UserTypeUpdate {
81
+ email: string
82
+ }
83
+
84
+ export interface UserTypeFilter {
85
+ id?: number
86
+ created_on?: string
87
+ updated_on?: string
88
+ is_online?: boolean
89
+ name?: string
90
+ email?: string
91
+ type?: "Admin" | "Employee"
92
+ active?: boolean
93
+ timezone?: string
94
+ phone?: string
95
+ skype?: string
96
+ position?: string
97
+ workday_hours?: number
98
+ price_per_hour?:number
99
+ image?: string
100
+ date_format?:"Y-m-d"|"d/m/Y"|"m/d/Y"|"d.m.Y"
101
+ time_format?:"H:i"|"h:i"
102
+ decimal_sep?:string
103
+ thousands_sep?:string
104
+ week_start?:0|1|2|3|4|5|6
105
+ language?:string
106
+ theme?:string
107
+ assigned_projects?:number[]
108
+ managed_projects?:number[]
109
+ password?:string
110
+ }
111
+
112
+ export interface UserFilterCondition extends UserTypeFilter {
113
+ _custom?: {
114
+ [k: string]: {
115
+ key?: Extract<keyof UserTypeFilter, string>
116
+ operator?:FilterOperator
117
+ value: string | number | boolean | null | number[]
118
+ }
119
+ }
120
+ }
121
+
122
+ export interface UsersListConfig extends GenericListConfig {
123
+ filter?:UserFilterCondition
124
+ }
@@ -0,0 +1,46 @@
1
+ import { AbstractResource, AbstractResourceInterface } from '../../abstract'
2
+ import { AuthInterface } from "../../types"
3
+ import { UserTasksListConfig, UserTasksTypeCreate, UserTasksTypeResponse, UserTasksTypeUpdate } from "./types"
4
+
5
+ export interface UserTasksHandler extends AbstractResourceInterface {
6
+ get: (id: number) => Promise<UserTasksTypeResponse | null>
7
+ list: (config?: UserTasksListConfig) => Promise<UserTasksTypeResponse[]>
8
+ create: (d: UserTasksTypeCreate) => Promise<UserTasksTypeResponse | null>
9
+ update: (id: number, data: UserTasksTypeUpdate) => Promise<UserTasksTypeResponse | null>
10
+ delete: (id: number) => Promise<boolean>
11
+ }
12
+
13
+ export class UserTasks extends AbstractResource implements UserTasksHandler {
14
+ constructor(auth: AuthInterface) {
15
+ super(auth, 'userstasks')
16
+ }
17
+
18
+ get = async (id: number) => {
19
+ return (await this.baseGet(id)) as UserTasksTypeResponse | null
20
+ }
21
+
22
+ list = async (config: UserTasksListConfig = {}) => {
23
+ const validConfig =
24
+ !!config &&
25
+ config.filter &&
26
+ (config.filter.user_id || config.filter.task_id)
27
+ if (!validConfig) {
28
+ console.log('User task list requires at least a user_id or task_id filter')
29
+ return []
30
+ }
31
+ return (await this.baseList(config)) as UserTasksTypeResponse[]
32
+ }
33
+
34
+ create = async (data: UserTasksTypeCreate) => {
35
+ return (await this.baseCreate(data)) as UserTasksTypeResponse | null
36
+ }
37
+
38
+ update = async (id: number, data: UserTasksTypeUpdate) => {
39
+ return (await this.baseUpdate(id, data)) as UserTasksTypeResponse | null
40
+ }
41
+
42
+ delete = async (id: number) => {
43
+ return await this.baseDelete(id)
44
+ }
45
+
46
+ }
@@ -0,0 +1,43 @@
1
+ import { FilterOperator, GenericListConfig, Merge } from "../../types"
2
+
3
+ // PAYMO API DOCS - 2019-12-11 /userstasks /userstasks/####
4
+ // =================================================================================================
5
+
6
+ export interface UserTasksTypeRead {
7
+ readonly id: number
8
+ readonly created_on: string
9
+ readonly updated_on: string
10
+ }
11
+
12
+ export interface UserTasksTypeUpdate {
13
+ user_id?:number
14
+ task_id?:number
15
+ }
16
+
17
+ export type UserTasksTypeResponse = Merge<UserTasksTypeUpdate, Merge<UserTasksTypeRead, {
18
+
19
+ }>>
20
+
21
+ export interface UserTasksTypeCreate extends UserTasksTypeUpdate {
22
+ user_id:number
23
+ task_id:number
24
+ }
25
+
26
+ export interface UserTasksTypeFilter {
27
+ user_id?:number
28
+ task_id?:number
29
+ }
30
+
31
+ export interface UserTasksFilterCondition extends UserTasksTypeFilter {
32
+ _custom?: {
33
+ [k: string]: {
34
+ key?: Extract<keyof UserTasksTypeFilter, string>
35
+ operator?:FilterOperator
36
+ value: string | number | boolean | null | number[]
37
+ }
38
+ }
39
+ }
40
+
41
+ export interface UserTasksListConfig extends GenericListConfig {
42
+ filter?:UserTasksFilterCondition
43
+ }