@tyrads.com/tyrads-sdk 2.0.0-beta.2 → 2.0.0
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/LICENSE +11 -11
- package/android/build.gradle +117 -117
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/AndroidManifestNew.xml +2 -2
- package/android/src/main/java/com/tyradssdk/TyradsSdkComposeViewManager.kt +112 -112
- package/android/src/main/java/com/tyradssdk/TyradsSdkModule.kt +56 -56
- package/android/src/main/java/com/tyradssdk/TyradsSdkPackage.kt +18 -21
- package/ios/Tyrads/AcmoConfig.swift +32 -31
- package/ios/Tyrads/ApiHeaders.swift +12 -0
- package/ios/Tyrads/InitModel.swift +48 -46
- package/ios/Tyrads/Tyrads.swift +199 -176
- package/ios/TyradsSdk-Bridging-Header.h +2 -2
- package/ios/TyradsSdk.mm +14 -11
- package/ios/TyradsSdk.swift +47 -27
- package/lib/commonjs/acmo/core/marquee.js.map +1 -1
- package/lib/commonjs/acmo/core/storage/storage.js.map +1 -1
- package/lib/commonjs/acmo/core/types/types.d.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/auto_scroller.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/custom_card.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/my_games_button.js +3 -5
- package/lib/commonjs/acmo/modules/dashboard/components/my_games_button.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/offer_info_section.js +3 -8
- package/lib/commonjs/acmo/modules/dashboard/components/offer_info_section.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_header.js +3 -3
- package/lib/commonjs/acmo/modules/dashboard/components/premium_header.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_1.js +2 -7
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_1.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_2.js +4 -6
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_2.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_3.js +4 -6
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_3.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_4.js +5 -6
- package/lib/commonjs/acmo/modules/dashboard/components/premium_option_4.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/repository.js.map +1 -1
- package/lib/commonjs/acmo/modules/dashboard/top_offers.js +23 -7
- package/lib/commonjs/acmo/modules/dashboard/top_offers.js.map +1 -1
- package/lib/commonjs/i18n.js.map +1 -1
- package/lib/commonjs/index.js +12 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/acmo/core/marquee.js.map +1 -1
- package/lib/module/acmo/core/storage/storage.js.map +1 -1
- package/lib/module/acmo/core/types/types.d.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/auto_scroller.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/custom_card.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/my_games_button.js +3 -5
- package/lib/module/acmo/modules/dashboard/components/my_games_button.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/offer_info_section.js +3 -8
- package/lib/module/acmo/modules/dashboard/components/offer_info_section.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_header.js +3 -3
- package/lib/module/acmo/modules/dashboard/components/premium_header.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_option_1.js +2 -7
- package/lib/module/acmo/modules/dashboard/components/premium_option_1.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_option_2.js +4 -6
- package/lib/module/acmo/modules/dashboard/components/premium_option_2.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_option_3.js +4 -6
- package/lib/module/acmo/modules/dashboard/components/premium_option_3.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/components/premium_option_4.js +5 -6
- package/lib/module/acmo/modules/dashboard/components/premium_option_4.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/repository.js.map +1 -1
- package/lib/module/acmo/modules/dashboard/top_offers.js +23 -7
- package/lib/module/acmo/modules/dashboard/top_offers.js.map +1 -1
- package/lib/module/i18n.js.map +1 -1
- package/lib/module/index.js +12 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/acmo/core/storage/storage.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/my_games_button.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/my_games_button.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/offer_info_section.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/offer_info_section.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_header.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_header.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_1.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_1.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_2.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_2.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_3.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_3.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_4.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_4.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/repository.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/top_offers.d.ts +1 -0
- package/lib/typescript/commonjs/src/acmo/modules/dashboard/top_offers.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/core/storage/storage.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/my_games_button.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/my_games_button.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/offer_info_section.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/offer_info_section.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_header.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_header.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_1.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_1.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_2.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_2.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_3.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_3.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_4.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_4.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/repository.d.ts.map +1 -1
- package/lib/typescript/module/src/acmo/modules/dashboard/top_offers.d.ts +1 -0
- package/lib/typescript/module/src/acmo/modules/dashboard/top_offers.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +197 -197
- package/readme.md +95 -97
- package/src/acmo/core/marquee.tsx +61 -61
- package/src/acmo/core/storage/storage.ts +27 -27
- package/src/acmo/core/types/types.d.ts +93 -93
- package/src/acmo/modules/dashboard/components/auto_scroller.tsx +84 -84
- package/src/acmo/modules/dashboard/components/custom_card.tsx +30 -30
- package/src/acmo/modules/dashboard/components/my_games_button.tsx +39 -39
- package/src/acmo/modules/dashboard/components/offer_info_section.tsx +138 -143
- package/src/acmo/modules/dashboard/components/premium_header.tsx +80 -80
- package/src/acmo/modules/dashboard/components/premium_option_1.tsx +155 -160
- package/src/acmo/modules/dashboard/components/premium_option_2.tsx +99 -103
- package/src/acmo/modules/dashboard/components/premium_option_3.tsx +41 -45
- package/src/acmo/modules/dashboard/components/premium_option_4.tsx +184 -183
- package/src/acmo/modules/dashboard/repository.ts +94 -94
- package/src/acmo/modules/dashboard/top_offers.tsx +144 -131
- package/src/i18n.ts +114 -114
- package/src/index.tsx +89 -81
- package/tyrads-sdk.podspec +41 -41
@@ -1,184 +1,185 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import {
|
3
|
-
View,
|
4
|
-
Text,
|
5
|
-
Image,
|
6
|
-
StyleSheet,
|
7
|
-
Dimensions,
|
8
|
-
TouchableOpacity,
|
9
|
-
} from 'react-native';
|
10
|
-
import AutoScrollPagerWithIndicators from './auto_scroller';
|
11
|
-
import numeral from 'numeral';
|
12
|
-
import
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
21
|
-
|
22
|
-
const PremiumOption4: React.FC<PremiumOption4Props> = ({ data, premiumColor }) => {
|
23
|
-
return (
|
24
|
-
<AutoScrollPagerWithIndicators
|
25
|
-
totalPages={data.length}
|
26
|
-
premiumColor={premiumColor}
|
27
|
-
content={(page) => (
|
28
|
-
<View key={page}>
|
29
|
-
{
|
30
|
-
data[page] && (
|
31
|
-
<OfferBanner details={data[page]} index={page} premiumColor={premiumColor} />
|
32
|
-
)
|
33
|
-
}
|
34
|
-
</View>
|
35
|
-
)}
|
36
|
-
/>
|
37
|
-
);
|
38
|
-
};
|
39
|
-
|
40
|
-
interface OfferBannerProps {
|
41
|
-
details: TransformedCampaign;
|
42
|
-
index: number;
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
<
|
67
|
-
|
68
|
-
<
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
<Text style={styles.points}>{
|
76
|
-
<Text style={styles.
|
77
|
-
|
78
|
-
{
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
}
|
183
|
-
|
1
|
+
import React from 'react';
|
2
|
+
import {
|
3
|
+
View,
|
4
|
+
Text,
|
5
|
+
Image,
|
6
|
+
StyleSheet,
|
7
|
+
Dimensions,
|
8
|
+
TouchableOpacity,
|
9
|
+
} from 'react-native';
|
10
|
+
import AutoScrollPagerWithIndicators from './auto_scroller';
|
11
|
+
import numeral from 'numeral';
|
12
|
+
import { useTranslation } from 'react-i18next';
|
13
|
+
|
14
|
+
const { width } = Dimensions.get('window');
|
15
|
+
|
16
|
+
interface PremiumOption4Props {
|
17
|
+
data: TransformedCampaign[];
|
18
|
+
premiumColor?: string;
|
19
|
+
onCampaignPress?: (campaignId: number) => void;
|
20
|
+
}
|
21
|
+
|
22
|
+
const PremiumOption4: React.FC<PremiumOption4Props> = ({ data, onCampaignPress, premiumColor }) => {
|
23
|
+
return (
|
24
|
+
<AutoScrollPagerWithIndicators
|
25
|
+
totalPages={data.length}
|
26
|
+
premiumColor={premiumColor}
|
27
|
+
content={(page) => (
|
28
|
+
<View key={page}>
|
29
|
+
{
|
30
|
+
data[page] && (
|
31
|
+
<OfferBanner details={data[page]} index={page} premiumColor={premiumColor} onCampaignPress={onCampaignPress} />
|
32
|
+
)
|
33
|
+
}
|
34
|
+
</View>
|
35
|
+
)}
|
36
|
+
/>
|
37
|
+
);
|
38
|
+
};
|
39
|
+
|
40
|
+
interface OfferBannerProps {
|
41
|
+
details: TransformedCampaign;
|
42
|
+
index: number;
|
43
|
+
onCampaignPress?: (campaignId: number) => void;
|
44
|
+
premiumColor?: string;
|
45
|
+
}
|
46
|
+
|
47
|
+
const OfferBanner: React.FC<OfferBannerProps> = ({ details, index, onCampaignPress, premiumColor }) => {
|
48
|
+
const { t } = useTranslation();
|
49
|
+
return (
|
50
|
+
<View style={styles.outerContainer}>
|
51
|
+
<View style={styles.bannerContainer}>
|
52
|
+
<Image style={styles.bannerImage} source={{ uri: details.fileUrl }} resizeMode="cover" />
|
53
|
+
|
54
|
+
<View style={styles.starContainer}>
|
55
|
+
<Image
|
56
|
+
source={require('../../../../assets/images/premium_star.png')}
|
57
|
+
style={[styles.starIcon, { tintColor: premiumColor || '#1C90DF' }]}
|
58
|
+
/>
|
59
|
+
<Text style={styles.index} numberOfLines={1} ellipsizeMode="tail">
|
60
|
+
{index + 1}
|
61
|
+
</Text>
|
62
|
+
</View>
|
63
|
+
</View>
|
64
|
+
<View style={styles.titleContainer}>
|
65
|
+
<View style={{ flexDirection: 'row', flex: 8, width: '70%' }}>
|
66
|
+
<Image style={styles.gameIcon} source={{ uri: details.thumbnail }} resizeMode="cover" />
|
67
|
+
<View style={{ marginLeft: 10 }}>
|
68
|
+
<Text style={styles.titleText}>{details.title}</Text>
|
69
|
+
<View style={styles.rewardDetails}>
|
70
|
+
<Image
|
71
|
+
source={{ uri: details.currency.adUnitCurrencyIcon }}
|
72
|
+
resizeMode="contain"
|
73
|
+
style={styles.coinIcon}
|
74
|
+
/>
|
75
|
+
<Text style={styles.points}>{numeral(details.points).format("0.00a").toUpperCase()}</Text>
|
76
|
+
<Text style={styles.points}>{''}{details.currency.adUnitCurrencyName}</Text>
|
77
|
+
<Text style={styles.rewards}>
|
78
|
+
{' '}
|
79
|
+
{details.rewards} {t('dashboard.rewards', { count: details.rewards })}
|
80
|
+
</Text>
|
81
|
+
</View>
|
82
|
+
</View>
|
83
|
+
</View>
|
84
|
+
<TouchableOpacity
|
85
|
+
onPress={() => onCampaignPress && onCampaignPress(details.campaignId)}
|
86
|
+
style={[styles.playButton, { backgroundColor: premiumColor || '#1C90DF' }]}
|
87
|
+
>
|
88
|
+
<Text style={styles.playButtonText}>{t('dashboard.play_button')}</Text>
|
89
|
+
</TouchableOpacity>
|
90
|
+
</View>
|
91
|
+
</View>
|
92
|
+
);
|
93
|
+
};
|
94
|
+
|
95
|
+
const styles = StyleSheet.create({
|
96
|
+
outerContainer: {},
|
97
|
+
bannerContainer: {
|
98
|
+
width: width,
|
99
|
+
height: 190,
|
100
|
+
},
|
101
|
+
bannerImage: {
|
102
|
+
flex: 1,
|
103
|
+
borderRadius: 8,
|
104
|
+
},
|
105
|
+
starContainer: {
|
106
|
+
position: 'absolute',
|
107
|
+
top: 10,
|
108
|
+
left: 10,
|
109
|
+
backgroundColor: 'rgba(0,0,0,0)',
|
110
|
+
},
|
111
|
+
starIcon: {
|
112
|
+
width: 30,
|
113
|
+
height: 30,
|
114
|
+
},
|
115
|
+
index: {
|
116
|
+
position: 'absolute',
|
117
|
+
top: 0,
|
118
|
+
left: 0,
|
119
|
+
right: 0,
|
120
|
+
bottom: 0,
|
121
|
+
textAlign: 'center',
|
122
|
+
textAlignVertical: 'center',
|
123
|
+
color: 'white',
|
124
|
+
fontSize: 14,
|
125
|
+
fontWeight: 'bold',
|
126
|
+
},
|
127
|
+
titleContainer: {
|
128
|
+
flex: 1,
|
129
|
+
width: '91.5%',
|
130
|
+
flexDirection: 'row',
|
131
|
+
justifyContent: 'space-between',
|
132
|
+
alignItems: 'center',
|
133
|
+
padding: 8,
|
134
|
+
backgroundColor: 'rgba(0,0,0,0.5)',
|
135
|
+
position: 'absolute',
|
136
|
+
bottom: 0,
|
137
|
+
left: 0,
|
138
|
+
right: 0,
|
139
|
+
},
|
140
|
+
titleText: {
|
141
|
+
color: 'white',
|
142
|
+
fontSize: 14,
|
143
|
+
fontWeight: 'bold',
|
144
|
+
marginBottom: 4,
|
145
|
+
},
|
146
|
+
gameIcon: {
|
147
|
+
width: 35,
|
148
|
+
height: 35,
|
149
|
+
borderRadius: 8,
|
150
|
+
},
|
151
|
+
coinIcon: {
|
152
|
+
width: 16,
|
153
|
+
height: 16,
|
154
|
+
},
|
155
|
+
points: {
|
156
|
+
fontSize: 12,
|
157
|
+
marginLeft: 4,
|
158
|
+
fontWeight: 'bold',
|
159
|
+
color: 'white',
|
160
|
+
},
|
161
|
+
rewardDetails: {
|
162
|
+
flexDirection: 'row',
|
163
|
+
alignItems: 'center',
|
164
|
+
},
|
165
|
+
rewards: {
|
166
|
+
fontSize: 10,
|
167
|
+
fontStyle: 'italic',
|
168
|
+
color: 'lightgray',
|
169
|
+
},
|
170
|
+
playButton: {
|
171
|
+
paddingHorizontal: 12,
|
172
|
+
paddingVertical: 2,
|
173
|
+
height: 31,
|
174
|
+
borderRadius: 8,
|
175
|
+
alignItems: 'center',
|
176
|
+
justifyContent: 'center',
|
177
|
+
},
|
178
|
+
playButtonText: {
|
179
|
+
fontSize: 16,
|
180
|
+
fontWeight: 'bold',
|
181
|
+
color: 'white',
|
182
|
+
},
|
183
|
+
});
|
184
|
+
|
184
185
|
export default PremiumOption4;
|
@@ -1,95 +1,95 @@
|
|
1
|
-
import axios, { type AxiosResponse } from 'axios';
|
2
|
-
import { getData } from '../../core/storage/storage';
|
3
|
-
|
4
|
-
interface ApiHeaders {
|
5
|
-
languageCode: string;
|
6
|
-
premiumColor: string;
|
7
|
-
xUserId: string;
|
8
|
-
xApiKey: string;
|
9
|
-
xApiSecret: string;
|
10
|
-
xSdkPlatform: string;
|
11
|
-
xSdkVersion: string;
|
12
|
-
userAgent: string;
|
13
|
-
}
|
14
|
-
|
15
|
-
const transformCampaigns = (campaigns: Campaign[]): TransformedCampaign[] => {
|
16
|
-
return campaigns.map((campaign) => ({
|
17
|
-
campaignId: campaign.campaignId || 0,
|
18
|
-
appId: campaign.app?.id || 0,
|
19
|
-
title: campaign.app?.title || 'Unknown Title',
|
20
|
-
creativePackName:
|
21
|
-
campaign.creative?.creativePacks?.[0]?.creativePackName || '',
|
22
|
-
fileUrl:
|
23
|
-
campaign.creative?.creativePacks?.[0]?.creatives?.[0]?.fileUrl || '',
|
24
|
-
points: campaign.campaignPayout?.totalPayoutConverted || 0,
|
25
|
-
rewards: campaign.campaignPayout?.totalEvents || 0,
|
26
|
-
currency: campaign.currency || {},
|
27
|
-
thumbnail: campaign.app?.thumbnail || '',
|
28
|
-
premium: campaign.premium || false,
|
29
|
-
sortingScore: campaign.sortingScore || 0,
|
30
|
-
}));
|
31
|
-
};
|
32
|
-
|
33
|
-
export const fetchCampaignsData = async (
|
34
|
-
// setLanguage: (language: string) => void,
|
35
|
-
setPremiumColor: (color: string) => void,
|
36
|
-
setCampaigns: (campaigns: TransformedCampaign[]) => void,
|
37
|
-
setError: (error: string) => void,
|
38
|
-
setIsLoading: (loading: boolean) => void
|
39
|
-
): Promise<void> => {
|
40
|
-
setIsLoading(true);
|
41
|
-
|
42
|
-
try {
|
43
|
-
const data: any = await getData('apiHeaders');
|
44
|
-
if (!data) {
|
45
|
-
throw new Error('apiHeaders data not found.');
|
46
|
-
}
|
47
|
-
const parsedHeaderData: ApiHeaders = JSON.parse(data);
|
48
|
-
// setLanguage(parsedHeaderData.languageCode);
|
49
|
-
setPremiumColor(parsedHeaderData.premiumColor);
|
50
|
-
|
51
|
-
const headers = {
|
52
|
-
'Content-Type': 'application/json',
|
53
|
-
Accept: 'application/json',
|
54
|
-
'X-User-ID': parsedHeaderData.xUserId,
|
55
|
-
'X-API-Key': parsedHeaderData.xApiKey,
|
56
|
-
'X-API-Secret': parsedHeaderData.xApiSecret,
|
57
|
-
'X-SDK-Platform': parsedHeaderData.xSdkPlatform,
|
58
|
-
'X-SDK-Version': parsedHeaderData.xSdkVersion,
|
59
|
-
'User-Agent': parsedHeaderData.userAgent,
|
60
|
-
};
|
61
|
-
|
62
|
-
const response: AxiosResponse<{ data: Campaign[] }> = await axios.get(
|
63
|
-
`https://api.tyrads.com/v2.0/campaigns?lang=${parsedHeaderData.languageCode}`,
|
64
|
-
{
|
65
|
-
headers: headers,
|
66
|
-
}
|
67
|
-
);
|
68
|
-
|
69
|
-
const transformedCampaigns = transformCampaigns(response.data.data);
|
70
|
-
|
71
|
-
const hotOffers = transformedCampaigns
|
72
|
-
.sort((a, b) => {
|
73
|
-
if (a.premium && !b.premium) return -1;
|
74
|
-
if (!a.premium && b.premium) return 1;
|
75
|
-
return b.sortingScore - a.sortingScore;
|
76
|
-
})
|
77
|
-
.filter((item) => item.points > 0)
|
78
|
-
.slice(0, 5);
|
79
|
-
|
80
|
-
setCampaigns(hotOffers);
|
81
|
-
} catch (error: any) {
|
82
|
-
if (axios.isAxiosError(error) && error.response) {
|
83
|
-
console.log('Response Error:', error.response.data);
|
84
|
-
console.log('Status Code:', error.response.status);
|
85
|
-
console.log('Response Headers:', error.response.headers);
|
86
|
-
} else if (axios.isAxiosError(error) && error.request) {
|
87
|
-
console.log('No Response from API:', error.request);
|
88
|
-
} else {
|
89
|
-
console.log('Error setting up request:', error.message);
|
90
|
-
}
|
91
|
-
setError('Something went wrong, please try again');
|
92
|
-
} finally {
|
93
|
-
setIsLoading(false);
|
94
|
-
}
|
1
|
+
import axios, { type AxiosResponse } from 'axios';
|
2
|
+
import { getData } from '../../core/storage/storage';
|
3
|
+
|
4
|
+
interface ApiHeaders {
|
5
|
+
languageCode: string;
|
6
|
+
premiumColor: string;
|
7
|
+
xUserId: string;
|
8
|
+
xApiKey: string;
|
9
|
+
xApiSecret: string;
|
10
|
+
xSdkPlatform: string;
|
11
|
+
xSdkVersion: string;
|
12
|
+
userAgent: string;
|
13
|
+
}
|
14
|
+
|
15
|
+
const transformCampaigns = (campaigns: Campaign[]): TransformedCampaign[] => {
|
16
|
+
return campaigns.map((campaign) => ({
|
17
|
+
campaignId: campaign.campaignId || 0,
|
18
|
+
appId: campaign.app?.id || 0,
|
19
|
+
title: campaign.app?.title || 'Unknown Title',
|
20
|
+
creativePackName:
|
21
|
+
campaign.creative?.creativePacks?.[0]?.creativePackName || '',
|
22
|
+
fileUrl:
|
23
|
+
campaign.creative?.creativePacks?.[0]?.creatives?.[0]?.fileUrl || '',
|
24
|
+
points: campaign.campaignPayout?.totalPayoutConverted || 0,
|
25
|
+
rewards: campaign.campaignPayout?.totalEvents || 0,
|
26
|
+
currency: campaign.currency || {},
|
27
|
+
thumbnail: campaign.app?.thumbnail || '',
|
28
|
+
premium: campaign.premium || false,
|
29
|
+
sortingScore: campaign.sortingScore || 0,
|
30
|
+
}));
|
31
|
+
};
|
32
|
+
|
33
|
+
export const fetchCampaignsData = async (
|
34
|
+
// setLanguage: (language: string) => void,
|
35
|
+
setPremiumColor: (color: string) => void,
|
36
|
+
setCampaigns: (campaigns: TransformedCampaign[]) => void,
|
37
|
+
setError: (error: string) => void,
|
38
|
+
setIsLoading: (loading: boolean) => void
|
39
|
+
): Promise<void> => {
|
40
|
+
setIsLoading(true);
|
41
|
+
|
42
|
+
try {
|
43
|
+
const data: any = await getData('apiHeaders');
|
44
|
+
if (!data) {
|
45
|
+
throw new Error('apiHeaders data not found.');
|
46
|
+
}
|
47
|
+
const parsedHeaderData: ApiHeaders = JSON.parse(data);
|
48
|
+
// setLanguage(parsedHeaderData.languageCode);
|
49
|
+
setPremiumColor(parsedHeaderData.premiumColor);
|
50
|
+
|
51
|
+
const headers = {
|
52
|
+
'Content-Type': 'application/json',
|
53
|
+
Accept: 'application/json',
|
54
|
+
'X-User-ID': parsedHeaderData.xUserId,
|
55
|
+
'X-API-Key': parsedHeaderData.xApiKey,
|
56
|
+
'X-API-Secret': parsedHeaderData.xApiSecret,
|
57
|
+
'X-SDK-Platform': parsedHeaderData.xSdkPlatform,
|
58
|
+
'X-SDK-Version': parsedHeaderData.xSdkVersion,
|
59
|
+
'User-Agent': parsedHeaderData.userAgent,
|
60
|
+
};
|
61
|
+
|
62
|
+
const response: AxiosResponse<{ data: Campaign[] }> = await axios.get(
|
63
|
+
`https://api.tyrads.com/v2.0/campaigns?lang=${parsedHeaderData.languageCode}`,
|
64
|
+
{
|
65
|
+
headers: headers,
|
66
|
+
}
|
67
|
+
);
|
68
|
+
|
69
|
+
const transformedCampaigns = transformCampaigns(response.data.data);
|
70
|
+
|
71
|
+
const hotOffers = transformedCampaigns
|
72
|
+
.sort((a, b) => {
|
73
|
+
if (a.premium && !b.premium) return -1;
|
74
|
+
if (!a.premium && b.premium) return 1;
|
75
|
+
return b.sortingScore - a.sortingScore;
|
76
|
+
})
|
77
|
+
.filter((item) => item.points > 0)
|
78
|
+
.slice(0, 5);
|
79
|
+
|
80
|
+
setCampaigns(hotOffers);
|
81
|
+
} catch (error: any) {
|
82
|
+
if (axios.isAxiosError(error) && error.response) {
|
83
|
+
console.log('Response Error:', error.response.data);
|
84
|
+
console.log('Status Code:', error.response.status);
|
85
|
+
console.log('Response Headers:', error.response.headers);
|
86
|
+
} else if (axios.isAxiosError(error) && error.request) {
|
87
|
+
console.log('No Response from API:', error.request);
|
88
|
+
} else {
|
89
|
+
console.log('Error setting up request:', error.message);
|
90
|
+
}
|
91
|
+
setError('Something went wrong, please try again');
|
92
|
+
} finally {
|
93
|
+
setIsLoading(false);
|
94
|
+
}
|
95
95
|
};
|