1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | 'use strict';
|
8 |
|
9 | var QueryRequest = require('./query_request').QueryRequest;
|
10 | var util = require('util');
|
11 |
|
12 | exports.TextRequest = module.exports.TextRequest = TextRequest;
|
13 |
|
14 | util.inherits(TextRequest, QueryRequest);
|
15 |
|
16 | function TextRequest (application, query, options) {
|
17 | TextRequest.super_.apply(this, [application, options]);
|
18 |
|
19 | var self = this;
|
20 | self.query = query;
|
21 | }
|
22 |
|
23 | TextRequest.prototype._headers = function() {
|
24 | var headers = TextRequest.super_.prototype._headers.apply(this, arguments);
|
25 |
|
26 | headers['Content-Type'] = 'application/json; charset=utf-8';
|
27 |
|
28 | return headers;
|
29 | };
|
30 |
|
31 | TextRequest.prototype._jsonRequestParameters = function() {
|
32 | var self = this;
|
33 |
|
34 | var json = TextRequest.super_.prototype._jsonRequestParameters.apply(this, arguments);
|
35 |
|
36 | json['query'] = self.query;
|
37 |
|
38 | return json;
|
39 | };
|
40 |
|
41 | TextRequest.prototype.end = function() {
|
42 | var self = this;
|
43 |
|
44 | self.write(JSON.stringify(self._jsonRequestParameters()));
|
45 |
|
46 | TextRequest.super_.prototype.end.apply(this, arguments);
|
47 | };
|