diff --git a/src/lib/ng-noosfero-api/http/http_client.ts b/src/lib/ng-noosfero-api/http/http_client.ts new file mode 100644 index 0000000..d09e3e2 --- /dev/null +++ b/src/lib/ng-noosfero-api/http/http_client.ts @@ -0,0 +1,12 @@ +module NgNoosferoAPI { + export class NoosferoHttpClient { + static $inject = ['$http', '$q']; + + constructor(private $http, private $q) { + + } + } + + NgNoosferoAPI.ngModule.service(NoosferoHttpClient); +} + diff --git a/src/lib/ng-noosfero-api/http/http_config.ts b/src/lib/ng-noosfero-api/http/http_config.ts new file mode 100644 index 0000000..d9c3136 --- /dev/null +++ b/src/lib/ng-noosfero-api/http/http_config.ts @@ -0,0 +1,26 @@ + +module NgNoosferoAPI { + export interface NoosferoHttpServiceConfig { + protocol: string; + hostname: string; + port: number; + apiPath: string; + acceptHeader: string; + contentTypeHeader: string; + textEncoding: string; + + } + + export function configNoosferoHttpService(hostname: string, port?: number, protocol?: string) { + return { + hostname: hostname, + port: port || 80, + apiPath: "/api/v1", + protocol: protocol || "http", + acceptHeader: "application/json", + contentTypeHeader: "application/json", + textEncoding: "UTF-8" + }; + } + +} \ No newline at end of file diff --git a/src/lib/ng-noosfero-api/http/http_config_provider.ts b/src/lib/ng-noosfero-api/http/http_config_provider.ts new file mode 100644 index 0000000..2e351c5 --- /dev/null +++ b/src/lib/ng-noosfero-api/http/http_config_provider.ts @@ -0,0 +1,30 @@ +module NgNoosferoAPI { + + + // The following class represents the provider + export class NoosferoHttpServiceConfigProvider implements ng.IServiceProvider { + private config = { + hostname: "localhost", + protocol: "http", + port: 3000, + apiPath: "/api/v1", + acceptHeader: "application/json", + contentTypeHeader: "application/json", + textEncoding: "UTF-8" + }; + + + // Configuration function + public setConfig(config: NoosferoHttpServiceConfig) { + this.config = config; + } + + // Provider's factory function + public $get(): NoosferoHttpServiceConfig { + return this.config; + } + } + + ngModule.provider("NoosferoHttpServiceConfig", NoosferoHttpServiceConfigProvider); + +} \ No newline at end of file diff --git a/src/lib/ng-noosfero-api/module.ts b/src/lib/ng-noosfero-api/module.ts new file mode 100644 index 0000000..c62263c --- /dev/null +++ b/src/lib/ng-noosfero-api/module.ts @@ -0,0 +1,8 @@ + + +module NgNoosferoAPI { + "use strict"; + export var ngModule: ng.IModule = angular.module("ngNoosferoAPI", []); + +} + -- libgit2 0.21.2