Skip to content

Commit

Permalink
Merge pull request #20 from AnglesHQ/adding_screenshots_apis
Browse files Browse the repository at this point in the history
added new screenshot metrics api (grouped by tags and views)
  • Loading branch information
snevesbarros authored Mar 11, 2024
2 parents 59b77c2 + a1588bd commit 85110b7
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/models/response/ScreenshotMetric.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {ScreenshotPlatform} from "../requests/ScreenshotPlatform";

export class ScreenshotMetric {
_id: string;
count: number;
platforms: ScreenshotPlatform[];
}
7 changes: 7 additions & 0 deletions src/lib/models/response/ScreenshotMetricPlatform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {Screenshot} from "../Screenshot";

export class ScreenshotMetric {
platformId: string;
count: number;
screenshot: Screenshot
}
6 changes: 6 additions & 0 deletions src/lib/models/response/ScreenshotMetrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {ScreenshotMetric} from "./ScreenshotMetric";

export class ScreenshotMetrics {
views: ScreenshotMetric[];
tags: ScreenshotMetric[];
}
18 changes: 18 additions & 0 deletions src/lib/requests/MetricRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import moment from 'moment';
import { BaseRequests } from './BaseRequests';
import {GroupingPeriods} from "../models/enum/GroupingPeriods";
import {PhaseMetrics} from "../models/response/PhaseMetrics";
import {ScreenshotMetrics} from "../models/response/ScreenshotMetrics";

export class MetricRequests extends BaseRequests {

Expand All @@ -27,4 +28,21 @@ export class MetricRequests extends BaseRequests {
if (groupingPeriod) { url.searchParams.append('groupingPeriod', groupingPeriod); }
return this.get<PhaseMetrics>(url.toString());
}

/**
* Will retrieve screenshot metrics grouped by tags and views.
*
* @param view
* @param tag
* @param limit
* @param thumbnail
*/
public getScreenshotMetrics(view: string, tag: string, limit: number, thumbnail: boolean): Promise<ScreenshotMetrics> {
const url = new URL(this.axios.defaults.baseURL + `/metrics/screenshot?`);
if (view) { url.searchParams.append('view', view); }
if (tag) { url.searchParams.append('tag', tag); }
if (limit) { url.searchParams.append('limit', String(limit)); }
if (thumbnail) { url.searchParams.append('thumbnail', String(thumbnail)); }
return this.get<ScreenshotMetrics>(url.toString());
}
}
18 changes: 18 additions & 0 deletions src/lib/requests/ScreenshotRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ export class ScreenshotRequests extends BaseRequests {
});
}

public getScreenshotViews(view: string, limit: number) : Promise<string[]> {
return this.get<string[]>('screenshot/views', {
params: {
view,
limit,
}
});
}

public getScreenshotTags(tag: string, limit: number) : Promise<string[]> {
return this.get<string[]>('screenshot/tags', {
params: {
tag,
limit,
}
});
}

public getScreenshotHistoryByView(view: string, platformId: string, limit: number, offset: number) : Promise<Screenshot[]> {
return this.get('/screenshot/', {
params: {
Expand Down

0 comments on commit 85110b7

Please sign in to comment.