swiftyper-node 1.0.4 → 1.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/lib/Error.js CHANGED
@@ -15,7 +15,7 @@ class SwiftyperError extends Error {
15
15
  }
16
16
 
17
17
  static generate(rawSwiftyperError) {
18
- switch (rawSwiftyperError.code) {
18
+ switch (rawSwiftyperError.type) {
19
19
  case 'over_query_limit':
20
20
  return new SwiftyperQuotaError(rawSwiftyperError);
21
21
  case 'missing':
@@ -192,8 +192,9 @@ SwiftyperResource.prototype = {
192
192
  : this._swiftyper.getMaxNetworkRetries();
193
193
  },
194
194
 
195
- _makeHeaders(contentLength, method, userSuppliedHeaders) {
195
+ _makeHeaders(auth, contentLength, method, userSuppliedHeaders) {
196
196
  const defaultHeaders = {
197
+ 'X-Swiftyper-API-Key': auth || this._swiftyper.getApiField('auth'),
197
198
  Accept: 'application/json',
198
199
  'Content-Type': 'application/x-www-form-urlencoded',
199
200
  'Content-Length': contentLength,
@@ -209,7 +210,6 @@ SwiftyperResource.prototype = {
209
210
  let requestData;
210
211
 
211
212
  data.__req = requests++;
212
- data.api_key = auth ? auth : this._swiftyper.getApiField('auth');
213
213
 
214
214
  const retryRequest = (requestFn, headers, requestRetries, retryAfter) => {
215
215
  return setTimeout(
@@ -313,6 +313,7 @@ SwiftyperResource.prototype = {
313
313
  requestData = data;
314
314
 
315
315
  const headers = this._makeHeaders(
316
+ auth,
316
317
  requestData.length,
317
318
  method,
318
319
  options.headers,
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ const SwiftyperResource = require('../SwiftyperResource');
4
+ const swiftyperMethod = SwiftyperResource.method;
5
+
6
+ module.exports = SwiftyperResource.extend({
7
+ path: 'intl/fbt',
8
+
9
+ init: swiftyperMethod({
10
+ method: 'POST',
11
+ path: '/initialize',
12
+ }),
13
+ });
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ const SwiftyperResource = require('../SwiftyperResource');
4
+ const swiftyperMethod = SwiftyperResource.method;
5
+
6
+ module.exports = SwiftyperResource.extend({
7
+ path: 'intl/phrases',
8
+
9
+ query: swiftyperMethod({
10
+ method: 'POST',
11
+ path: '/query',
12
+ }),
13
+
14
+ upload: swiftyperMethod({
15
+ method: 'POST',
16
+ path: '/upload',
17
+ }),
18
+
19
+ raw: swiftyperMethod({
20
+ method: 'GET',
21
+ path: '/raw',
22
+ }),
23
+ });
package/lib/resources.js CHANGED
@@ -3,5 +3,7 @@
3
3
  module.exports = {
4
4
  Translations: require('./resources/Translation'),
5
5
  Business: require('./resources/Business'),
6
+ Phrases: require('./resources/Phrase'),
6
7
  Places: require('./resources/Places'),
8
+ Fbt: require('./resources/Fbt'),
7
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swiftyper-node",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Swiftyper API",
5
5
  "keywords": [
6
6
  "swiftyper",