File tree Expand file tree Collapse file tree
DotNetCliCodeSnippets/Reports Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #region
2+
3+ using System ;
4+ using System . Threading . Tasks ;
5+ using Vonage . Reports . CancelReport ;
6+
7+ #endregion
8+
9+ namespace DotnetCliCodeSnippets . Reports ;
10+
11+ public class CancelReport : ReportBaseRequest , ICodeSnippet
12+ {
13+ public async Task Execute ( )
14+ {
15+ var requestId = Guid . Parse ( Environment . GetEnvironmentVariable ( "REQUEST_ID" ) ! ) ;
16+ var request = CancelReportRequest . Build ( )
17+ . WithReportId ( requestId )
18+ . Create ( ) ;
19+ var response = await Client . ReportsClient . CancelReportAsync ( request ) ;
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ #region
2+
3+ using System ;
4+ using System . Threading . Tasks ;
5+ using Vonage . Reports ;
6+ using Vonage . Reports . CreateReport ;
7+
8+ #endregion
9+
10+ namespace DotnetCliCodeSnippets . Reports ;
11+
12+ public class CreateReport : ReportBaseRequest , ICodeSnippet
13+ {
14+ public async Task Execute ( )
15+ {
16+ var product = Enum . Parse < ReportProduct > ( Environment . GetEnvironmentVariable ( "REPORT_PRODUCT" ) ! ) ;
17+ var accountId = Environment . GetEnvironmentVariable ( "ACCOUNT_ID" ) ;
18+ var direction = Enum . Parse < RecordDirection > ( Environment . GetEnvironmentVariable ( "REPORT_DIRECTION" ) ! ) ;
19+ var dateStart = DateTimeOffset . Parse ( Environment . GetEnvironmentVariable ( "DATE_START" ) ! ) ;
20+ var dateEnd = DateTimeOffset . Parse ( Environment . GetEnvironmentVariable ( "DATE_END" ) ! ) ;
21+ var status = Environment . GetEnvironmentVariable ( "STATUS" ) ;
22+ var request = CreateReportRequest . Build ( )
23+ . WithProduct ( product )
24+ . WithAccountId ( accountId )
25+ . WithDirection ( direction )
26+ . WithDateStart ( dateStart )
27+ . WithDateEnd ( dateEnd )
28+ . WithStatus ( status )
29+ . Create ( ) ;
30+ var response = await Client . ReportsClient . CreateReportAsync ( request ) ;
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ #region
2+
3+ using System ;
4+ using System . Threading . Tasks ;
5+ using Vonage . Reports . DownloadReport ;
6+ using Vonage . Reports . GetReport ;
7+
8+ #endregion
9+
10+ namespace DotnetCliCodeSnippets . Reports ;
11+
12+ public class DownloadReport : ReportBaseRequest , ICodeSnippet
13+ {
14+ public async Task Execute ( )
15+ {
16+ var requestId = Guid . Parse ( Environment . GetEnvironmentVariable ( "FILE_ID" ) ! ) ;
17+ var request = DownloadReportRequest . Build ( )
18+ . WithFileId ( requestId )
19+ . Create ( ) ;
20+ var response = await Client . ReportsClient . DownloadReportAsync ( request ) ;
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ #region
2+
3+ using System ;
4+ using System . Threading . Tasks ;
5+ using Vonage . Reports . GetReport ;
6+
7+ #endregion
8+
9+ namespace DotnetCliCodeSnippets . Reports ;
10+
11+ public class GetReport : ReportBaseRequest , ICodeSnippet
12+ {
13+ public async Task Execute ( )
14+ {
15+ var requestId = Guid . Parse ( Environment . GetEnvironmentVariable ( "REQUEST_ID" ) ! ) ;
16+ var request = GetReportRequest . Build ( )
17+ . WithReportId ( requestId )
18+ . Create ( ) ;
19+ var response = await Client . ReportsClient . GetReportAsync ( request ) ;
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ #region
2+
3+ using System ;
4+ using System . Threading . Tasks ;
5+ using Vonage . Reports ;
6+ using Vonage . Reports . LoadRecords ;
7+
8+ #endregion
9+
10+ namespace DotnetCliCodeSnippets . Reports ;
11+
12+ public class LoadsRecordsByDate : ReportBaseRequest , ICodeSnippet
13+ {
14+ public async Task Execute ( )
15+ {
16+ var product = Enum . Parse < ReportProduct > ( Environment . GetEnvironmentVariable ( "REPORT_PRODUCT" ) ! ) ;
17+ var accountId = Environment . GetEnvironmentVariable ( "ACCOUNT_ID" ) ;
18+ var direction = Enum . Parse < RecordDirection > ( Environment . GetEnvironmentVariable ( "REPORT_DIRECTION" ) ! ) ;
19+ var dateStart = DateTimeOffset . Parse ( Environment . GetEnvironmentVariable ( "DATE_START" ) ! ) ;
20+ var dateEnd = DateTimeOffset . Parse ( Environment . GetEnvironmentVariable ( "DATE_END" ) ! ) ;
21+ var request = LoadRecordsRequest . Build ( )
22+ . WithProduct ( product )
23+ . WithAccountId ( accountId )
24+ . WithDirection ( direction )
25+ . WithDateStart ( dateStart )
26+ . WithDateEnd ( dateEnd )
27+ . Create ( ) ;
28+ var response = await Client . ReportsClient . LoadRecordsAsync ( request ) ;
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ #region
2+
3+ using System ;
4+ using System . Threading . Tasks ;
5+ using Vonage . Reports ;
6+ using Vonage . Reports . LoadRecords ;
7+
8+ #endregion
9+
10+ namespace DotnetCliCodeSnippets . Reports ;
11+
12+ public class LoadsRecordsByUUID : ReportBaseRequest , ICodeSnippet
13+ {
14+ public async Task Execute ( )
15+ {
16+ var product = Enum . Parse < ReportProduct > ( Environment . GetEnvironmentVariable ( "REPORT_PRODUCT" ) ! ) ;
17+ var accountId = Environment . GetEnvironmentVariable ( "ACCOUNT_ID" ) ;
18+ var direction = Enum . Parse < RecordDirection > ( Environment . GetEnvironmentVariable ( "REPORT_DIRECTION" ) ! ) ;
19+ var id = Environment . GetEnvironmentVariable ( "ID" ) ;
20+ var request = LoadRecordsRequest . Build ( )
21+ . WithProduct ( product )
22+ . WithAccountId ( accountId )
23+ . WithDirection ( direction )
24+ . WithId ( id )
25+ . Create ( ) ;
26+ var response = await Client . ReportsClient . LoadRecordsAsync ( request ) ;
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ #region
2+
3+ using System ;
4+ using Vonage ;
5+ using Vonage . Request ;
6+
7+ #endregion
8+
9+ namespace DotnetCliCodeSnippets . Reports ;
10+
11+ public abstract class ReportBaseRequest
12+ {
13+ protected readonly VonageClient Client ;
14+
15+ internal ReportBaseRequest ( )
16+ {
17+ var VONAGE_API_KEY = Environment . GetEnvironmentVariable ( "VONAGE_API_KEY" ) ?? "VONAGE_API_KEY" ;
18+ var VONAGE_API_SECRET = Environment . GetEnvironmentVariable ( "VONAGE_API_SECRET" ) ?? "VONAGE_API_SECRET" ;
19+ var credentials = Credentials . FromApiKeyAndSecret ( VONAGE_API_KEY , VONAGE_API_SECRET ) ;
20+ Client = new VonageClient ( credentials ) ;
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments