feat(client): Client documents and identifiers (#134)

* feat(client): Client documents and identifiers
This commit is contained in:
Anwesh Nayak
2018-07-19 19:56:12 +05:30
committed by GitHub
parent 4a30432fa9
commit c5360f4162
15 changed files with 803 additions and 138 deletions
+248 -128
View File
@@ -8,178 +8,298 @@ import { map } from 'rxjs/operators';
@Injectable()
export class ClientsService {
constructor(private http: Http) {} // tslint:disable-line
constructor(private http: Http) {} // tslint:disable-line
createAuthorizationHeader(headers: Headers) { // tslint:disable-line
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', '*');
}
createAuthorizationHeader(headers: Headers) { // tslint:disable-line
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() {
const headers = new Headers(); // tslint:disable-line
getClients() {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get
('https://demo.openmf.org/fineract-provider/api/v1/clients?tenantIdentifier=default&pretty=true',
{headers: headers})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response['pageItems'];
return this.http.get(
'https://demo.openmf.org/fineract-provider/api/v1/clients?tenantIdentifier=default&pretty=true', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response['pageItems'];
}
)
);
}
}
)
);
}
getClientId(clientId: number) {
const headers = new Headers(); // tslint:disable-line
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
+ '?tenantIdentifier=default&pretty=true',
{headers: headers})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
return this.http.get('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'?tenantIdentifier=default&pretty=true', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
}
)
);
}
)
);
}
getClientAccounts(clientId: number) {
const headers = new Headers(); // tslint:disable-line
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
+ '/accounts' + '?tenantIdentifier=default&pretty=true',
{headers: headers})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
return this.http.get('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/accounts' + '?tenantIdentifier=default&pretty=true', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
}
)
);
}
)
);
}
getClientCharges(clientId: number) {
const headers = new Headers(); // tslint:disable-line
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
+ '/charges' + '?tenantIdentifier=default&pretty=true',
{headers: headers})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
return this.http.get('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/charges' + '?tenantIdentifier=default&pretty=true', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
}
)
);
}
)
);
}
getClientAddress (clientId: number) {
const headers = new Headers(); // tslint:disable-line
getClientAddress(clientId: number) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get
('https://demo.openmf.org/fineract-provider/api/v1/client/' + clientId
+ '/addresses' + '?tenantIdentifier=default&pretty=true',
{headers: headers})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
return this.http.get('https://demo.openmf.org/fineract-provider/api/v1/client/' + clientId +
'/addresses' + '?tenantIdentifier=default&pretty=true', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
}
)
);
}
)
);
}
getClientNote (clientId: number) {
const headers = new Headers(); // tslint:disable-line
getClientNote(clientId: number) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
+ '/notes' + '?tenantIdentifier=default&pretty=true',
{headers: headers})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
return this.http.get('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/notes' + '?tenantIdentifier=default&pretty=true', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
}
)
);
}
)
);
}
postClientNote (clientId: number, notes: any) {
const headers = new Headers(); // tslint:disable-line
postClientNote(clientId: number, notes: any) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
const body = JSON.stringify(notes);
return this.http.post
('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId
+ '/notes' + '?tenantIdentifier=default&pretty=true', notes ,
{headers: headers})
.pipe(
map(
(response: Response) => { // tslint:disable-line
return this.http.post('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/notes' + '?tenantIdentifier=default&pretty=true', notes, {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response.json();
}
)
);
)
);
}
getClientAddressTemplate() {
const headers = new Headers(); // tslint:disable-line
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get
('https://demo.openmf.org/fineract-provider/api/v1/client/'
+ 'addresses/template?tenantIdentifier=default',
{headers: headers})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
return this.http.get('https://demo.openmf.org/fineract-provider/api/v1/client/' +
'addresses/template?tenantIdentifier=default', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
}
)
);
}
)
);
}
postClientAddress (clientId: number, body: any, type: any) {
const headers = new Headers(); // tslint:disable-line
postClientAddress(clientId: number, body: any, type: any) {
const headers = new Headers(); // tslint:disable-line
const params = new URLSearchParams(); // tslint:disable-line
params.set('type', type);
this.createAuthorizationHeader(headers);
body = JSON.stringify(body);
const options = new RequestOptions({ // tslint:disable-line
headers: headers,
params: params,
const options = new RequestOptions({ // tslint:disable-line
headers: headers,
params: params,
});
return this.http.post
('https://demo.openmf.org/fineract-provider/api/v1/client/' + clientId
+ '/addresses?' + '&tenantIdentifier=default&pretty=true', body ,
options)
.pipe(
map(
(response: Response) => { // tslint:disable-line
return this.http.post('https://demo.openmf.org/fineract-provider/api/v1/client/' + clientId +
'/addresses?' + '&tenantIdentifier=default&pretty=true', body,
options)
.pipe(
map(
(response: Response) => { // tslint:disable-line
response.json();
}
)
);
)
);
}
getClientIdentifierTemplate(clientId: number) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/identifiers/template?tenantIdentifier=default', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response['allowedDocumentTypes'];
}
)
);
}
getClientIdentifiers(clientId: number) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/identifiers/?tenantIdentifier=default', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response = response.json();
return response;
}
)
);
}
postClientIdentifier(clientId: number, body: any) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.post('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/identifiers/?tenantIdentifier=default', body, {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response.json();
}
)
);
}
deleteClientIdentifier(clientId: number, identifierId: number) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.delete('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/identifiers/' + identifierId + '/?tenantIdentifier=default', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response.json();
}
)
);
}
postClientDocument(clientId: number, body: any) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
headers.append('Content-Type', null);
headers.append('Accept', 'multipart/form-data');
body = JSON.stringify(body);
return this.http.post('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/documents/?tenantIdentifier=default', body, {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response.json();
}
)
);
}
getClientDocuments(clientId: number) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.get('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/documents/?tenantIdentifier=default', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
return response.json();
}
)
);
}
deleteClientDocuments(clientId: number, documentId: number) {
const headers = new Headers(); // tslint:disable-line
this.createAuthorizationHeader(headers);
return this.http.delete('https://demo.openmf.org/fineract-provider/api/v1/clients/' + clientId +
'/documents/' + documentId + '/?tenantIdentifier=default', {
headers: headers
})
.pipe(
map(
(response: Response) => { // tslint:disable-line
response.json();
}
)
);
}
}