grenton-ts 1.0.0
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/LICENSE +21 -0
- package/README.md +86 -0
- package/dist/analog-din/fv02_01/analog-in.ts +271 -0
- package/dist/clu/calendar/v1/calendar.ts +308 -0
- package/dist/clu/clu-zwave-2/fv515_03/clu-zwave-2.ts +1302 -0
- package/dist/clu/event-scheduler/v1/event-scheduler.ts +537 -0
- package/dist/clu/multi-fan-ac-thermostat/v1/multi-fan-ac-thermostat.ts +1163 -0
- package/dist/clu/pid-controller/v1/pid-controller.ts +536 -0
- package/dist/clu/presence-sensor/v1/presence-sensor.ts +313 -0
- package/dist/clu/presence-sensor/v2/presence-sensor.ts +470 -0
- package/dist/clu/push/v1/push.ts +261 -0
- package/dist/clu/scheduler/v1/scheduler.ts +304 -0
- package/dist/clu/statistics/v1/statistics.ts +413 -0
- package/dist/clu/statistics-pulse/v1/statistics-pulse.ts +218 -0
- package/dist/clu/sunrise-sunset-calendar/v1/sunrise-sunset-calendar.ts +389 -0
- package/dist/clu/sunrise-sunset-calendar/v2/sunrise-sunset-calendar.ts +659 -0
- package/dist/clu/sunrise-sunset-calendar/v3/sunrise-sunset-calendar.ts +659 -0
- package/dist/clu/thermostat/v1/thermostat.ts +768 -0
- package/dist/clu/thermostat/v2/thermostat.ts +861 -0
- package/dist/clu/timer/v1/timer.ts +369 -0
- package/dist/core/execution-builder.ts +55 -0
- package/dist/core/remote-gate.ts +17 -0
- package/dist/digital-in-din/fv02_01/din.ts +310 -0
- package/dist/examples/light_turned_on_by_calendar/Clu_OnInit.ts +26 -0
- package/dist/examples/light_turned_on_by_presence_sensor/Clu_OnInit.ts +35 -0
- package/dist/examples/light_turned_on_by_switch/Clu_OnInit.ts +16 -0
- package/dist/gate/cool-master/v1/cool-master.ts +782 -0
- package/dist/gate/cool-master-net/v1/cool-master-net.ts +334 -0
- package/dist/gate/denon-marantz-avr/v1/denon-marantz-avr.ts +724 -0
- package/dist/gate/heos/v1/heos.ts +1224 -0
- package/dist/gate/http/fv1000_03/clu-gate-http.ts +405 -0
- package/dist/gate/http/fv1000_03_hv1/clu-gate-http.ts +352 -0
- package/dist/gate/http/fv1100_03/clu-gate-http.ts +589 -0
- package/dist/gate/http/fv1110_03/clu-gate-http.ts +589 -0
- package/dist/gate/http/fv1300_03/clu-gate-http.ts +589 -0
- package/dist/gate/http/fv1400_03/clu-gate-http.ts +677 -0
- package/dist/gate/http-listener/v1/http-listener.ts +299 -0
- package/dist/gate/http-listener/v2/http-listener.ts +325 -0
- package/dist/gate/http-request/v1/http-request.ts +645 -0
- package/dist/gate/http-request/v2/http-request.ts +709 -0
- package/dist/gate/input/v1/input.ts +171 -0
- package/dist/gate/jablotron/v1/jablotron.ts +100 -0
- package/dist/gate/jablotron-device/v1/jablotron-device.ts +171 -0
- package/dist/gate/jablotron-output/v1/jablotron-output.ts +240 -0
- package/dist/gate/jablotron-section/v1/jablotron-section.ts +260 -0
- package/dist/gate/modbus/v1/modbus.ts +609 -0
- package/dist/gate/modbus/v2/modbus.ts +690 -0
- package/dist/gate/modbus-client/v1/modbus-client.ts +827 -0
- package/dist/gate/modbus-rtu/v1/modbus-rtu.ts +911 -0
- package/dist/gate/modbus-server/v1/modbus-server.ts +405 -0
- package/dist/gate/modbus-slave-config-rtu/v1/modbus-slave-config-rtu.ts +160 -0
- package/dist/gate/modbus-slave-rtu/v1/modbus-slave-rtu.ts +371 -0
- package/dist/gate/modbus-value/v1/modbus-value.ts +856 -0
- package/dist/gate/music-cast/v1/music-cast.ts +1298 -0
- package/dist/gate/output/v1/output.ts +240 -0
- package/dist/gate/satel/v1/satel.ts +359 -0
- package/dist/gate/satel-input/v1/satel-input.ts +171 -0
- package/dist/gate/satel-output/v1/satel-output.ts +240 -0
- package/dist/gate/satel-zone/v1/satel-zone.ts +235 -0
- package/dist/gate/sonos/v1/sonos.ts +934 -0
- package/dist/gate/timer/v2/timer.ts +253 -0
- package/dist/gate/zone/v1/zone.ts +235 -0
- package/dist/io-module-din-8/fv02_02/din.ts +354 -0
- package/dist/io-module-din-8/fv02_02/dout.ts +360 -0
- package/dist/one-wire/fv01_10/onew-sensor.ts +269 -0
- package/dist/one-wire/fv01_28/onew-sensor.ts +269 -0
- package/dist/one-wire/fv02_28/onew-sensor.ts +350 -0
- package/dist/one-wire/fv03_28/onew-sensor.ts +435 -0
- package/dist/relay-din-2/fv02_02/dout.ts +544 -0
- package/dist/relay-din-4/fv01_02/dout.ts +340 -0
- package/dist/relay-din-4/fv02_02/dout.ts +368 -0
- package/dist/roller-shutter-din-3/fv03_02/roller-shutter.ts +1078 -0
- package/dist/smart-panel-fm-4/fv03_03/panel-button.ts +550 -0
- package/dist/smart-panel-fm-4/fv03_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv03_03/panel-sens-temp.ts +239 -0
- package/dist/smart-panel-fm-4/fv03_03/panel.ts +700 -0
- package/dist/smart-panel-fm-4/fv04_03/panel-button.ts +567 -0
- package/dist/smart-panel-fm-4/fv04_03/panel-page.ts +516 -0
- package/dist/smart-panel-fm-4/fv04_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv04_03/panel-sens-temp.ts +239 -0
- package/dist/smart-panel-fm-4/fv04_03/panel.ts +1026 -0
- package/dist/smart-panel-fm-4/fv05_03/panel-button.ts +567 -0
- package/dist/smart-panel-fm-4/fv05_03/panel-page.ts +620 -0
- package/dist/smart-panel-fm-4/fv05_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv05_03/panel-sens-temp.ts +266 -0
- package/dist/smart-panel-fm-4/fv05_03/panel.ts +1109 -0
- package/dist/smart-panel-fm-4/fv06_03/panel-button.ts +567 -0
- package/dist/smart-panel-fm-4/fv06_03/panel-page.ts +877 -0
- package/dist/smart-panel-fm-4/fv06_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv06_03/panel-sens-temp.ts +297 -0
- package/dist/smart-panel-fm-4/fv06_03/panel.ts +1138 -0
- package/dist/smart-panel-fm-4/fv07_03/panel-button.ts +567 -0
- package/dist/smart-panel-fm-4/fv07_03/panel-page.ts +864 -0
- package/dist/smart-panel-fm-4/fv07_03/panel-sens-light.ts +238 -0
- package/dist/smart-panel-fm-4/fv07_03/panel-sens-temp.ts +297 -0
- package/dist/smart-panel-fm-4/fv07_03/panel.ts +1135 -0
- package/dist/touch-panel-fm-4/fv01_02/panel-button.ts +418 -0
- package/dist/touch-panel-fm-4/fv01_02/panel-sens-light.ts +238 -0
- package/dist/touch-panel-fm-4/fv01_02/panel-sens-temp.ts +257 -0
- package/dist/touch-panel-fm-4/fv01_02/panel.ts +75 -0
- package/dist/touch-panel-fm-4/fv01_02/power-supply-voltage.ts +322 -0
- package/dist/touch-panel-fm-8/fv01_02/panel-button.ts +418 -0
- package/dist/touch-panel-fm-8/fv01_02/panel-sens-light.ts +238 -0
- package/dist/touch-panel-fm-8/fv01_02/panel-sens-temp.ts +270 -0
- package/dist/touch-panel-fm-8/fv01_02/panel.ts +75 -0
- package/dist/touch-panel-fm-8/fv01_02/power-supply-voltage.ts +322 -0
- package/package.json +16 -0
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
// Created from: packages/grenton-api/interfaces/object_http_request_v1.xml, object name="HttpRequest" version="1"
|
|
2
|
+
|
|
3
|
+
import { rawExecutionBuilderFactory } from "../../../core/execution-builder"
|
|
4
|
+
import { RemoteGate } from "../../../core/remote-gate"
|
|
5
|
+
|
|
6
|
+
enum EventType {
|
|
7
|
+
OnRequestSent = 0,
|
|
8
|
+
OnResponse = 1
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
enum PropertyType {
|
|
12
|
+
Host = 0,
|
|
13
|
+
Path = 1,
|
|
14
|
+
QueryStringParams = 2,
|
|
15
|
+
Method = 3,
|
|
16
|
+
Timeout = 4,
|
|
17
|
+
RequestType = 5,
|
|
18
|
+
ResponseType = 6,
|
|
19
|
+
RequestHeaders = 7,
|
|
20
|
+
RequestBody = 8,
|
|
21
|
+
ResponseBody = 10,
|
|
22
|
+
StatusCode = 11
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
enum MethodType {
|
|
26
|
+
SendRequest = 0,
|
|
27
|
+
AbortRequest = 1,
|
|
28
|
+
Clear = 2
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
enum RequestType {
|
|
32
|
+
None = 0,
|
|
33
|
+
Text = 1,
|
|
34
|
+
JSON = 2,
|
|
35
|
+
XML = 3,
|
|
36
|
+
FormData = 4,
|
|
37
|
+
Other = 5
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
enum ResponseType {
|
|
41
|
+
None = 0,
|
|
42
|
+
Text = 1,
|
|
43
|
+
JSON = 2,
|
|
44
|
+
XML = 3,
|
|
45
|
+
FormData = 4,
|
|
46
|
+
Other = 5
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare class HttpRequestRaw {
|
|
50
|
+
add_event(event: EventType, callback: () => void): void;
|
|
51
|
+
get(property: PropertyType): any;
|
|
52
|
+
set(property: PropertyType, value: any): void;
|
|
53
|
+
execute(method: MethodType, ...args: any[]): any;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface IHttpRequest {
|
|
57
|
+
/**
|
|
58
|
+
* Zdarzenie wywoływane w momencie wysłania zapytania
|
|
59
|
+
* @param callback
|
|
60
|
+
*/
|
|
61
|
+
addOnRequestSent: (callback: () => void) => void
|
|
62
|
+
/**
|
|
63
|
+
* Zdarzenie wywoływane w momencie otrzymania odpowiedzi
|
|
64
|
+
* @param callback
|
|
65
|
+
*/
|
|
66
|
+
addOnResponse: (callback: () => void) => void
|
|
67
|
+
/** Wysyła zapytanie */
|
|
68
|
+
sendRequest: () => void
|
|
69
|
+
/** Przerywa obsługę zapytania */
|
|
70
|
+
abortRequest: () => void
|
|
71
|
+
/** Usuwa treść zapytania */
|
|
72
|
+
clear: () => void
|
|
73
|
+
/** Adres hosta */
|
|
74
|
+
host: string
|
|
75
|
+
/** Ustawia adres hosta */
|
|
76
|
+
setHost: (value: string) => void
|
|
77
|
+
/** Ścieżka zapytania */
|
|
78
|
+
path: string
|
|
79
|
+
/** Ustawia ścieżkę zapytania */
|
|
80
|
+
setPath: (value: string) => void
|
|
81
|
+
/** Parametry zapytania */
|
|
82
|
+
queryStringParams: string
|
|
83
|
+
/** Ustawia parametry zapytania */
|
|
84
|
+
setQueryStringParams: (value: string) => void
|
|
85
|
+
/** Typ metody wysyłanej w zapytaniu np. GET, POST */
|
|
86
|
+
method: string
|
|
87
|
+
/** Ustawia metodę zapytania */
|
|
88
|
+
setMethod: (value: string) => void
|
|
89
|
+
/** Dopuszczalny czas odpowiedzi */
|
|
90
|
+
timeout: number
|
|
91
|
+
/** Ustawia dopuszczalny czas odpowiedzi */
|
|
92
|
+
setTimeout: (value: number) => void
|
|
93
|
+
/** Typ zawartości wysyłanego zapytania. Definiuje parametr content-type w nagłówku zapytania. W zależności od wybranego typu zawartość cechy RequestBody jest odpowiednio serializowana: 0 - None - niezdefiniowany. W nagłówku nie jest wysyłane content-type. Zawartość cechy RequestBody nie jest serializowana. 1 - Text - content-type: text/plain. Zawartość cechy RequestBody nie jest serializowana. 2 - JSON - content-type: application/json. Zawartość cechy RequestBody jest serializowana do formatu JSON. 3 - XML - content-type: text/xml. Zawartość cechy RequestBody jest serializowana do formatu XML. 4 - FormData - content-type: application/x-www-form-urlencoded. Zawartość cechy RequestBody jest serializowana do tabeli. 5 - Other - typ zawartości (content-type) jest inny niż wbudowany. Typ można zdefiniować umieszczając go w nagłówku (cecha RequestHeaders). Zawartość nie jest serializowana. */
|
|
94
|
+
requestType: RequestType
|
|
95
|
+
/** Ustawia typ zawartości wysyłanego zapytania (content-type) */
|
|
96
|
+
setRequestType: (value: RequestType) => void
|
|
97
|
+
/** Typ oczekiwanej odpowiedzi. Definiuje parametr Accept w nagłówku zapytania. W zależności od wybranego typu zawartość otrzymanej odpowiedzi (cechy ResponseBody) jest odpowiednio parsowana do tabeli: 0 - None - parametr Accept nie jest wysyłany w nagłówku wysyłanego zapytania. Odpowiedź (cecha ResponseBody) nie jest parsowana. 1 - Text - Accept: text/plain. Odpowiedź (cecha ResponseBody) nie jest parsowana. 2 - JSON - Accept: application/json. Odpowiedź (cecha ResponseBody) jest parsowana z JSON. 3 - XML - Accept: text/xml. Odpowiedź (cecha ResponseBody) jest parsowana z XML. 4 - FormData - Accept: application/x-www-form-urlencoded. Odpowiedź (cecha ResponseBody) jest parsowana. 5 - Other - parametr Accept nagłówka jest inny niż wbudowany. Parametr można zdefiniować umieszczając go w nagłówku (cecha RequestHeaders) */
|
|
98
|
+
responseType: ResponseType
|
|
99
|
+
/** Ustawia typ oczekiwanej odpowiedzi na zapytanie */
|
|
100
|
+
setResponseType: (value: ResponseType) => void
|
|
101
|
+
/** Dodatkowe nagłówki zapytania HTTP */
|
|
102
|
+
requestHeaders: string
|
|
103
|
+
/** Ustawia dodatkowe nagłówki HTTP w zapytaniu */
|
|
104
|
+
setRequestHeaders: (value: string) => void
|
|
105
|
+
/** Zawartość wiadomości wysyłanej w zapytaniu */
|
|
106
|
+
requestBody: string
|
|
107
|
+
/** Ustawia zawartość wiadomości w zapytaniu */
|
|
108
|
+
setRequestBody: (value: string) => void
|
|
109
|
+
/** Zawartość wiadomości otrzymanej po wysłaniu zapytania */
|
|
110
|
+
responseBody: string
|
|
111
|
+
/** Ustawia zawartość wiadomości w odpowiedzi */
|
|
112
|
+
setResponseBody: (value: string) => void
|
|
113
|
+
/** Status odpowiedzi HTTP */
|
|
114
|
+
readonly statusCode: number
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
class HttpRequest implements IHttpRequest {
|
|
118
|
+
private onRequestSentCallbacks: Array<() => void> = [];
|
|
119
|
+
private onResponseCallbacks: Array<() => void> = [];
|
|
120
|
+
|
|
121
|
+
constructor(private raw: HttpRequestRaw) {
|
|
122
|
+
this.raw.add_event(EventType.OnRequestSent, () => {
|
|
123
|
+
this.onRequestSentCallbacks.forEach(callback => { callback(); });
|
|
124
|
+
});
|
|
125
|
+
this.raw.add_event(EventType.OnResponse, () => {
|
|
126
|
+
this.onResponseCallbacks.forEach(callback => { callback(); });
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Zdarzenie wywoływane w momencie wysłania zapytania
|
|
132
|
+
* @param callback
|
|
133
|
+
*/
|
|
134
|
+
addOnRequestSent(callback: () => void): void {
|
|
135
|
+
this.onRequestSentCallbacks.push(callback);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Zdarzenie wywoływane w momencie otrzymania odpowiedzi
|
|
139
|
+
* @param callback
|
|
140
|
+
*/
|
|
141
|
+
addOnResponse(callback: () => void): void {
|
|
142
|
+
this.onResponseCallbacks.push(callback);
|
|
143
|
+
}
|
|
144
|
+
/** Wysyła zapytanie */
|
|
145
|
+
sendRequest(): void {
|
|
146
|
+
this.raw.execute(MethodType.SendRequest);
|
|
147
|
+
}
|
|
148
|
+
/** Przerywa obsługę zapytania */
|
|
149
|
+
abortRequest(): void {
|
|
150
|
+
this.raw.execute(MethodType.AbortRequest);
|
|
151
|
+
}
|
|
152
|
+
/** Usuwa treść zapytania */
|
|
153
|
+
clear(): void {
|
|
154
|
+
this.raw.execute(MethodType.Clear);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Adres hosta
|
|
158
|
+
* @returns {string}
|
|
159
|
+
*/
|
|
160
|
+
get host(): string {
|
|
161
|
+
return this.raw.get(PropertyType.Host);
|
|
162
|
+
}
|
|
163
|
+
set host(value: string) {
|
|
164
|
+
this.raw.set(PropertyType.Host, value);
|
|
165
|
+
}
|
|
166
|
+
/** Ustawia adres hosta */
|
|
167
|
+
setHost(value: string): void {
|
|
168
|
+
this.raw.set(PropertyType.Host, value);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Ścieżka zapytania
|
|
172
|
+
* @returns {string}
|
|
173
|
+
*/
|
|
174
|
+
get path(): string {
|
|
175
|
+
return this.raw.get(PropertyType.Path);
|
|
176
|
+
}
|
|
177
|
+
set path(value: string) {
|
|
178
|
+
this.raw.set(PropertyType.Path, value);
|
|
179
|
+
}
|
|
180
|
+
/** Ustawia ścieżkę zapytania */
|
|
181
|
+
setPath(value: string): void {
|
|
182
|
+
this.raw.set(PropertyType.Path, value);
|
|
183
|
+
}
|
|
184
|
+
get queryStringParams(): string {
|
|
185
|
+
return this.raw.get(PropertyType.QueryStringParams);
|
|
186
|
+
}
|
|
187
|
+
set queryStringParams(value: string) {
|
|
188
|
+
this.raw.set(PropertyType.QueryStringParams, value);
|
|
189
|
+
}
|
|
190
|
+
/** Ustawia parametry zapytania */
|
|
191
|
+
setQueryStringParams(value: string): void {
|
|
192
|
+
this.raw.set(PropertyType.QueryStringParams, value);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Typ metody wysyłanej w zapytaniu np. GET, POST
|
|
196
|
+
* @returns {string}
|
|
197
|
+
*/
|
|
198
|
+
get method(): string {
|
|
199
|
+
return this.raw.get(PropertyType.Method);
|
|
200
|
+
}
|
|
201
|
+
set method(value: string) {
|
|
202
|
+
this.raw.set(PropertyType.Method, value);
|
|
203
|
+
}
|
|
204
|
+
/** Ustawia metodę zapytania */
|
|
205
|
+
setMethod(value: string): void {
|
|
206
|
+
this.raw.set(PropertyType.Method, value);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Dopuszczalny czas odpowiedzi
|
|
210
|
+
* @returns {number}
|
|
211
|
+
*/
|
|
212
|
+
get timeout(): number {
|
|
213
|
+
return this.raw.get(PropertyType.Timeout);
|
|
214
|
+
}
|
|
215
|
+
set timeout(value: number) {
|
|
216
|
+
this.raw.set(PropertyType.Timeout, value);
|
|
217
|
+
}
|
|
218
|
+
/** Ustawia dopuszczalny czas odpowiedzi */
|
|
219
|
+
setTimeout(value: number): void {
|
|
220
|
+
this.raw.set(PropertyType.Timeout, value);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Typ zawartości wysyłanego zapytania. Definiuje parametr content-type w nagłówku zapytania. W zależności od wybranego typu zawartość cechy RequestBody jest odpowiednio serializowana: 0 - None - niezdefiniowany. W nagłówku nie jest wysyłane content-type. Zawartość cechy RequestBody nie jest serializowana. 1 - Text - content-type: text/plain. Zawartość cechy RequestBody nie jest serializowana. 2 - JSON - content-type: application/json. Zawartość cechy RequestBody jest serializowana do formatu JSON. 3 - XML - content-type: text/xml. Zawartość cechy RequestBody jest serializowana do formatu XML. 4 - FormData - content-type: application/x-www-form-urlencoded. Zawartość cechy RequestBody jest serializowana do tabeli. 5 - Other - typ zawartości (content-type) jest inny niż wbudowany. Typ można zdefiniować umieszczając go w nagłówku (cecha RequestHeaders). Zawartość nie jest serializowana.
|
|
224
|
+
* @returns {RequestType}
|
|
225
|
+
*/
|
|
226
|
+
get requestType(): RequestType {
|
|
227
|
+
return this.raw.get(PropertyType.RequestType);
|
|
228
|
+
}
|
|
229
|
+
set requestType(value: RequestType) {
|
|
230
|
+
this.raw.set(PropertyType.RequestType, value);
|
|
231
|
+
}
|
|
232
|
+
/** Ustawia typ zawartości wysyłanego zapytania (content-type) */
|
|
233
|
+
setRequestType(value: RequestType): void {
|
|
234
|
+
this.raw.set(PropertyType.RequestType, value);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Typ oczekiwanej odpowiedzi. Definiuje parametr Accept w nagłówku zapytania. W zależności od wybranego typu zawartość otrzymanej odpowiedzi (cechy ResponseBody) jest odpowiednio parsowana do tabeli: 0 - None - parametr Accept nie jest wysyłany w nagłówku wysyłanego zapytania. Odpowiedź (cecha ResponseBody) nie jest parsowana. 1 - Text - Accept: text/plain. Odpowiedź (cecha ResponseBody) nie jest parsowana. 2 - JSON - Accept: application/json. Odpowiedź (cecha ResponseBody) jest parsowana z JSON. 3 - XML - Accept: text/xml. Odpowiedź (cecha ResponseBody) jest parsowana z XML. 4 - FormData - Accept: application/x-www-form-urlencoded. Odpowiedź (cecha ResponseBody) jest parsowana. 5 - Other - parametr Accept nagłówka jest inny niż wbudowany. Parametr można zdefiniować umieszczając go w nagłówku (cecha RequestHeaders)
|
|
238
|
+
* @returns {ResponseType}
|
|
239
|
+
*/
|
|
240
|
+
get responseType(): ResponseType {
|
|
241
|
+
return this.raw.get(PropertyType.ResponseType);
|
|
242
|
+
}
|
|
243
|
+
set responseType(value: ResponseType) {
|
|
244
|
+
this.raw.set(PropertyType.ResponseType, value);
|
|
245
|
+
}
|
|
246
|
+
/** Ustawia typ oczekiwanej odpowiedzi na zapytanie */
|
|
247
|
+
setResponseType(value: ResponseType): void {
|
|
248
|
+
this.raw.set(PropertyType.ResponseType, value);
|
|
249
|
+
}
|
|
250
|
+
get requestHeaders(): string {
|
|
251
|
+
return this.raw.get(PropertyType.RequestHeaders);
|
|
252
|
+
}
|
|
253
|
+
set requestHeaders(value: string) {
|
|
254
|
+
this.raw.set(PropertyType.RequestHeaders, value);
|
|
255
|
+
}
|
|
256
|
+
/** Ustawia dodatkowe nagłówki HTTP w zapytaniu */
|
|
257
|
+
setRequestHeaders(value: string): void {
|
|
258
|
+
this.raw.set(PropertyType.RequestHeaders, value);
|
|
259
|
+
}
|
|
260
|
+
get requestBody(): string {
|
|
261
|
+
return this.raw.get(PropertyType.RequestBody);
|
|
262
|
+
}
|
|
263
|
+
set requestBody(value: string) {
|
|
264
|
+
this.raw.set(PropertyType.RequestBody, value);
|
|
265
|
+
}
|
|
266
|
+
/** Ustawia zawartość wiadomości w zapytaniu */
|
|
267
|
+
setRequestBody(value: string): void {
|
|
268
|
+
this.raw.set(PropertyType.RequestBody, value);
|
|
269
|
+
}
|
|
270
|
+
get responseBody(): string {
|
|
271
|
+
return this.raw.get(PropertyType.ResponseBody);
|
|
272
|
+
}
|
|
273
|
+
set responseBody(value: string) {
|
|
274
|
+
this.raw.set(PropertyType.ResponseBody, value);
|
|
275
|
+
}
|
|
276
|
+
/** Ustawia zawartość wiadomości w odpowiedzi */
|
|
277
|
+
setResponseBody(value: string): void {
|
|
278
|
+
this.raw.set(PropertyType.ResponseBody, value);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Status odpowiedzi HTTP
|
|
282
|
+
* @returns {number}
|
|
283
|
+
*/
|
|
284
|
+
get statusCode(): number {
|
|
285
|
+
return this.raw.get(PropertyType.StatusCode);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
class HttpRequestRemote implements IHttpRequest {
|
|
290
|
+
constructor(private objectName: string, private gate: RemoteGate) {
|
|
291
|
+
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Zdarzenie wywoływane w momencie wysłania zapytania
|
|
296
|
+
* @param callback
|
|
297
|
+
*/
|
|
298
|
+
addOnRequestSent(_callback: () => void): void {
|
|
299
|
+
// Remote events are not supported
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Zdarzenie wywoływane w momencie otrzymania odpowiedzi
|
|
303
|
+
* @param callback
|
|
304
|
+
*/
|
|
305
|
+
addOnResponse(_callback: () => void): void {
|
|
306
|
+
// Remote events are not supported
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** Wysyła zapytanie */
|
|
310
|
+
sendRequest(): void {
|
|
311
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
312
|
+
.execute()
|
|
313
|
+
.addParameter(MethodType.SendRequest)
|
|
314
|
+
.build();
|
|
315
|
+
this.gate.runScript(cmd!);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** Przerywa obsługę zapytania */
|
|
319
|
+
abortRequest(): void {
|
|
320
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
321
|
+
.execute()
|
|
322
|
+
.addParameter(MethodType.AbortRequest)
|
|
323
|
+
.build();
|
|
324
|
+
this.gate.runScript(cmd!);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** Usuwa treść zapytania */
|
|
328
|
+
clear(): void {
|
|
329
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
330
|
+
.execute()
|
|
331
|
+
.addParameter(MethodType.Clear)
|
|
332
|
+
.build();
|
|
333
|
+
this.gate.runScript(cmd!);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Adres hosta
|
|
338
|
+
* @returns {string}
|
|
339
|
+
*/
|
|
340
|
+
get host(): string {
|
|
341
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
342
|
+
.get()
|
|
343
|
+
.addParameter(PropertyType.Host)
|
|
344
|
+
.build();
|
|
345
|
+
return this.gate.runScript(cmd!);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
set host(value: string) {
|
|
349
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
350
|
+
.set()
|
|
351
|
+
.addParameter(PropertyType.Host)
|
|
352
|
+
.addParameter(value)
|
|
353
|
+
.build();
|
|
354
|
+
this.gate.runScript(cmd!);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** Ustawia adres hosta */
|
|
358
|
+
setHost(value: string): void {
|
|
359
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
360
|
+
.set()
|
|
361
|
+
.addParameter(PropertyType.Host)
|
|
362
|
+
.addParameter(value)
|
|
363
|
+
.build();
|
|
364
|
+
this.gate.runScript(cmd!);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Ścieżka zapytania
|
|
369
|
+
* @returns {string}
|
|
370
|
+
*/
|
|
371
|
+
get path(): string {
|
|
372
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
373
|
+
.get()
|
|
374
|
+
.addParameter(PropertyType.Path)
|
|
375
|
+
.build();
|
|
376
|
+
return this.gate.runScript(cmd!);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
set path(value: string) {
|
|
380
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
381
|
+
.set()
|
|
382
|
+
.addParameter(PropertyType.Path)
|
|
383
|
+
.addParameter(value)
|
|
384
|
+
.build();
|
|
385
|
+
this.gate.runScript(cmd!);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** Ustawia ścieżkę zapytania */
|
|
389
|
+
setPath(value: string): void {
|
|
390
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
391
|
+
.set()
|
|
392
|
+
.addParameter(PropertyType.Path)
|
|
393
|
+
.addParameter(value)
|
|
394
|
+
.build();
|
|
395
|
+
this.gate.runScript(cmd!);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
get queryStringParams(): string {
|
|
399
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
400
|
+
.get()
|
|
401
|
+
.addParameter(PropertyType.QueryStringParams)
|
|
402
|
+
.build();
|
|
403
|
+
return this.gate.runScript(cmd!);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
set queryStringParams(value: string) {
|
|
407
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
408
|
+
.set()
|
|
409
|
+
.addParameter(PropertyType.QueryStringParams)
|
|
410
|
+
.addParameter(value)
|
|
411
|
+
.build();
|
|
412
|
+
this.gate.runScript(cmd!);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** Ustawia parametry zapytania */
|
|
416
|
+
setQueryStringParams(value: string): void {
|
|
417
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
418
|
+
.set()
|
|
419
|
+
.addParameter(PropertyType.QueryStringParams)
|
|
420
|
+
.addParameter(value)
|
|
421
|
+
.build();
|
|
422
|
+
this.gate.runScript(cmd!);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Typ metody wysyłanej w zapytaniu np. GET, POST
|
|
427
|
+
* @returns {string}
|
|
428
|
+
*/
|
|
429
|
+
get method(): string {
|
|
430
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
431
|
+
.get()
|
|
432
|
+
.addParameter(PropertyType.Method)
|
|
433
|
+
.build();
|
|
434
|
+
return this.gate.runScript(cmd!);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
set method(value: string) {
|
|
438
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
439
|
+
.set()
|
|
440
|
+
.addParameter(PropertyType.Method)
|
|
441
|
+
.addParameter(value)
|
|
442
|
+
.build();
|
|
443
|
+
this.gate.runScript(cmd!);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/** Ustawia metodę zapytania */
|
|
447
|
+
setMethod(value: string): void {
|
|
448
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
449
|
+
.set()
|
|
450
|
+
.addParameter(PropertyType.Method)
|
|
451
|
+
.addParameter(value)
|
|
452
|
+
.build();
|
|
453
|
+
this.gate.runScript(cmd!);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Dopuszczalny czas odpowiedzi
|
|
458
|
+
* @returns {number}
|
|
459
|
+
*/
|
|
460
|
+
get timeout(): number {
|
|
461
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
462
|
+
.get()
|
|
463
|
+
.addParameter(PropertyType.Timeout)
|
|
464
|
+
.build();
|
|
465
|
+
return this.gate.runScript(cmd!);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
set timeout(value: number) {
|
|
469
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
470
|
+
.set()
|
|
471
|
+
.addParameter(PropertyType.Timeout)
|
|
472
|
+
.addParameter(value)
|
|
473
|
+
.build();
|
|
474
|
+
this.gate.runScript(cmd!);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** Ustawia dopuszczalny czas odpowiedzi */
|
|
478
|
+
setTimeout(value: number): void {
|
|
479
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
480
|
+
.set()
|
|
481
|
+
.addParameter(PropertyType.Timeout)
|
|
482
|
+
.addParameter(value)
|
|
483
|
+
.build();
|
|
484
|
+
this.gate.runScript(cmd!);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Typ zawartości wysyłanego zapytania. Definiuje parametr content-type w nagłówku zapytania. W zależności od wybranego typu zawartość cechy RequestBody jest odpowiednio serializowana: 0 - None - niezdefiniowany. W nagłówku nie jest wysyłane content-type. Zawartość cechy RequestBody nie jest serializowana. 1 - Text - content-type: text/plain. Zawartość cechy RequestBody nie jest serializowana. 2 - JSON - content-type: application/json. Zawartość cechy RequestBody jest serializowana do formatu JSON. 3 - XML - content-type: text/xml. Zawartość cechy RequestBody jest serializowana do formatu XML. 4 - FormData - content-type: application/x-www-form-urlencoded. Zawartość cechy RequestBody jest serializowana do tabeli. 5 - Other - typ zawartości (content-type) jest inny niż wbudowany. Typ można zdefiniować umieszczając go w nagłówku (cecha RequestHeaders). Zawartość nie jest serializowana.
|
|
489
|
+
* @returns {RequestType}
|
|
490
|
+
*/
|
|
491
|
+
get requestType(): RequestType {
|
|
492
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
493
|
+
.get()
|
|
494
|
+
.addParameter(PropertyType.RequestType)
|
|
495
|
+
.build();
|
|
496
|
+
return this.gate.runScript(cmd!);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
set requestType(value: RequestType) {
|
|
500
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
501
|
+
.set()
|
|
502
|
+
.addParameter(PropertyType.RequestType)
|
|
503
|
+
.addParameter(value)
|
|
504
|
+
.build();
|
|
505
|
+
this.gate.runScript(cmd!);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/** Ustawia typ zawartości wysyłanego zapytania (content-type) */
|
|
509
|
+
setRequestType(value: RequestType): void {
|
|
510
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
511
|
+
.set()
|
|
512
|
+
.addParameter(PropertyType.RequestType)
|
|
513
|
+
.addParameter(value)
|
|
514
|
+
.build();
|
|
515
|
+
this.gate.runScript(cmd!);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Typ oczekiwanej odpowiedzi. Definiuje parametr Accept w nagłówku zapytania. W zależności od wybranego typu zawartość otrzymanej odpowiedzi (cechy ResponseBody) jest odpowiednio parsowana do tabeli: 0 - None - parametr Accept nie jest wysyłany w nagłówku wysyłanego zapytania. Odpowiedź (cecha ResponseBody) nie jest parsowana. 1 - Text - Accept: text/plain. Odpowiedź (cecha ResponseBody) nie jest parsowana. 2 - JSON - Accept: application/json. Odpowiedź (cecha ResponseBody) jest parsowana z JSON. 3 - XML - Accept: text/xml. Odpowiedź (cecha ResponseBody) jest parsowana z XML. 4 - FormData - Accept: application/x-www-form-urlencoded. Odpowiedź (cecha ResponseBody) jest parsowana. 5 - Other - parametr Accept nagłówka jest inny niż wbudowany. Parametr można zdefiniować umieszczając go w nagłówku (cecha RequestHeaders)
|
|
520
|
+
* @returns {ResponseType}
|
|
521
|
+
*/
|
|
522
|
+
get responseType(): ResponseType {
|
|
523
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
524
|
+
.get()
|
|
525
|
+
.addParameter(PropertyType.ResponseType)
|
|
526
|
+
.build();
|
|
527
|
+
return this.gate.runScript(cmd!);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
set responseType(value: ResponseType) {
|
|
531
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
532
|
+
.set()
|
|
533
|
+
.addParameter(PropertyType.ResponseType)
|
|
534
|
+
.addParameter(value)
|
|
535
|
+
.build();
|
|
536
|
+
this.gate.runScript(cmd!);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/** Ustawia typ oczekiwanej odpowiedzi na zapytanie */
|
|
540
|
+
setResponseType(value: ResponseType): void {
|
|
541
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
542
|
+
.set()
|
|
543
|
+
.addParameter(PropertyType.ResponseType)
|
|
544
|
+
.addParameter(value)
|
|
545
|
+
.build();
|
|
546
|
+
this.gate.runScript(cmd!);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
get requestHeaders(): string {
|
|
550
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
551
|
+
.get()
|
|
552
|
+
.addParameter(PropertyType.RequestHeaders)
|
|
553
|
+
.build();
|
|
554
|
+
return this.gate.runScript(cmd!);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
set requestHeaders(value: string) {
|
|
558
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
559
|
+
.set()
|
|
560
|
+
.addParameter(PropertyType.RequestHeaders)
|
|
561
|
+
.addParameter(value)
|
|
562
|
+
.build();
|
|
563
|
+
this.gate.runScript(cmd!);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** Ustawia dodatkowe nagłówki HTTP w zapytaniu */
|
|
567
|
+
setRequestHeaders(value: string): void {
|
|
568
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
569
|
+
.set()
|
|
570
|
+
.addParameter(PropertyType.RequestHeaders)
|
|
571
|
+
.addParameter(value)
|
|
572
|
+
.build();
|
|
573
|
+
this.gate.runScript(cmd!);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
get requestBody(): string {
|
|
577
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
578
|
+
.get()
|
|
579
|
+
.addParameter(PropertyType.RequestBody)
|
|
580
|
+
.build();
|
|
581
|
+
return this.gate.runScript(cmd!);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
set requestBody(value: string) {
|
|
585
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
586
|
+
.set()
|
|
587
|
+
.addParameter(PropertyType.RequestBody)
|
|
588
|
+
.addParameter(value)
|
|
589
|
+
.build();
|
|
590
|
+
this.gate.runScript(cmd!);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** Ustawia zawartość wiadomości w zapytaniu */
|
|
594
|
+
setRequestBody(value: string): void {
|
|
595
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
596
|
+
.set()
|
|
597
|
+
.addParameter(PropertyType.RequestBody)
|
|
598
|
+
.addParameter(value)
|
|
599
|
+
.build();
|
|
600
|
+
this.gate.runScript(cmd!);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
get responseBody(): string {
|
|
604
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
605
|
+
.get()
|
|
606
|
+
.addParameter(PropertyType.ResponseBody)
|
|
607
|
+
.build();
|
|
608
|
+
return this.gate.runScript(cmd!);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
set responseBody(value: string) {
|
|
612
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
613
|
+
.set()
|
|
614
|
+
.addParameter(PropertyType.ResponseBody)
|
|
615
|
+
.addParameter(value)
|
|
616
|
+
.build();
|
|
617
|
+
this.gate.runScript(cmd!);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/** Ustawia zawartość wiadomości w odpowiedzi */
|
|
621
|
+
setResponseBody(value: string): void {
|
|
622
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
623
|
+
.set()
|
|
624
|
+
.addParameter(PropertyType.ResponseBody)
|
|
625
|
+
.addParameter(value)
|
|
626
|
+
.build();
|
|
627
|
+
this.gate.runScript(cmd!);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Status odpowiedzi HTTP
|
|
632
|
+
* @returns {number}
|
|
633
|
+
*/
|
|
634
|
+
get statusCode(): number {
|
|
635
|
+
const cmd: string | null = rawExecutionBuilderFactory(this.objectName)
|
|
636
|
+
.get()
|
|
637
|
+
.addParameter(PropertyType.StatusCode)
|
|
638
|
+
.build();
|
|
639
|
+
return this.gate.runScript(cmd!);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export {
|
|
644
|
+
HttpRequest, HttpRequestRaw, HttpRequestRemote, RequestType, ResponseType
|
|
645
|
+
}
|