Commit 807f6df689415c1cafe199090d3c1cf4ed3c6387

Authored by Ábner Oliveira
1 parent 17b9833a

added ng-noosfero-api lib path

src/lib/ng-noosfero-api/http/http_client.ts 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +module NgNoosferoAPI {
  2 + export class NoosferoHttpClient {
  3 + static $inject = ['$http', '$q'];
  4 +
  5 + constructor(private $http, private $q) {
  6 +
  7 + }
  8 + }
  9 +
  10 + NgNoosferoAPI.ngModule.service(NoosferoHttpClient);
  11 +}
  12 +
... ...
src/lib/ng-noosfero-api/http/http_config.ts 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +
  2 +module NgNoosferoAPI {
  3 + export interface NoosferoHttpServiceConfig {
  4 + protocol: string;
  5 + hostname: string;
  6 + port: number;
  7 + apiPath: string;
  8 + acceptHeader: string;
  9 + contentTypeHeader: string;
  10 + textEncoding: string;
  11 +
  12 + }
  13 +
  14 + export function configNoosferoHttpService(hostname: string, port?: number, protocol?: string) {
  15 + return <NoosferoHttpServiceConfig>{
  16 + hostname: hostname,
  17 + port: port || 80,
  18 + apiPath: "/api/v1",
  19 + protocol: protocol || "http",
  20 + acceptHeader: "application/json",
  21 + contentTypeHeader: "application/json",
  22 + textEncoding: "UTF-8"
  23 + };
  24 + }
  25 +
  26 +}
0 27 \ No newline at end of file
... ...
src/lib/ng-noosfero-api/http/http_config_provider.ts 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +module NgNoosferoAPI {
  2 +
  3 +
  4 + // The following class represents the provider
  5 + export class NoosferoHttpServiceConfigProvider implements ng.IServiceProvider {
  6 + private config = <NoosferoHttpServiceConfig>{
  7 + hostname: "localhost",
  8 + protocol: "http",
  9 + port: 3000,
  10 + apiPath: "/api/v1",
  11 + acceptHeader: "application/json",
  12 + contentTypeHeader: "application/json",
  13 + textEncoding: "UTF-8"
  14 + };
  15 +
  16 +
  17 + // Configuration function
  18 + public setConfig(config: NoosferoHttpServiceConfig) {
  19 + this.config = config;
  20 + }
  21 +
  22 + // Provider's factory function
  23 + public $get(): NoosferoHttpServiceConfig {
  24 + return this.config;
  25 + }
  26 + }
  27 +
  28 + ngModule.provider("NoosferoHttpServiceConfig", NoosferoHttpServiceConfigProvider);
  29 +
  30 +}
0 31 \ No newline at end of file
... ...
src/lib/ng-noosfero-api/module.ts 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +
  2 +
  3 +module NgNoosferoAPI {
  4 + "use strict";
  5 + export var ngModule: ng.IModule = angular.module("ngNoosferoAPI", []);
  6 +
  7 +}
  8 +
... ...