|
1 | | -# sendx-javascript-sdk |
2 | | - |
3 | | -sendx - JavaScript client for sendx-javascript-sdk |
4 | | -# SendX REST API Documentation |
| 1 | +# SendX JavaScript SDK |
5 | 2 |
|
6 | 3 | ## 🚀 Introduction |
7 | 4 |
|
@@ -52,9 +49,9 @@ SendX uses encrypted IDs for security and better developer experience: |
52 | 49 | **Example:** |
53 | 50 | ```json |
54 | 51 | { |
55 | | - \"id\": \"contact_BnKjkbBBS500CoBCP0oChQ\", |
56 | | - \"lists\": [\"list_OcuxJHdiAvujmwQVJfd3ss\", \"list_0tOFLp5RgV7s3LNiHrjGYs\"], |
57 | | - \"tags\": [\"tag_UhsDkjL772Qbj5lWtT62VK\", \"tag_fL7t9lsnZ9swvx2HrtQ9wM\"] |
| 52 | + "id": "contact_BnKjkbBBS500CoBCP0oChQ", |
| 53 | + "lists": ["list_OcuxJHdiAvujmwQVJfd3ss", "list_0tOFLp5RgV7s3LNiHrjGYs"], |
| 54 | + "tags": ["tag_UhsDkjL772Qbj5lWtT62VK", "tag_fL7t9lsnZ9swvx2HrtQ9wM"] |
58 | 55 | } |
59 | 56 | ``` |
60 | 57 |
|
@@ -115,119 +112,49 @@ Need help? Contact us: |
115 | 112 |
|
116 | 113 | [<img src=\"https://run.pstmn.io/button.svg\" alt=\"Run In Postman\" style=\"width: 128px; height: 32px;\">](https://god.gw.postman.com/run-collection/33476323-44b198b0-5219-4619-a01f-cfc24d573885?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D33476323-44b198b0-5219-4619-a01f-cfc24d573885%26entityType%3Dcollection%26workspaceId%3D6b1e4f65-96a9-4136-9512-6266c852517e) |
117 | 114 |
|
118 | | -This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: |
119 | | - |
120 | | -- API version: 1.0.0 |
121 | | -- Package version: 1.0.0 |
122 | | -- Generator version: 7.13.0 |
123 | | -- Build package: org.openapitools.codegen.languages.JavascriptClientCodegen |
124 | | -For more information, please visit [https://sendx.io](https://sendx.io) |
125 | 115 |
|
126 | 116 | ## Installation |
127 | 117 |
|
128 | 118 | ### For [Node.js](https://nodejs.org/) |
129 | 119 |
|
130 | 120 | #### npm |
131 | 121 |
|
132 | | -To publish the library as a [npm](https://www.npmjs.com/), please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages). |
133 | | - |
134 | | -Then install it via: |
135 | | - |
136 | | -```shell |
137 | | -npm install sendx-javascript-sdk --save |
138 | | -``` |
139 | | - |
140 | | -Finally, you need to build the module: |
141 | | - |
142 | | -```shell |
143 | | -npm run build |
144 | | -``` |
145 | | - |
146 | | -##### Local development |
147 | | - |
148 | | -To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run: |
149 | | - |
150 | | -```shell |
151 | | -npm install |
152 | | -``` |
153 | | - |
154 | | -Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`: |
155 | | - |
156 | | -```shell |
157 | | -npm link |
158 | | -``` |
159 | | - |
160 | | -To use the link you just defined in your project, switch to the directory you want to use your sendx-javascript-sdk from, and run: |
161 | | - |
162 | | -```shell |
163 | | -npm link /path/to/<JAVASCRIPT_CLIENT_DIR> |
164 | | -``` |
165 | | - |
166 | | -Finally, you need to build the module: |
167 | | - |
168 | | -```shell |
169 | | -npm run build |
170 | | -``` |
171 | | - |
172 | | -#### git |
173 | | - |
174 | | -If the library is hosted at a git repository, e.g.https://github.com/sendx/sendx-javascript-sdk |
175 | | -then install it via: |
176 | | - |
177 | | -```shell |
178 | | - npm install sendx/sendx-javascript-sdk --save |
179 | | -``` |
180 | | - |
181 | | -### For browser |
182 | 122 |
|
183 | | -The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following |
184 | | -the above steps with Node.js and installing browserify with `npm install -g browserify`, |
185 | | -perform the following (assuming *main.js* is your entry file): |
| 123 | +To install it via npm: |
186 | 124 |
|
187 | 125 | ```shell |
188 | | -browserify main.js > bundle.js |
189 | | -``` |
190 | | - |
191 | | -Then include *bundle.js* in the HTML pages. |
192 | | - |
193 | | -### Webpack Configuration |
194 | | - |
195 | | -Using Webpack you may encounter the following error: "Module not found: Error: |
196 | | -Cannot resolve module", most certainly you should disable AMD loader. Add/merge |
197 | | -the following section to your webpack config: |
198 | | - |
199 | | -```javascript |
200 | | -module: { |
201 | | - rules: [ |
202 | | - { |
203 | | - parser: { |
204 | | - amd: false |
205 | | - } |
206 | | - } |
207 | | - ] |
208 | | -} |
| 126 | +npm install sendx-javascript-sdk |
209 | 127 | ``` |
210 | 128 |
|
211 | 129 | ## Getting Started |
212 | 130 |
|
213 | 131 | Please follow the [installation](#installation) instruction and execute the following JS code: |
214 | 132 |
|
215 | 133 | ```javascript |
216 | | -var sendx = require('sendx-javascript-sdk'); |
| 134 | +import sendx from 'sendx-javascript-sdk'; |
217 | 135 |
|
218 | | -var defaultClient = sendx.ApiClient.instance; |
| 136 | +let defaultClient = sendx.ApiClient.instance; |
219 | 137 | // Configure API key authorization: TeamApiKey |
220 | 138 | var TeamApiKey = defaultClient.authentications['TeamApiKey']; |
221 | 139 | TeamApiKey.apiKey = "YOUR API KEY" |
222 | | -// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) |
223 | | -//TeamApiKey.apiKeyPrefix['X-Team-ApiKey'] = "Token" |
224 | | - |
225 | | -var api = new sendx.CampaignApi() |
226 | | -var restECampaign = {"name":"Flash Sale Announcement","subject":"⚡ 24-Hour Flash Sale - {{contact.firstName}}, Save 50%!","sender":"sender_4vK3WFhMgvOwUNyaL4QxCD","previewText":"Limited time offer - Today only!","htmlCode":"<html><body><h1>Flash Sale!</h1><p>Hi {{contact.firstName}},</p><p>Don't miss our 24-hour flash sale!</p><a href='{{sale.url}}'>Shop Now</a></body></html>","plainText":"Flash Sale!\n\nHi {{contact.firstName}},\n\nDon't miss our 24-hour flash sale!\n\nShop now: {{sale.url}}","scheduleType":1,"includedLists":["list_0tOFLp5RgV7s3LNiHrjGYs","list_vUCjsUmrVXtSppS8rD0Ssq"],"excludedTags":["tag_unengaged"]}; // {RestECampaign} |
227 | | -api.createCampaign(restECampaign).then(function(data) { |
228 | | - console.log('API called successfully. Returned data: ' + data); |
229 | | -}, function(error) { |
230 | | - console.error(error); |
| 140 | + |
| 141 | + |
| 142 | +let apiInstance = new sendx.ContactApi(); // ContactApi | |
| 143 | +let contactRequest = new sendx.ContactRequest(); // ContactRequest | |
| 144 | + |
| 145 | +contactRequest.email = "jane@doe.com"; |
| 146 | +contactRequest.firstName = "Jane"; |
| 147 | +contactRequest.lastName = "Doe"; |
| 148 | +contactRequest.company = "Tech Solutions Inc."; |
| 149 | +contactRequest.lastTrackedIp = "34.94.159.140"; |
| 150 | +contactRequest.customFields = { "1231nfenife213": "VIP", "1434bife23bfij32": "Special Offer Subscriber" }; |
| 151 | +contactRequest.lists = ["234b324bjed32", "234bij3e2eyv3v2i"]; |
| 152 | +contactRequest.tags = ["234bijn2ei2jbu4", "2342bijhb2ijneni"]; |
| 153 | + |
| 154 | +apiInstance.createContact(contactRequest).then((data) => { |
| 155 | + console.log('API called successfully. Contact created: ' + JSON.stringify(data, null, 2)); |
| 156 | +}, (error) => { |
| 157 | + console.error(error); |
231 | 158 | }); |
232 | 159 |
|
233 | 160 |
|
|
0 commit comments