drapcode-developer-sdk 1.0.3 → 1.0.4
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/README.md +48 -13
- package/build/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,9 +11,14 @@ npm install drapcode-developer-sdk
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { DrapcodeApis } from
|
|
14
|
+
import { DrapcodeApis } from "drapcode-developer-sdk";
|
|
15
15
|
|
|
16
|
-
const api = new DrapcodeApis(
|
|
16
|
+
const api = new DrapcodeApis(
|
|
17
|
+
project_seo_name,
|
|
18
|
+
xApiKey,
|
|
19
|
+
authorization,
|
|
20
|
+
environment
|
|
21
|
+
);
|
|
17
22
|
```
|
|
18
23
|
|
|
19
24
|
**project_seo_name (Required):** The SEO name of your Drapcode project.
|
|
@@ -22,18 +27,24 @@ const api = new DrapcodeApis(project_seo_name, xApiKey, authorization, environme
|
|
|
22
27
|
|
|
23
28
|
**authorization (Optional)**: Authorization token for authentication, if applicable.
|
|
24
29
|
|
|
25
|
-
**environment (Optional)**: The environment (PRODUCTION, PREVIEW,
|
|
26
|
-
|
|
30
|
+
**environment (Optional)**: The environment (PRODUCTION, PREVIEW, SANDBOX, UAT). Defaults to PRODUCTION if not provided.
|
|
31
|
+
|
|
32
|
+
### Example:
|
|
33
|
+
|
|
27
34
|
```
|
|
28
35
|
const drapcodeApi = new DrapcodeApis("test-project-7138");
|
|
29
36
|
```
|
|
37
|
+
|
|
30
38
|
# Methods
|
|
31
39
|
|
|
32
40
|
## getAllItems(collectionName: string)
|
|
41
|
+
|
|
33
42
|
Retrieves all items from a specified collection. The items will come under 'data' JSON path.
|
|
34
43
|
|
|
35
|
-
**collectionName:** The name of the collection to retrieve items from
|
|
36
|
-
|
|
44
|
+
**collectionName:** The name of the collection to retrieve items from
|
|
45
|
+
|
|
46
|
+
### Example:
|
|
47
|
+
|
|
37
48
|
```
|
|
38
49
|
const items = await drapcodeApi.getAllItems("users");
|
|
39
50
|
```
|
|
@@ -41,17 +52,21 @@ const items = await drapcodeApi.getAllItems("users");
|
|
|
41
52
|
Retrieves items from the "users" collection.
|
|
42
53
|
|
|
43
54
|
## createItem(collectionName: string, body: JSON)
|
|
55
|
+
|
|
44
56
|
Creates a new item in the specified collection.
|
|
45
57
|
|
|
46
58
|
**collectionName:** The name of the collection to create the item in.
|
|
47
59
|
**body:** The data of the item to be created.
|
|
48
|
-
|
|
60
|
+
|
|
61
|
+
### Example:
|
|
62
|
+
|
|
49
63
|
```
|
|
50
64
|
await drapcodeApi.createItem("users", {
|
|
51
65
|
"name": "John Doe",
|
|
52
66
|
"age": 25
|
|
53
67
|
});
|
|
54
68
|
```
|
|
69
|
+
|
|
55
70
|
Creates a new item in the "users" collection with the provided data.
|
|
56
71
|
|
|
57
72
|
## getItemsWithFilter(collectionName: string, filterUuid: string)
|
|
@@ -61,7 +76,8 @@ Retrieves items from a collection based on a filter UUID.
|
|
|
61
76
|
**collectionName:** The name of the collection to retrieve items from.
|
|
62
77
|
**filterUuid:** The UUID of the filter to apply.
|
|
63
78
|
|
|
64
|
-
### Example:
|
|
79
|
+
### Example:
|
|
80
|
+
|
|
65
81
|
```
|
|
66
82
|
const filteredItems = await drapcodeApi.getItemsWithFilter("users", "15263");
|
|
67
83
|
```
|
|
@@ -69,60 +85,79 @@ const filteredItems = await drapcodeApi.getItemsWithFilter("users", "15263");
|
|
|
69
85
|
Retrieves items from the "users" collection based on the filter UUID "15263".
|
|
70
86
|
|
|
71
87
|
## getItemsCountWithFilter(collectionName: string, filterUuid: string)
|
|
88
|
+
|
|
72
89
|
Retrieves the count of items from a collection based on a filter UUID.
|
|
73
90
|
|
|
74
91
|
**collectionName:** The name of the collection to retrieve items from.
|
|
75
92
|
**filterUuid:** The UUID of the filter to apply.
|
|
76
93
|
|
|
77
|
-
### Example:
|
|
94
|
+
### Example:
|
|
95
|
+
|
|
78
96
|
```
|
|
79
97
|
const itemCount = await drapcodeApi.getItemsCountWithFilter("users", "15263");
|
|
80
98
|
```
|
|
99
|
+
|
|
81
100
|
Retrieves the count of items from the "users" collection based on the filter UUID "15263".
|
|
82
101
|
|
|
83
102
|
## getItemWithUuid(collectionName: string, itemUuid: string)
|
|
103
|
+
|
|
84
104
|
Retrieves a specific item from a collection based on its UUID.
|
|
85
105
|
|
|
86
106
|
**collectionName:** The name of the collection to retrieve the item from.
|
|
87
107
|
**itemUuid:** The UUID of the item to retrieve.
|
|
88
|
-
|
|
108
|
+
|
|
109
|
+
### Example:
|
|
110
|
+
|
|
89
111
|
```
|
|
90
112
|
const item = await drapcodeApi.getItemWithUuid("users", "3487-383");
|
|
91
113
|
```
|
|
114
|
+
|
|
92
115
|
Retrieves a specific item from the "users" collection with the UUID "3487-383".
|
|
93
116
|
|
|
94
117
|
## updateItemWithUuid(collectionName: string, itemUuid: string, body: any)
|
|
118
|
+
|
|
95
119
|
Updates a specific item in a collection based on its UUID.
|
|
96
120
|
|
|
97
121
|
**collectionName:** The name of the collection containing the item.
|
|
98
122
|
**itemUuid:** The UUID of the item to update.
|
|
99
123
|
**body:** The updated data for the item.
|
|
100
|
-
|
|
124
|
+
|
|
125
|
+
### Example:
|
|
126
|
+
|
|
101
127
|
```
|
|
102
128
|
await drapcodeApi.updateItemWithUuid("users", "3487-383", {"name": "Drapcode"});
|
|
103
129
|
```
|
|
130
|
+
|
|
104
131
|
Updates the item in the "users" collection with the UUID "3487-383" with the provided data.
|
|
105
132
|
|
|
106
133
|
## deleteItemWithUuid(collectionName: string, itemUuid: string)
|
|
134
|
+
|
|
107
135
|
Deletes a specific item from a collection based on its UUID.
|
|
108
136
|
|
|
109
137
|
**collectionName:** The name of the collection containing the item.
|
|
110
138
|
**itemUuid:** The UUID of the item to delete.
|
|
111
|
-
|
|
139
|
+
|
|
140
|
+
### Example:
|
|
141
|
+
|
|
112
142
|
```
|
|
113
143
|
await drapcodeApi.deleteItemWithUuid("users", "3487-383");
|
|
114
144
|
```
|
|
145
|
+
|
|
115
146
|
Deletes the item with the UUID "3487-383" from the "users" collection.
|
|
116
147
|
|
|
117
148
|
## sendEmail(templateId: string, sendTo: string)
|
|
149
|
+
|
|
118
150
|
Sends an email using the specified email template ID.
|
|
119
151
|
|
|
120
152
|
**templateId:** The ID of the email template to use.
|
|
121
153
|
**sendTo:** The email address to send the email to.
|
|
122
|
-
|
|
154
|
+
|
|
155
|
+
### Example:
|
|
156
|
+
|
|
123
157
|
```
|
|
124
158
|
await drapcodeApi.sendEmail("345-678", "support@drapcode.com");
|
|
125
159
|
```
|
|
160
|
+
|
|
126
161
|
Sends an email using the template ID "345-678" to the email address "support@drapcode.com".
|
|
127
162
|
|
|
128
163
|
For better experience, utilize async/await syntax when using these methods.
|
package/build/index.js
CHANGED
|
@@ -56,9 +56,9 @@ var DrapcodeApis = /** @class */ (function () {
|
|
|
56
56
|
case "PREVIEW":
|
|
57
57
|
return "https://".concat(this.project_seo_name, ".api.preview.").concat(this.API_PATH);
|
|
58
58
|
case "BETA":
|
|
59
|
-
return "https://".concat(this.project_seo_name, ".api.
|
|
59
|
+
return "https://".concat(this.project_seo_name, ".api.sandbox.").concat(this.API_PATH);
|
|
60
60
|
case "ALPHA":
|
|
61
|
-
return "https://".concat(this.project_seo_name, ".api.
|
|
61
|
+
return "https://".concat(this.project_seo_name, ".api.uat.").concat(this.API_PATH);
|
|
62
62
|
default:
|
|
63
63
|
return "https://".concat(this.project_seo_name, ".api.").concat(this.API_PATH);
|
|
64
64
|
}
|