-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1272 from stripe/remi-add-reporting-resources
Add support for Reporting resources
- Loading branch information
Showing
13 changed files
with
499 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Stripe.Reporting | ||
{ | ||
using System; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class Parameters : StripeEntity | ||
{ | ||
[JsonProperty("connected_account")] | ||
public string ConnectedAccount { get; set; } | ||
|
||
[JsonProperty("currency")] | ||
public string Currency { get; set; } | ||
|
||
[JsonProperty("interval_end")] | ||
[JsonConverter(typeof(StripeDateTimeConverter))] | ||
public DateTime IntervalEnd { get; set; } | ||
|
||
[JsonProperty("interval_start")] | ||
[JsonConverter(typeof(StripeDateTimeConverter))] | ||
public DateTime IntervalStart { get; set; } | ||
|
||
[JsonProperty("payout")] | ||
public string Payout { get; set; } | ||
|
||
[JsonProperty("reporting_category")] | ||
public string ReportingCategory { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace Stripe.Reporting | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class ReportRun : StripeEntityWithId | ||
{ | ||
[JsonProperty("object")] | ||
public string Object { get; set; } | ||
|
||
[JsonProperty("created")] | ||
[JsonConverter(typeof(StripeDateTimeConverter))] | ||
public DateTime Created { get; set; } | ||
|
||
[JsonProperty("error")] | ||
public string Error { get; set; } | ||
|
||
[JsonProperty("livemode")] | ||
public bool LiveMode { get; set; } | ||
|
||
[JsonProperty("parameters")] | ||
public Parameters Parameters { get; set; } | ||
|
||
[JsonProperty("reportType")] | ||
public string ReportType { get; set; } | ||
|
||
[JsonProperty("result")] | ||
public StripeFileUpload Result { get; set; } | ||
|
||
[JsonProperty("status")] | ||
public string Status { get; set; } | ||
|
||
[JsonProperty("succeeded_at")] | ||
[JsonConverter(typeof(StripeDateTimeConverter))] | ||
public DateTime SucceededAt { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace Stripe.Reporting | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class ReportType : StripeEntityWithId | ||
{ | ||
[JsonProperty("object")] | ||
public string Object { get; set; } | ||
|
||
[JsonProperty("data_available_end")] | ||
[JsonConverter(typeof(StripeDateTimeConverter))] | ||
public DateTime DataAvailableEnd { get; set; } | ||
|
||
[JsonProperty("data_available_start")] | ||
[JsonConverter(typeof(StripeDateTimeConverter))] | ||
public DateTime DataAvailableStart { get; set; } | ||
|
||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonProperty("updated")] | ||
[JsonConverter(typeof(StripeDateTimeConverter))] | ||
public DateTime Updated { get; set; } | ||
|
||
[JsonProperty("version")] | ||
public int Version { get; set; } | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/Stripe.net/Services/Reporting/ReportRuns/ParametersOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
namespace Stripe.Reporting | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class ParametersOptions : INestedOptions | ||
{ | ||
[JsonProperty("parameters[connected_account]")] | ||
public string ConnectedAccount { get; set; } | ||
|
||
[JsonProperty("parameters[currency]")] | ||
public string Currency { get; set; } | ||
|
||
public DateTime? IntervalEnd { get; set; } | ||
|
||
[JsonProperty("parameters[interval_end]")] | ||
internal long? IntervalEndInternal | ||
{ | ||
get | ||
{ | ||
if (!this.IntervalEnd.HasValue) | ||
{ | ||
return null; | ||
} | ||
|
||
return EpochTime.ConvertDateTimeToEpoch(this.IntervalEnd.Value); | ||
} | ||
} | ||
|
||
public DateTime? IntervalStart { get; set; } | ||
|
||
[JsonProperty("parameters[interval_start]")] | ||
internal long? IntervalStartInternal | ||
{ | ||
get | ||
{ | ||
if (!this.IntervalStart.HasValue) | ||
{ | ||
return null; | ||
} | ||
|
||
return EpochTime.ConvertDateTimeToEpoch(this.IntervalStart.Value); | ||
} | ||
} | ||
|
||
[JsonProperty("parameters[payout]")] | ||
public string Payout { get; set; } | ||
|
||
[JsonProperty("parameters[reporting_category]")] | ||
public string ReportingCategory { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Stripe.net/Services/Reporting/ReportRuns/ReportRunCreateOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Stripe.Reporting | ||
{ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
public class ReportRunCreateOptions : StripeBaseOptions | ||
{ | ||
[JsonProperty("parameters")] | ||
public ParametersOptions Parameters { get; set; } | ||
|
||
[JsonProperty("report_type")] | ||
public string ReportType { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Stripe.net/Services/Reporting/ReportRuns/ReportRunListOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Stripe.Reporting | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class ReportRunListOptions : StripeListOptions | ||
{ | ||
[JsonProperty("created")] | ||
public StripeDateFilter Created { get; set; } | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
src/Stripe.net/Services/Reporting/ReportRuns/ReportRunService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
namespace Stripe.Reporting | ||
{ | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Stripe.Infrastructure; | ||
|
||
public class ReportRunService : StripeService | ||
{ | ||
private static string classUrl = Urls.BaseUrl + "/reporting/report_runs"; | ||
|
||
public ReportRunService() | ||
: base(null) | ||
{ | ||
} | ||
|
||
public ReportRunService(string apiKey) | ||
: base(apiKey) | ||
{ | ||
} | ||
|
||
public virtual ReportRun Create(ReportRunCreateOptions createOptions, StripeRequestOptions requestOptions = null) | ||
{ | ||
return Mapper<ReportRun>.MapFromJson( | ||
Requestor.PostString( | ||
this.ApplyAllParameters(createOptions, classUrl, false), | ||
this.SetupRequestOptions(requestOptions))); | ||
} | ||
|
||
public virtual ReportRun Get(string reportRunId, StripeRequestOptions requestOptions = null) | ||
{ | ||
return Mapper<ReportRun>.MapFromJson( | ||
Requestor.GetString( | ||
this.ApplyAllParameters(null, $"{classUrl}/{reportRunId}", false), | ||
this.SetupRequestOptions(requestOptions))); | ||
} | ||
|
||
public virtual StripeList<ReportRun> List(ReportRunListOptions listOptions = null, StripeRequestOptions requestOptions = null) | ||
{ | ||
return Mapper<StripeList<ReportRun>>.MapFromJson( | ||
Requestor.GetString( | ||
this.ApplyAllParameters(listOptions, classUrl, true), | ||
this.SetupRequestOptions(requestOptions))); | ||
} | ||
|
||
public virtual async Task<ReportRun> CreateAsync(ReportRunCreateOptions createOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return Mapper<ReportRun>.MapFromJson( | ||
await Requestor.PostStringAsync( | ||
this.ApplyAllParameters(createOptions, classUrl, false), | ||
this.SetupRequestOptions(requestOptions), | ||
cancellationToken).ConfigureAwait(false)); | ||
} | ||
|
||
public virtual async Task<ReportRun> GetAsync(string reportRunId, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return Mapper<ReportRun>.MapFromJson( | ||
await Requestor.GetStringAsync( | ||
this.ApplyAllParameters(null, $"{classUrl}/{reportRunId}", false), | ||
this.SetupRequestOptions(requestOptions), | ||
cancellationToken).ConfigureAwait(false)); | ||
} | ||
|
||
public virtual async Task<StripeList<ReportRun>> ListAsync(ReportRunListOptions listOptions = null, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return Mapper<StripeList<ReportRun>>.MapFromJson( | ||
await Requestor.GetStringAsync( | ||
this.ApplyAllParameters(listOptions, classUrl, true), | ||
this.SetupRequestOptions(requestOptions), | ||
cancellationToken).ConfigureAwait(false)); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Stripe.net/Services/Reporting/ReportTypes/ReportTypeListOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Stripe.Reporting | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class ReportTypeListOptions : StripeListOptions | ||
{ | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/Stripe.net/Services/Reporting/ReportTypes/ReportTypeService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
namespace Stripe.Reporting | ||
{ | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Stripe.Infrastructure; | ||
|
||
public class ReportTypeService : StripeService | ||
{ | ||
private static string classUrl = Urls.BaseUrl + "/reporting/report_types"; | ||
|
||
public ReportTypeService() | ||
: base(null) | ||
{ | ||
} | ||
|
||
public ReportTypeService(string apiKey) | ||
: base(apiKey) | ||
{ | ||
} | ||
|
||
public virtual ReportType Get(string reportTypeId, StripeRequestOptions requestOptions = null) | ||
{ | ||
return Mapper<ReportType>.MapFromJson( | ||
Requestor.GetString( | ||
this.ApplyAllParameters(null, $"{classUrl}/{reportTypeId}", false), | ||
this.SetupRequestOptions(requestOptions))); | ||
} | ||
|
||
public virtual StripeList<ReportType> List(ReportTypeListOptions listOptions = null, StripeRequestOptions requestOptions = null) | ||
{ | ||
return Mapper<StripeList<ReportType>>.MapFromJson( | ||
Requestor.GetString( | ||
this.ApplyAllParameters(listOptions, classUrl, true), | ||
this.SetupRequestOptions(requestOptions))); | ||
} | ||
|
||
public virtual async Task<ReportType> GetAsync(string reportTypeId, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return Mapper<ReportType>.MapFromJson( | ||
await Requestor.GetStringAsync( | ||
this.ApplyAllParameters(null, $"{classUrl}/{reportTypeId}", false), | ||
this.SetupRequestOptions(requestOptions), | ||
cancellationToken).ConfigureAwait(false)); | ||
} | ||
|
||
public virtual async Task<StripeList<ReportType>> ListAsync(ReportTypeListOptions listOptions = null, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return Mapper<StripeList<ReportType>>.MapFromJson( | ||
await Requestor.GetStringAsync( | ||
this.ApplyAllParameters(listOptions, classUrl, true), | ||
this.SetupRequestOptions(requestOptions), | ||
cancellationToken).ConfigureAwait(false)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace StripeTests.Reporting | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
using Newtonsoft.Json; | ||
using Stripe; | ||
using Stripe.Reporting; | ||
using Xunit; | ||
|
||
public class ReportRunTest : BaseStripeTest | ||
{ | ||
[Fact] | ||
public void Deserialize() | ||
{ | ||
string json = GetFixture("/v1/reporting/report_runs/frr_123"); | ||
var reportRun = Mapper<ReportRun>.MapFromJson(json); | ||
Assert.NotNull(reportRun); | ||
Assert.IsType<ReportRun>(reportRun); | ||
Assert.NotNull(reportRun.Id); | ||
Assert.Equal("reporting.report_run", reportRun.Object); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace StripeTests.Reporting | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
using Newtonsoft.Json; | ||
using Stripe; | ||
using Stripe.Reporting; | ||
using Xunit; | ||
|
||
public class ReportTypeTest : BaseStripeTest | ||
{ | ||
[Fact] | ||
public void Deserialize() | ||
{ | ||
string json = GetFixture("/v1/reporting/report_types/activity.summary.1"); | ||
var reportType = Mapper<ReportType>.MapFromJson(json); | ||
Assert.NotNull(reportType); | ||
Assert.IsType<ReportType>(reportType); | ||
Assert.NotNull(reportType.Id); | ||
Assert.Equal("reporting.report_type", reportType.Object); | ||
} | ||
} | ||
} |
Oops, something went wrong.