@bprotsyk/aso-core 1.2.207 → 1.2.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -30,12 +30,12 @@ export { IOfferWallAuthConfig } from "./aso/offerwall/auth/offerwall-auth-config
30
30
  export { IOfferWallAuthLocalization } from "./aso/offerwall/auth/offerwall-auth-localization";
31
31
  export { IOfferWallAuthSubmitRequest } from "./aso/offerwall/auth/offerwall-auth-submit-request";
32
32
  export { IOfferWallAuthSubmitResponse } from "./aso/offerwall/auth/offerwall-auth-submit-response";
33
- export { KeitaroService } from "./network/keitaro/keitaro-service";
33
+ export { KeitaroService, IKeitaroOffersFilter } from "./network/keitaro/keitaro-service";
34
34
  export * as KeitaroUtils from "./utils/keitaro-utils";
35
35
  export { IKeitaroCampaign, IKeitaroCampaignParameters, IKeitaroCampaignParameter } from "./keitaro/keitaro-campaign";
36
36
  export { IKeitaroDomain } from "./keitaro/keitaro-domain";
37
37
  export { IKeitaroOffer } from "./keitaro/keitaro-offer";
38
38
  export { IKeitaroStream } from "./keitaro/keitaro-stream";
39
39
  export { ICloudflareDomainStatus, ICloudflareDomainType, ICloudflareDomain } from "./models/cloudflare-domain";
40
- export { IDomain, DomainStatus, DomainTarget, CONST_CLOUFLARE_STATUS_READY } from "./models/domain";
40
+ export { IDomain, DomainStatus, DomainTarget, CONST_CLOUFLARE_STATUS_READY, IDomainsBuyRequestResponse } from "./models/domain";
41
41
  export { INamecheapDomain, INamecheapBuyRequest, INamecheapContactInfo, NamecheapBuyRequestSchema } from "./models/namecheap-domain";
@@ -3,4 +3,5 @@ export interface IKeitaroOffer {
3
3
  campaign_id: number;
4
4
  name: string;
5
5
  url: string;
6
+ country: string;
6
7
  }
@@ -45,6 +45,15 @@ export interface IDomain extends Document {
45
45
  target: DomainTarget;
46
46
  assignedTo: number[];
47
47
  }
48
+ export interface IDomainsBuyRequestResponse {
49
+ requestId: string;
50
+ info: [
51
+ {
52
+ name: string;
53
+ price: string;
54
+ }
55
+ ];
56
+ }
48
57
  export declare const CONST_CLOUFLARE_STATUS_READY = "active";
49
58
  export declare enum DomainStatus {
50
59
  PENDING = "pending",
@@ -3,13 +3,20 @@ import { IOffer } from "../../shared/offer";
3
3
  import { IKeitaroCampaign } from "../../keitaro/keitaro-campaign";
4
4
  import { IKeitaroDomain } from "../../keitaro/keitaro-domain";
5
5
  import { IFlashApp } from "../../flash/flash-app";
6
+ import { IKeitaroOffer } from "index";
7
+ export interface IKeitaroOffersFilter {
8
+ keitaroId?: number;
9
+ name?: string;
10
+ caption?: string;
11
+ }
6
12
  declare function getStreamsByCampaignId(campaignId: number): Promise<IKeitaroStream[]>;
7
13
  declare function getAllCampaigns(): Promise<IKeitaroCampaign[]>;
8
14
  declare function cloneStreams(originalCampaignId: number, streamPositionsToClone: number[], campaignRegExp: RegExp): Promise<void>;
9
15
  declare function updateCampaign(id: number, payload: Partial<IKeitaroCampaign>): Promise<void>;
10
- declare function getAllOffers(): Promise<any[]>;
11
- declare function getOfferByKeitaroId(id: number): Promise<any>;
12
- declare function updateOffer(offer: any): Promise<any>;
16
+ declare function getAllOffers(): Promise<IKeitaroOffer[]>;
17
+ declare function findKeitaroOffers(filter: IKeitaroOffersFilter): Promise<IKeitaroOffer[]>;
18
+ declare function getOfferByKeitaroId(id: number): Promise<IKeitaroOffer>;
19
+ declare function updateOffer(offer: any): Promise<IKeitaroOffer>;
13
20
  declare function addOfferToKeitaro(offer: IOffer, affiliateId: number, link: string, campaignGroupId?: number, groupId?: number): Promise<void>;
14
21
  declare function createCampaign(campaignData: Partial<IKeitaroCampaign>): Promise<IKeitaroCampaign>;
15
22
  declare function getCampaignById(id: number): Promise<IKeitaroCampaign>;
@@ -38,5 +45,6 @@ export declare const KeitaroService: {
38
45
  getProfitForTimeRange: typeof getProfitForTimeRange;
39
46
  getProfitForTodayAndYesterday: typeof getProfitForTodayAndYesterday;
40
47
  cloneDCampaign: typeof cloneDCampaign;
48
+ findKeitaroOffers: typeof findKeitaroOffers;
41
49
  };
42
50
  export {};
@@ -83,6 +83,16 @@ async function getAllOffers() {
83
83
  const { data: offers } = await http_1.default.get('offers');
84
84
  return offers;
85
85
  }
86
+ async function findKeitaroOffers(filter) {
87
+ let offers = await getAllOffers();
88
+ if (filter.caption)
89
+ offers = offers.filter((o) => o.name.includes(filter.caption));
90
+ if (filter.keitaroId)
91
+ offers = offers.filter((o) => o.id == filter.keitaroId);
92
+ if (filter.name)
93
+ offers = offers.filter((o) => o.name.includes(filter.name));
94
+ return offers;
95
+ }
86
96
  async function getOfferByKeitaroId(id) {
87
97
  const { data: offer } = await http_1.default.get(`offers/${id}`);
88
98
  return offer;
@@ -246,5 +256,5 @@ async function getProfitForTodayAndYesterday() {
246
256
  }
247
257
  exports.KeitaroService = {
248
258
  getStreamsByCampaignId, updateCampaign, getAllCampaigns, getAllOffers, cloneStreams, addOfferToKeitaro, getOfferByKeitaroId, getDomains, createCampaign, getCampaignById, upsertStreamToCampaign, cloneOWCampaign,
249
- updateOffer, changeCampaignsGroup, getProfitForTimeRange, getProfitForTodayAndYesterday, cloneDCampaign
259
+ updateOffer, changeCampaignsGroup, getProfitForTimeRange, getProfitForTodayAndYesterday, cloneDCampaign, findKeitaroOffers
250
260
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bprotsyk/aso-core",
3
- "version": "1.2.207",
3
+ "version": "1.2.209",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -37,7 +37,7 @@ export { IOfferWallAuthLocalization } from "./aso/offerwall/auth/offerwall-auth-
37
37
  export { IOfferWallAuthSubmitRequest } from "./aso/offerwall/auth/offerwall-auth-submit-request"
38
38
  export { IOfferWallAuthSubmitResponse } from "./aso/offerwall/auth/offerwall-auth-submit-response"
39
39
 
40
- export { KeitaroService } from "./network/keitaro/keitaro-service"
40
+ export { KeitaroService, IKeitaroOffersFilter } from "./network/keitaro/keitaro-service"
41
41
  export * as KeitaroUtils from "./utils/keitaro-utils"
42
42
 
43
43
  export { IKeitaroCampaign, IKeitaroCampaignParameters, IKeitaroCampaignParameter } from "./keitaro/keitaro-campaign"
@@ -46,5 +46,5 @@ export { IKeitaroOffer } from "./keitaro/keitaro-offer"
46
46
  export { IKeitaroStream } from "./keitaro/keitaro-stream"
47
47
 
48
48
  export { ICloudflareDomainStatus, ICloudflareDomainType, ICloudflareDomain } from "./models/cloudflare-domain"
49
- export { IDomain, DomainStatus, DomainTarget, CONST_CLOUFLARE_STATUS_READY } from "./models/domain"
49
+ export { IDomain, DomainStatus, DomainTarget, CONST_CLOUFLARE_STATUS_READY, IDomainsBuyRequestResponse } from "./models/domain"
50
50
  export { INamecheapDomain, INamecheapBuyRequest, INamecheapContactInfo, NamecheapBuyRequestSchema } from "./models/namecheap-domain"
@@ -3,4 +3,5 @@ export interface IKeitaroOffer {
3
3
  campaign_id: number;
4
4
  name: string;
5
5
  url: string;
6
+ country: string
6
7
  }
@@ -24,6 +24,14 @@ export interface IDomain extends Document {
24
24
  assignedTo: number[]
25
25
  }
26
26
 
27
+ export interface IDomainsBuyRequestResponse {
28
+ requestId: string
29
+ info: [{
30
+ name: string,
31
+ price: string
32
+ }]
33
+ }
34
+
27
35
  export const CONST_CLOUFLARE_STATUS_READY = "active"
28
36
 
29
37
  export enum DomainStatus {
@@ -6,6 +6,13 @@ import { IKeitaroDomain } from "../../keitaro/keitaro-domain";
6
6
  import { IFlashApp } from "../../flash/flash-app";
7
7
  import { TRAFFIC_SOURCE_ID_FLASH_AI, prepareOWCampaignParameters } from "../../utils/keitaro-utils";
8
8
  import { convertMillisToDate, getTimestampsForTodayAndYesterday } from "../../utils/general";
9
+ import { IKeitaroOffer } from "index";
10
+
11
+ export interface IKeitaroOffersFilter {
12
+ keitaroId?: number,
13
+ name?: string,
14
+ caption?: string
15
+ }
9
16
 
10
17
  async function getStreamsByCampaignId(campaignId: number): Promise<IKeitaroStream[]> {
11
18
  const { data: streams } = await keitaroApi.get<IKeitaroStream[]>(`campaigns/${campaignId}/streams`);
@@ -93,20 +100,31 @@ async function createStreamForMatchingCampaigns(streamPartialPayload: any, offer
93
100
  }
94
101
  }
95
102
 
96
- async function getAllOffers(): Promise<any[]> {
97
- const { data: offers } = await keitaroApi.get<any[]>('offers')
103
+ async function getAllOffers(): Promise<IKeitaroOffer[]> {
104
+ const { data: offers } = await keitaroApi.get<IKeitaroOffer[]>('offers')
105
+
106
+ return offers
107
+ }
108
+
109
+
110
+ async function findKeitaroOffers(filter: IKeitaroOffersFilter): Promise<IKeitaroOffer[]> {
111
+ let offers = await getAllOffers()
112
+
113
+ if (filter.caption) offers = offers.filter((o) => o.name.includes(filter.caption!))
114
+ if (filter.keitaroId) offers = offers.filter((o) => o.id == filter.keitaroId!)
115
+ if (filter.name) offers = offers.filter((o) => o.name.includes(filter.name!))
98
116
 
99
117
  return offers
100
118
  }
101
119
 
102
- async function getOfferByKeitaroId(id: number): Promise<any> {
103
- const { data: offer } = await keitaroApi.get<any>(`offers/${id}`)
120
+ async function getOfferByKeitaroId(id: number): Promise<IKeitaroOffer> {
121
+ const { data: offer } = await keitaroApi.get<IKeitaroOffer>(`offers/${id}`)
104
122
 
105
123
  return offer
106
124
  }
107
125
 
108
- async function updateOffer(offer: any): Promise<any> {
109
- const { data: o } = await keitaroApi.put<any>(`offers/${offer.id}`, offer)
126
+ async function updateOffer(offer: any): Promise<IKeitaroOffer> {
127
+ const { data: o } = await keitaroApi.put<IKeitaroOffer>(`offers/${offer.id}`, offer)
110
128
 
111
129
  return o
112
130
  }
@@ -300,5 +318,5 @@ async function getProfitForTodayAndYesterday(): Promise<any> {
300
318
 
301
319
  export const KeitaroService = {
302
320
  getStreamsByCampaignId, updateCampaign, getAllCampaigns, getAllOffers, cloneStreams, addOfferToKeitaro, getOfferByKeitaroId, getDomains, createCampaign, getCampaignById, upsertStreamToCampaign, cloneOWCampaign,
303
- updateOffer, changeCampaignsGroup, getProfitForTimeRange, getProfitForTodayAndYesterday, cloneDCampaign
321
+ updateOffer, changeCampaignsGroup, getProfitForTimeRange, getProfitForTodayAndYesterday, cloneDCampaign, findKeitaroOffers
304
322
  }