@@ -7,54 +7,54 @@ export const statistics = (configuration, http) => {
77 const { get } = http ;
88
99 const typeFn = ( type ) => {
10- return {
11- daily : ( options = { } ) => {
12- let url = urljoin ( configuration . apiBaseUrl , 'encoding/statistics/encodings/' , type , '/daily' ) ;
13- let { limit, offset } = options ;
10+ return {
11+ daily : ( options = { } ) => {
12+ let url = urljoin ( configuration . apiBaseUrl , 'encoding/statistics/encodings/' , type , '/daily' ) ;
13+ let { limit, offset } = options ;
1414
15- if ( options !== { } && options . from && options . to ) {
16- if ( ! isValidApiRequestDateString ( options . from ) || ! isValidApiRequestDateString ( options . to ) ) {
17- console . error ( 'Wrong date format! Correct format is yyyy-MM-dd' ) ;
18- return Promise . reject ( new BitmovinError ( 'Wrong date format! Correct format is yyyy-MM-dd' , { } ) ) ;
19- }
20- url = urljoin ( url , options . from , options . to ) ;
15+ if ( options !== { } && options . from && options . to ) {
16+ if ( ! isValidApiRequestDateString ( options . from ) || ! isValidApiRequestDateString ( options . to ) ) {
17+ console . error ( 'Wrong date format! Correct format is yyyy-MM-dd' ) ;
18+ return Promise . reject ( new BitmovinError ( 'Wrong date format! Correct format is yyyy-MM-dd' , { } ) ) ;
2119 }
20+ url = urljoin ( url , options . from , options . to ) ;
21+ }
2222
23- const getParams = utils . buildGetParamString ( {
24- limit : limit ,
25- offset : offset
26- } ) ;
23+ const getParams = utils . buildGetParamString ( {
24+ limit : limit ,
25+ offset : offset
26+ } ) ;
2727
28- if ( getParams . length > 0 ) {
29- url = urljoin ( url , getParams ) ;
30- }
31- return get ( configuration , url ) ;
32- } ,
28+ if ( getParams . length > 0 ) {
29+ url = urljoin ( url , getParams ) ;
30+ }
31+ return get ( configuration , url ) ;
32+ } ,
3333
34- list : ( options = { } ) => {
35- let url = urljoin ( configuration . apiBaseUrl , 'encoding/statistics/encodings/' , type ) ;
36- let { limit, offset } = options ;
34+ list : ( options = { } ) => {
35+ let url = urljoin ( configuration . apiBaseUrl , 'encoding/statistics/encodings/' , type ) ;
36+ let { limit, offset } = options ;
3737
38- if ( options !== { } && options . from && options . to ) {
39- if ( ! isValidApiRequestDateString ( options . from ) || ! isValidApiRequestDateString ( options . to ) ) {
40- console . error ( 'Wrong date format! Correct format is yyyy-MM-dd' ) ;
41- return Promise . reject ( new BitmovinError ( 'Wrong date format! Correct format is yyyy-MM-dd' , { } ) ) ;
42- }
43- url = urljoin ( url , options . from , options . to ) ;
38+ if ( options !== { } && options . from && options . to ) {
39+ if ( ! isValidApiRequestDateString ( options . from ) || ! isValidApiRequestDateString ( options . to ) ) {
40+ console . error ( 'Wrong date format! Correct format is yyyy-MM-dd' ) ;
41+ return Promise . reject ( new BitmovinError ( 'Wrong date format! Correct format is yyyy-MM-dd' , { } ) ) ;
4442 }
43+ url = urljoin ( url , options . from , options . to ) ;
44+ }
4545
46- const getParams = utils . buildGetParamString ( {
47- limit : limit ,
48- offset : offset
49- } ) ;
46+ const getParams = utils . buildGetParamString ( {
47+ limit : limit ,
48+ offset : offset
49+ } ) ;
5050
51- if ( getParams . length > 0 ) {
52- url = urljoin ( url , getParams ) ;
53- }
54-
55- return get ( configuration , url ) ;
51+ if ( getParams . length > 0 ) {
52+ url = urljoin ( url , getParams ) ;
5653 }
54+
55+ return get ( configuration , url ) ;
5756 }
57+ }
5858 } ;
5959
6060 return {
@@ -70,8 +70,11 @@ export const statistics = (configuration, http) => {
7070 * from: Date
7171 * to: Date
7272 */
73- overall : ( ) => {
74- const url = urljoin ( configuration . apiBaseUrl , 'encoding/statistics' ) ;
73+ overall : ( from = null , to = null ) => {
74+ let url = urljoin ( configuration . apiBaseUrl , 'encoding/statistics' ) ;
75+ if ( from && to ) {
76+ url = urljoin ( url , from , to ) ;
77+ }
7578 return get ( configuration , url ) ;
7679 } ,
7780
@@ -80,6 +83,10 @@ export const statistics = (configuration, http) => {
8083
8184 encodings : ( encodingId ) => {
8285 return {
86+ statistics : ( ) => {
87+ const url = urljoin ( configuration . apiBaseUrl , 'encoding/statistics/encodings' , encodingId ) ;
88+ return get ( configuration , url ) ;
89+ } ,
8390 liveStatistics : ( ) => {
8491 const url = urljoin ( configuration . apiBaseUrl , 'encoding/statistics/encodings' , encodingId , 'live-statistics' ) ;
8592 return get ( configuration , url ) ;
0 commit comments