2014-02-26 19:12:37 +00:00
|
|
|
declare module Typertext {
|
|
|
|
class BaseException<T> {
|
|
|
|
private code;
|
|
|
|
private custom;
|
|
|
|
private message;
|
|
|
|
constructor(message: string, code: number, custom: T);
|
|
|
|
public GetCode(): number;
|
|
|
|
public GetMessage(): string;
|
|
|
|
public GetCustom(): T;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext {
|
|
|
|
class GenericResponse<T> {
|
|
|
|
private status;
|
|
|
|
private headers;
|
|
|
|
private httpStatus;
|
|
|
|
private content;
|
2014-03-03 18:35:46 +00:00
|
|
|
constructor(status: Http.HttpResponseStatus, responseHeaderGetter?: (input: string) => string, httpResponseCode?: number, responseBody?: T);
|
2014-02-26 19:12:37 +00:00
|
|
|
public GetContent(): T;
|
|
|
|
public GetContentType(): string;
|
2014-03-03 18:35:46 +00:00
|
|
|
public GetHeader(name: string): string;
|
2014-02-26 19:12:37 +00:00
|
|
|
public GetHttpStatus(): number;
|
|
|
|
public GetStatus(): Http.HttpResponseStatus;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext {
|
|
|
|
interface GenericResponseHandler<T extends GenericResponse<any>> {
|
|
|
|
(response: T): void;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Http {
|
|
|
|
enum HttpMethod {
|
2014-04-28 15:07:15 +00:00
|
|
|
DELETE = 0,
|
|
|
|
GET = 1,
|
|
|
|
HEAD = 2,
|
|
|
|
OPTIONS = 3,
|
|
|
|
POST = 4,
|
|
|
|
PUT = 5,
|
|
|
|
TRACE = 6,
|
2014-02-26 19:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Http {
|
|
|
|
interface HttpPostData {
|
|
|
|
[index: string]: string;
|
|
|
|
}
|
|
|
|
}
|
2014-04-28 15:39:19 +00:00
|
|
|
declare module Typertext.Http {
|
|
|
|
class HttpUrl {
|
|
|
|
private domain;
|
|
|
|
private path;
|
|
|
|
private port;
|
|
|
|
private protocol;
|
|
|
|
private queryString;
|
|
|
|
static DefaultPort(protocol: HttpProtocol): number;
|
|
|
|
static FromUrl(location: string): HttpUrl;
|
|
|
|
static DecodeQueryString(queryString: string): HttpQueryString;
|
|
|
|
static EncodeQueryString(query: HttpQueryString): string;
|
|
|
|
static UrlEncodeObject(data: HttpQueryString): string;
|
|
|
|
static UrlDecodeString(queryString: string): HttpQueryString;
|
|
|
|
private static splitString(input, separator, limit?);
|
|
|
|
constructor(domain: string, protocol?: HttpProtocol, path?: string, queryString?: HttpQueryString, port?: number);
|
|
|
|
public ToString(): string;
|
|
|
|
public GetPort(): number;
|
|
|
|
public GetDomain(): string;
|
|
|
|
public GetProtocol(): HttpProtocol;
|
|
|
|
public SameOriginCheck(url: HttpUrl): boolean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Transport {
|
|
|
|
interface TransportConstructor {
|
|
|
|
new(method: Http.HttpMethod, request: Http.HttpUrl, postData?: Http.HttpPostData, callback?: Http.HttpResponseHandler): GenericTransport;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext {
|
|
|
|
interface GenericRequest<T extends GenericResponseHandler<GenericResponse<any>>> {
|
|
|
|
Delete(request: Http.HttpUrl, callback: T): void;
|
|
|
|
Get(request: Http.HttpUrl, callback: T): void;
|
|
|
|
Post(request: Http.HttpUrl, postData: Http.HttpPostData, callback: T): void;
|
|
|
|
Put(request: Http.HttpUrl, putData: Http.HttpPostData, callback: T): void;
|
|
|
|
RawRequest(method: Http.HttpMethod, request: Http.HttpUrl, postData?: Http.HttpPostData, callback?: T, transport?: Transport.TransportConstructor): void;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Http {
|
|
|
|
class HttpException extends BaseException<HttpResponse> {
|
|
|
|
}
|
|
|
|
}
|
2014-02-26 19:12:37 +00:00
|
|
|
declare module Typertext.Http {
|
|
|
|
enum HttpProtocol {
|
|
|
|
http = 0,
|
|
|
|
https = 1,
|
|
|
|
}
|
|
|
|
}
|
2014-02-26 21:21:43 +00:00
|
|
|
declare module Typertext.Http {
|
|
|
|
interface HttpQueryString {
|
2014-07-07 19:29:39 +00:00
|
|
|
[index: string]: any;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Http {
|
|
|
|
interface HttpResponseHandler extends GenericResponseHandler<HttpResponse> {
|
2014-02-26 21:21:43 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-28 15:39:19 +00:00
|
|
|
declare module Typertext.Transport {
|
|
|
|
interface GenericTransport {
|
|
|
|
Send(): void;
|
|
|
|
Destroy(): void;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Transport {
|
|
|
|
class TransportChooser {
|
|
|
|
static Transport(method: Http.HttpMethod, request: Http.HttpUrl, postData: Http.HttpPostData, callback: Http.HttpResponseHandler): TransportConstructor;
|
|
|
|
}
|
|
|
|
}
|
2014-02-26 19:12:37 +00:00
|
|
|
declare module Typertext.Http {
|
|
|
|
class HttpRequest implements GenericRequest<HttpResponseHandler> {
|
|
|
|
constructor();
|
2014-04-28 15:07:15 +00:00
|
|
|
public Delete(request: HttpUrl, callback: HttpResponseHandler): void;
|
2014-02-26 19:12:37 +00:00
|
|
|
public Get(request: HttpUrl, callback: HttpResponseHandler): void;
|
|
|
|
public Post(request: HttpUrl, postData: HttpPostData, callback: HttpResponseHandler): void;
|
2014-04-28 15:07:15 +00:00
|
|
|
public Put(request: HttpUrl, putData: HttpPostData, callback: HttpResponseHandler): void;
|
2014-04-16 15:40:03 +00:00
|
|
|
public RawRequest(method: HttpMethod, request: HttpUrl, postData?: HttpPostData, callback?: HttpResponseHandler, transport?: Transport.TransportConstructor): void;
|
2014-02-26 19:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Http {
|
|
|
|
class HttpResponse extends GenericResponse<string> {
|
2014-03-03 18:35:46 +00:00
|
|
|
constructor(status: HttpResponseStatus, responseHeaderGetter?: (input: string) => string, httpResponseCode?: number, responseBody?: string);
|
2014-02-26 19:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Http {
|
|
|
|
enum HttpResponseStatus {
|
|
|
|
success = 0,
|
|
|
|
serverError = 1,
|
|
|
|
clientError = 2,
|
|
|
|
responseError = 3,
|
|
|
|
unknownError = 4,
|
|
|
|
timeout = 5,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Json {
|
|
|
|
class JsonException extends BaseException<void> {
|
|
|
|
constructor(message: string, code: number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Json {
|
|
|
|
interface JsonObject {
|
|
|
|
[index: string]: any;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Json {
|
|
|
|
class JsonRequest implements GenericRequest<JsonResponseHandler> {
|
|
|
|
private jsonType;
|
|
|
|
private request;
|
|
|
|
constructor(jsonContentType?: string);
|
2014-04-28 15:07:15 +00:00
|
|
|
public Delete(request: Http.HttpUrl, callback: JsonResponseHandler): void;
|
2014-02-26 19:12:37 +00:00
|
|
|
public Get(request: Http.HttpUrl, callback: JsonResponseHandler): void;
|
|
|
|
public Post(request: Http.HttpUrl, postData: Http.HttpPostData, callback: JsonResponseHandler): void;
|
2014-04-28 15:07:15 +00:00
|
|
|
public Put(request: Http.HttpUrl, putData: Http.HttpPostData, callback: JsonResponseHandler): void;
|
2014-04-16 15:40:03 +00:00
|
|
|
public RawRequest(method: Http.HttpMethod, request: Http.HttpUrl, postData?: Http.HttpPostData, callback?: JsonResponseHandler, transport?: Transport.TransportConstructor): void;
|
2014-02-26 19:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Json {
|
|
|
|
class JsonResponse extends GenericResponse<JsonObject> {
|
2014-03-12 18:56:11 +00:00
|
|
|
private parseSuccess;
|
2014-02-26 19:12:37 +00:00
|
|
|
static fromHttpResponse(httpResponse: Http.HttpResponse): JsonResponse;
|
2014-03-12 18:56:11 +00:00
|
|
|
static fromInvalidHttpResponse(httpResponse: Http.HttpResponse): JsonResponse;
|
|
|
|
constructor(status: Http.HttpResponseStatus, responseHeaderGetter?: (input: string) => string, httpResponseCode?: number, responseBody?: JsonObject, parseSuccess?: boolean);
|
|
|
|
public GetParseStatus(): boolean;
|
2014-02-26 19:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Json {
|
|
|
|
interface JsonResponseHandler extends GenericResponseHandler<JsonResponse> {
|
|
|
|
}
|
|
|
|
}
|
2014-04-11 18:51:54 +00:00
|
|
|
declare module Typertext.Transport {
|
2014-04-16 15:40:03 +00:00
|
|
|
class XDR implements GenericTransport {
|
|
|
|
private xdr;
|
|
|
|
private postData;
|
|
|
|
private method;
|
|
|
|
private request;
|
|
|
|
private callback;
|
2014-04-14 15:04:46 +00:00
|
|
|
constructor(method: Http.HttpMethod, request: Http.HttpUrl, postData?: Http.HttpPostData, callback?: Http.HttpResponseHandler);
|
2014-04-16 15:40:03 +00:00
|
|
|
public Send(): void;
|
|
|
|
public Destroy(): void;
|
2014-04-11 18:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
declare module Typertext.Transport {
|
2014-04-16 15:40:03 +00:00
|
|
|
class XHR implements GenericTransport {
|
|
|
|
private xhr;
|
|
|
|
private postData;
|
|
|
|
private method;
|
|
|
|
private request;
|
|
|
|
private callback;
|
2014-04-14 15:04:46 +00:00
|
|
|
constructor(method: Http.HttpMethod, request: Http.HttpUrl, postData?: Http.HttpPostData, callback?: Http.HttpResponseHandler);
|
2014-04-16 15:40:03 +00:00
|
|
|
public Send(): void;
|
|
|
|
public Destroy(): void;
|
2014-04-11 18:51:54 +00:00
|
|
|
}
|
|
|
|
}
|