1
1
using FikaAmazonAPI . AmazonSpApiSDK . Models . Exceptions ;
2
2
using FikaAmazonAPI . AmazonSpApiSDK . Models . Reports ;
3
+ using FikaAmazonAPI . AmazonSpApiSDK . Models . Token ;
4
+ using FikaAmazonAPI . Parameter ;
3
5
using FikaAmazonAPI . Parameter . Report ;
4
- using FikaAmazonAPI . Search ;
5
6
using FikaAmazonAPI . Utils ;
6
7
using System ;
7
8
using System . Collections . Generic ;
@@ -134,21 +135,42 @@ public async Task<ReportSchedule> GetReportScheduleAsync(string reportScheduleId
134
135
return null ;
135
136
}
136
137
137
- public ReportDocument GetReportDocument ( string reportDocumentId , IParameterBasedPII parameterBasedPII = null ) =>
138
- Task . Run ( ( ) => GetReportDocumentAsync ( reportDocumentId , parameterBasedPII ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
139
- public async Task < ReportDocument > GetReportDocumentAsync ( string reportDocumentId , IParameterBasedPII parameterBasedPII = null )
138
+ public ReportDocument GetReportDocument ( string reportDocumentId , bool isRestrictedReport = false ) =>
139
+ Task . Run ( ( ) => GetReportDocumentAsync ( reportDocumentId , isRestrictedReport ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
140
+ public async Task < ReportDocument > GetReportDocumentAsync ( string reportDocumentId , bool isRestrictedReport = false )
140
141
{
142
+ ParameterBasedPII parameterBasedPII = null ;
143
+
144
+ if ( isRestrictedReport )
145
+ {
146
+ parameterBasedPII = new ParameterBasedPII ( )
147
+ {
148
+ IsNeedRestrictedDataToken = true ,
149
+ RestrictedDataTokenRequest = new CreateRestrictedDataTokenRequest
150
+ {
151
+ restrictedResources = new List < RestrictedResource >
152
+ {
153
+ new RestrictedResource
154
+ {
155
+ method = Method . GET . ToString ( ) ,
156
+ path = ReportApiUrls . GetReportDocument ( reportDocumentId )
157
+ }
158
+ }
159
+ }
160
+ } ;
161
+ }
162
+
141
163
await CreateAuthorizedRequestAsync ( ReportApiUrls . GetReportDocument ( reportDocumentId ) , RestSharp . Method . GET , parameter : parameterBasedPII ) ;
142
164
var response = await ExecuteRequestAsync < ReportDocument > ( RateLimitType . Report_GetReportDocument ) ;
143
165
if ( response != null )
144
166
return response ;
145
167
return null ;
146
168
}
147
- public string GetReportFile ( string reportDocumentId ) =>
148
- Task . Run ( ( ) => GetReportFileAsync ( reportDocumentId ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
149
- public async Task < string > GetReportFileAsync ( string reportDocumentId )
169
+ public string GetReportFile ( string reportDocumentId , bool isRestrictedReport = false ) =>
170
+ Task . Run ( ( ) => GetReportFileAsync ( reportDocumentId , isRestrictedReport ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
171
+ public async Task < string > GetReportFileAsync ( string reportDocumentId , bool isRestrictedReport = false )
150
172
{
151
- var reportDocument = await GetReportDocumentAsync ( reportDocumentId ) ;
173
+ var reportDocument = await GetReportDocumentAsync ( reportDocumentId , isRestrictedReport ) ;
152
174
return GetFile ( reportDocument ) ;
153
175
}
154
176
@@ -223,12 +245,17 @@ public async Task<bool> CancelReportScheduleAsync(string reportScheduleId)
223
245
#endregion
224
246
225
247
226
- public string CreateReportAndDownloadFile ( ReportTypes reportTypes , DateTime ? dataStartTime = null , DateTime ? dataEndTime = null , ReportOptions reportOptions = null ) =>
227
- Task . Run ( ( ) => CreateReportAndDownloadFileAsync ( reportTypes , dataStartTime , dataEndTime , reportOptions ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
228
- public async Task < string > CreateReportAndDownloadFileAsync ( ReportTypes reportTypes , DateTime ? dataStartTime = null , DateTime ? dataEndTime = null , ReportOptions reportOptions = null )
248
+ public string CreateReportAndDownloadFile ( ReportTypes reportType , DateTime ? dataStartTime = null , DateTime ? dataEndTime = null , ReportOptions reportOptions = null , bool isRestrictedReport = false ) =>
249
+ Task . Run ( ( ) => CreateReportAndDownloadFileAsync ( reportType , dataStartTime , dataEndTime , reportOptions , isRestrictedReport ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
250
+ public async Task < string > CreateReportAndDownloadFileAsync ( ReportTypes reportType , DateTime ? dataStartTime = null , DateTime ? dataEndTime = null , ReportOptions reportOptions = null , bool isRestrictedReport = false )
229
251
{
252
+ if ( ! isRestrictedReport && Enum . TryParse < RestrictedReportTypes > ( reportType . ToString ( ) , out _ ) )
253
+ {
254
+ isRestrictedReport = true ;
255
+ }
256
+
230
257
var parameters = new ParameterCreateReportSpecification ( ) ;
231
- parameters . reportType = reportTypes ;
258
+ parameters . reportType = reportType ;
232
259
233
260
parameters . marketplaceIds = new MarketplaceIds ( ) ;
234
261
@@ -251,7 +278,7 @@ public async Task<string> CreateReportAndDownloadFileAsync(ReportTypes reportTyp
251
278
var reportData = await GetReportAsync ( reportId ) ;
252
279
if ( ! string . IsNullOrEmpty ( reportData . ReportDocumentId ) )
253
280
{
254
- filePath = await GetReportFileAsync ( reportData . ReportDocumentId ) ;
281
+ filePath = await GetReportFileAsync ( reportData . ReportDocumentId , isRestrictedReport ) ;
255
282
break ;
256
283
}
257
284
if ( reportData . ProcessingStatus == Report . ProcessingStatusEnum . FATAL )
0 commit comments