@bprotsyk/aso-core 1.2.206 → 1.2.208

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,7 +30,7 @@ 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";
@@ -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
  }
@@ -69,12 +69,12 @@ export interface NamecheapBuyResult {
69
69
  paidTotal: string;
70
70
  }
71
71
  export declare const NamecheapBuyRequestSchema: Schema<any, import("mongoose").Model<any, any, any, any, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
72
- id?: string | undefined;
73
- ip?: string | undefined;
74
- fullfilled?: boolean | undefined;
75
- domains?: {
72
+ domains: {
76
73
  name?: string | undefined;
77
74
  available?: boolean | undefined;
78
75
  price?: string | undefined;
79
- } | undefined;
76
+ }[];
77
+ id?: string | undefined;
78
+ ip?: string | undefined;
79
+ fullfilled?: boolean | undefined;
80
80
  }>;
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NamecheapBuyRequestSchema = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  exports.NamecheapBuyRequestSchema = new mongoose_1.Schema({
6
- domains: {
7
- name: String,
8
- price: String,
9
- available: Boolean
10
- },
6
+ domains: [{
7
+ name: String,
8
+ price: String,
9
+ available: Boolean
10
+ }],
11
11
  ip: String,
12
12
  fullfilled: Boolean,
13
13
  id: String
@@ -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.206",
3
+ "version": "1.2.208",
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"
@@ -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,11 +45,11 @@ export interface NamecheapBuyResult {
45
45
  }
46
46
 
47
47
  export const NamecheapBuyRequestSchema = new Schema({
48
- domains: {
48
+ domains: [{
49
49
  name: String,
50
50
  price: String,
51
51
  available: Boolean
52
- },
52
+ }],
53
53
  ip: String,
54
54
  fullfilled: Boolean,
55
55
  id: String
@@ -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
  }