Merge pull request #105 from openMF/refrc
refactor(client): client service
This commit is contained in:
@@ -9,14 +9,19 @@ import { map } from 'rxjs/operators';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class ClientsService {
|
export class ClientsService {
|
||||||
constructor(private http: Http) {} // tslint:disable-line
|
constructor(private http: Http) {} // tslint:disable-line
|
||||||
|
|
||||||
|
createAuthorizationHeader(headers: Headers) {
|
||||||
|
const username = 'mifos';
|
||||||
|
const password = 'password';
|
||||||
|
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
|
||||||
|
headers.append('Content-Type', 'application/json');
|
||||||
|
headers.append('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||||
|
headers.append('Access-Control-Allow-Origin', '*');
|
||||||
|
}
|
||||||
|
|
||||||
getClients() {
|
getClients() {
|
||||||
const username = 'mifos';
|
|
||||||
const password = 'password';
|
|
||||||
const headers = new Headers(); // tslint:disable-line
|
const headers = new Headers(); // tslint:disable-line
|
||||||
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
|
this.createAuthorizationHeader(headers);
|
||||||
headers.append('Content-Type', 'application/json');
|
|
||||||
headers.append('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
||||||
headers.append('Access-Control-Allow-Origin', '*');
|
|
||||||
return this.http.get
|
return this.http.get
|
||||||
('https://demo.openmf.org/fineract-provider/api/v1/clients?tenantIdentifier=default&pretty=true',
|
('https://demo.openmf.org/fineract-provider/api/v1/clients?tenantIdentifier=default&pretty=true',
|
||||||
{headers: headers})
|
{headers: headers})
|
||||||
@@ -31,13 +36,8 @@ export class ClientsService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
getClientId(clientId: number) {
|
getClientId(clientId: number) {
|
||||||
const username = 'mifos';
|
|
||||||
const password = 'password';
|
|
||||||
const headers = new Headers(); // tslint:disable-line
|
const headers = new Headers(); // tslint:disable-line
|
||||||
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
|
this.createAuthorizationHeader(headers);
|
||||||
headers.append('Content-Type', 'application/json');
|
|
||||||
headers.append('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
||||||
headers.append('Access-Control-Allow-Origin', '*');
|
|
||||||
return this.http.get
|
return this.http.get
|
||||||
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
|
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
|
||||||
+ '?tenantIdentifier=default&pretty=true',
|
+ '?tenantIdentifier=default&pretty=true',
|
||||||
@@ -54,13 +54,8 @@ export class ClientsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getClientAccounts(clientId: number) {
|
getClientAccounts(clientId: number) {
|
||||||
const username = 'mifos';
|
|
||||||
const password = 'password';
|
|
||||||
const headers = new Headers(); // tslint:disable-line
|
const headers = new Headers(); // tslint:disable-line
|
||||||
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
|
this.createAuthorizationHeader(headers);
|
||||||
headers.append('Content-Type', 'application/json');
|
|
||||||
headers.append('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
||||||
headers.append('Access-Control-Allow-Origin', '*');
|
|
||||||
return this.http.get
|
return this.http.get
|
||||||
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
|
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
|
||||||
+ '/accounts' + '?tenantIdentifier=default&pretty=true',
|
+ '/accounts' + '?tenantIdentifier=default&pretty=true',
|
||||||
@@ -77,13 +72,8 @@ export class ClientsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getClientCharges(clientId: number) {
|
getClientCharges(clientId: number) {
|
||||||
const username = 'mifos';
|
|
||||||
const password = 'password';
|
|
||||||
const headers = new Headers(); // tslint:disable-line
|
const headers = new Headers(); // tslint:disable-line
|
||||||
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
|
this.createAuthorizationHeader(headers);
|
||||||
headers.append('Content-Type', 'application/json');
|
|
||||||
headers.append('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
||||||
headers.append('Access-Control-Allow-Origin', '*');
|
|
||||||
return this.http.get
|
return this.http.get
|
||||||
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
|
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
|
||||||
+ '/charges' + '?tenantIdentifier=default&pretty=true',
|
+ '/charges' + '?tenantIdentifier=default&pretty=true',
|
||||||
@@ -100,13 +90,8 @@ export class ClientsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getClientAddress (clientId: number) {
|
getClientAddress (clientId: number) {
|
||||||
const username = 'mifos';
|
|
||||||
const password = 'password';
|
|
||||||
const headers = new Headers(); // tslint:disable-line
|
const headers = new Headers(); // tslint:disable-line
|
||||||
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
|
this.createAuthorizationHeader(headers);
|
||||||
headers.append('Content-Type', 'application/json');
|
|
||||||
headers.append('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
||||||
headers.append('Access-Control-Allow-Origin', '*');
|
|
||||||
return this.http.get
|
return this.http.get
|
||||||
('https://demo.openmf.org/fineract-provider/api/v1/client/' + clientId
|
('https://demo.openmf.org/fineract-provider/api/v1/client/' + clientId
|
||||||
+ '/addresses' + '?tenantIdentifier=default&pretty=true',
|
+ '/addresses' + '?tenantIdentifier=default&pretty=true',
|
||||||
|
|||||||
Reference in New Issue
Block a user