Angular SDK
Sample Application
component.html
<h3>{{name}}</h3>
<div>
Error:
<pre>{{error | json}}</pre>
<hr>
Sum:
<pre>{{sum | json}}</pre>
<hr>
Result:
<pre>{{result | json}}</pre>
<hr>
Result List:
<ol>
<li *ngFor=
"let item of result_list | async"
>
<pre>{{item | json}}</pre>
</li>
</ol>
</div>
component.ts
import { Component, OnInit } from
'@angular/core'
;
import {
CardprocessingTransactionsService,
ProductExceptionPayload
} from
'../../../shared/api'
;
import { map, Observable } from
'rxjs'
;
@Component({
templateUrl:
'./ident-requests.component.html'
,
})
/**
* https://angular.io/guide/rx-library
* https://angular.io/guide/comparing-observables
* https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-functions-datetime.html
* https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math
*/
export class IdentRequestsComponent2 implements OnInit {
public name!: string;
public error!: ProductExceptionPayload;
public result!: any;
public result_list!: any;
public sum!: any;
constructor(
private service: CardprocessingTransactionsService,
) {
this
.name =
this
.service.constructor.name;
}
ngOnInit(): void {
this
.service.getOne({
cardprocessing_transaction_id:
'PTX_9Z053S5DQAQPKHXEYEZCB460805PN9'
}).subscribe(
res =>
this
.result = res,
error =>
this
.error = error.error
);
this
.result_list =
this
.service.getAll({
count: 2,
// FROM today (time 00:00:00) minus one month TO now (current time)
q:
"created:[now-1M/d TO now]"
,
}).pipe(
map((value) => value.data),
);
this
.service.getAll({
// FROM the first day of the last month (00:00:00) TO the end of the last month (23:59:59)
q:
"created:[now-1M/M TO now-1M/M]"
,
aggregate: {
timestamp_prop:
'created'
,
interval:
'1d'
,
group_by_prop:
"product"
,
sum_by_prop:
"amount"
}
}).subscribe(
res =>
this
.sum = res,
error =>
this
.error = error.error
);
}
}