This repository has been archived on 2019-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
Typertext/build/typertext.d.ts

162 lines
5.8 KiB
TypeScript
Raw Normal View History

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 {
interface GenericRequest<T extends GenericResponseHandler<GenericResponse<any>>> {
Get(request: Http.HttpUrl, callback: T): void;
Post(request: Http.HttpUrl, postData: Http.HttpPostData, callback: T): void;
RawRequest(method: Http.HttpMethod, request: Http.HttpUrl, postData?: Http.HttpPostData, callback?: T): void;
}
}
declare module Typertext {
class GenericResponse<T> {
private status;
private headers;
private httpStatus;
private content;
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;
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 {
2014-03-04 22:51:55 +00:00
class HttpException extends BaseException<HttpResponse> {
2014-02-26 19:12:37 +00:00
}
}
declare module Typertext.Http {
enum HttpMethod {
GET = 0,
POST = 1,
}
}
declare module Typertext.Http {
interface HttpPostData {
[index: string]: string;
}
}
declare module Typertext.Http {
enum HttpProtocol {
http = 0,
https = 1,
}
}
2014-02-26 21:21:43 +00:00
declare module Typertext.Http {
interface HttpQueryString {
[index: string]: string;
}
}
2014-02-26 19:12:37 +00:00
declare module Typertext.Http {
class HttpRequest implements GenericRequest<HttpResponseHandler> {
constructor();
public Get(request: HttpUrl, callback: HttpResponseHandler): void;
public Post(request: HttpUrl, postData: HttpPostData, callback: HttpResponseHandler): void;
public RawRequest(method: HttpMethod, request: HttpUrl, postData?: HttpPostData, callback?: HttpResponseHandler): void;
}
}
declare module Typertext.Http {
class HttpResponse extends GenericResponse<string> {
constructor(status: HttpResponseStatus, responseHeaderGetter?: (input: string) => string, httpResponseCode?: number, responseBody?: string);
2014-02-26 19:12:37 +00:00
}
}
declare module Typertext.Http {
interface HttpResponseHandler extends GenericResponseHandler<HttpResponse> {
}
}
declare module Typertext.Http {
enum HttpResponseStatus {
success = 0,
serverError = 1,
clientError = 2,
responseError = 3,
unknownError = 4,
timeout = 5,
}
}
declare module Typertext.Http {
class HttpUrl {
2014-02-28 17:45:37 +00:00
private domain;
private path;
private port;
private protocol;
private queryString;
2014-02-26 19:12:37 +00:00
static DefaultPort(protocol: HttpProtocol): number;
2014-02-26 21:21:43 +00:00
static FromUrl(location: string): HttpUrl;
static DecodeQueryString(queryString: string): HttpQueryString;
static EncodeQueryString(query: HttpQueryString): string;
2014-02-26 21:58:45 +00:00
static UrlEncodeObject(data: HttpQueryString): string;
static UrlDecodeString(queryString: string): HttpQueryString;
2014-02-26 21:21:43 +00:00
private static splitString(input, separator, limit?);
2014-02-26 21:58:45 +00:00
constructor(domain: string, protocol?: HttpProtocol, path?: string, queryString?: HttpQueryString, port?: number);
2014-02-26 19:12:37 +00:00
public ToString(): string;
}
}
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);
public Get(request: Http.HttpUrl, callback: JsonResponseHandler): void;
public Post(request: Http.HttpUrl, postData: Http.HttpPostData, callback: JsonResponseHandler): void;
public RawRequest(method: Http.HttpMethod, request: Http.HttpUrl, postData?: Http.HttpPostData, callback?: JsonResponseHandler): void;
}
}
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-14 15:04:46 +00:00
class GenericTransport {
constructor(method: Http.HttpMethod, request: Http.HttpUrl, postData: Http.HttpPostData, callback: Http.HttpResponseHandler);
2014-04-11 18:51:54 +00:00
}
}
declare module Typertext.Transport {
class TransportChooser {
2014-04-14 15:04:46 +00:00
static GetTransport(method: Http.HttpMethod, request: Http.HttpUrl, postData: Http.HttpPostData, callback: Http.HttpResponseHandler): GenericTransport;
2014-04-11 18:51:54 +00:00
}
}
declare module Typertext.Transport {
2014-04-14 15:04:46 +00:00
class XDR extends GenericTransport {
constructor(method: Http.HttpMethod, request: Http.HttpUrl, postData?: Http.HttpPostData, callback?: Http.HttpResponseHandler);
2014-04-11 18:51:54 +00:00
}
}
declare module Typertext.Transport {
2014-04-14 15:04:46 +00:00
class XHR extends GenericTransport {
constructor(method: Http.HttpMethod, request: Http.HttpUrl, postData?: Http.HttpPostData, callback?: Http.HttpResponseHandler);
2014-04-11 18:51:54 +00:00
}
}