1 | const Property = require('./deal_property')
|
2 |
|
3 | class Deal {
|
4 | constructor(client) {
|
5 | this.client = client
|
6 | this.properties = new Property(client)
|
7 | }
|
8 |
|
9 | get(options) {
|
10 | return this.client._request({
|
11 | method: 'GET',
|
12 | path: '/deals/v1/deal/paged',
|
13 | qs: options,
|
14 | useQuerystring: true,
|
15 | })
|
16 | }
|
17 |
|
18 | getRecentlyModified(options) {
|
19 | return this.client._request({
|
20 | method: 'GET',
|
21 | path: '/deals/v1/deal/recent/modified',
|
22 | qs: options,
|
23 | })
|
24 | }
|
25 |
|
26 | getRecentlyCreated(options) {
|
27 | return this.client._request({
|
28 | method: 'GET',
|
29 | path: '/deals/v1/deal/recent/created',
|
30 | qs: options,
|
31 | })
|
32 | }
|
33 |
|
34 | getById(id, options) {
|
35 | return this.client._request({
|
36 | method: 'GET',
|
37 | path: `/deals/v1/deal/${id}`,
|
38 | qs: options,
|
39 | })
|
40 | }
|
41 |
|
42 | getAssociated(objectType, objectId, options) {
|
43 | return this.client._request({
|
44 | method: 'GET',
|
45 | path: `/deals/v1/deal/associated/${objectType}/${objectId}/paged`,
|
46 | qs: options,
|
47 | })
|
48 | }
|
49 |
|
50 | deleteById(id) {
|
51 | return this.client._request({
|
52 | method: 'DELETE',
|
53 | path: `/deals/v1/deal/${id}`,
|
54 | })
|
55 | }
|
56 |
|
57 | updateById(id, data) {
|
58 | return this.client._request({
|
59 | method: 'PUT',
|
60 | path: `/deals/v1/deal/${id}`,
|
61 | body: data,
|
62 | })
|
63 | }
|
64 |
|
65 | updateBatch(data) {
|
66 | return this.client._request({
|
67 | method: 'POST',
|
68 | path: '/deals/v1/batch-async/update',
|
69 | body: data,
|
70 | })
|
71 | }
|
72 |
|
73 | create(data) {
|
74 | return this.client._request({
|
75 | method: 'POST',
|
76 | path: '/deals/v1/deal',
|
77 | body: data,
|
78 | })
|
79 | }
|
80 |
|
81 | associate(id, objectType, associatedObjectId) {
|
82 | return this.client._request({
|
83 | method: 'PUT',
|
84 | path: `/deals/v1/deal/${id}/associations/${objectType}?id=${associatedObjectId}`,
|
85 | })
|
86 | }
|
87 |
|
88 | removeAssociation(id, objectType, associatedObjectId) {
|
89 | return this.client._request({
|
90 | method: 'DELETE',
|
91 | path: `/deals/v1/deal/${id}/associations/${objectType}?id=${associatedObjectId}`,
|
92 | })
|
93 | }
|
94 | }
|
95 |
|
96 | module.exports = Deal
|