-
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.
Add support for the Account Link resource
Also fixed a test as the latest openapi spec removed support for it. It's now gated. Leaving in the library though to avoid a major version
- Loading branch information
1 parent
6af79c7
commit 173dab3
Showing
7 changed files
with
155 additions
and
1 deletion.
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,24 @@ | ||
namespace Stripe | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class AccountLink : StripeEntity, IHasObject | ||
{ | ||
[JsonProperty("object")] | ||
public string Object { get; set; } | ||
|
||
[JsonProperty("created")] | ||
[JsonConverter(typeof(DateTimeConverter))] | ||
public DateTime? Created { get; set; } | ||
|
||
[JsonProperty("expires_at")] | ||
[JsonConverter(typeof(DateTimeConverter))] | ||
public DateTime? ExpiresAt { get; set; } | ||
|
||
[JsonProperty("url")] | ||
public string Url { get; set; } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Stripe.net/Services/AccountLinks/AccountLinkCreateOptions.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,25 @@ | ||
namespace Stripe | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class AccountLinkCreateOptions : BaseOptions | ||
{ | ||
[JsonProperty("account")] | ||
public string AccountId { get; set; } | ||
|
||
[JsonProperty("collect")] | ||
public string Collect { get; set; } | ||
|
||
[JsonProperty("failure_url")] | ||
public string FailureUrl { get; set; } | ||
|
||
[JsonProperty("success_url")] | ||
public string SuccessUrl { get; set; } | ||
|
||
[JsonProperty("type")] | ||
public string Type { get; set; } | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/Stripe.net/Services/AccountLinks/AccountLinkService.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,34 @@ | ||
namespace Stripe | ||
{ | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Stripe.Infrastructure; | ||
|
||
public class AccountLinkService : Service<AccountLink>, | ||
ICreatable<AccountLink, AccountLinkCreateOptions> | ||
{ | ||
public AccountLinkService() | ||
: base(null) | ||
{ | ||
} | ||
|
||
public AccountLinkService(string apiKey) | ||
: base(apiKey) | ||
{ | ||
} | ||
|
||
public override string BasePath => "/account_links"; | ||
|
||
public virtual AccountLink Create(AccountLinkCreateOptions options, RequestOptions requestOptions = null) | ||
{ | ||
return this.CreateEntity(options, requestOptions); | ||
} | ||
|
||
public virtual Task<AccountLink> CreateAsync(AccountLinkCreateOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.CreateEntityAsync(options, requestOptions, cancellationToken); | ||
} | ||
} | ||
} |
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,19 @@ | ||
namespace StripeTests | ||
{ | ||
using Newtonsoft.Json; | ||
using Stripe; | ||
using Xunit; | ||
|
||
public class AccountLinkTest : BaseStripeTest | ||
{ | ||
[Fact] | ||
public void Deserialize() | ||
{ | ||
var json = GetResourceAsString("api_fixtures.account_link.json"); | ||
var accountLink = JsonConvert.DeserializeObject<AccountLink>(json); | ||
Assert.NotNull(accountLink); | ||
Assert.IsType<AccountLink>(accountLink); | ||
Assert.Equal("account_link", accountLink.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,6 @@ | ||
{ | ||
"object": "account_link", | ||
"created": 1544220862, | ||
"expires_at": 1544221162, | ||
"url": "https://stripe.com/hv/12345" | ||
} |
47 changes: 47 additions & 0 deletions
47
src/StripeTests/Services/AccountLinks/AccountLinkServiceTest.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,47 @@ | ||
namespace StripeTests | ||
{ | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
using Stripe; | ||
using Xunit; | ||
|
||
public class AccountLinkServiceTest : BaseStripeTest | ||
{ | ||
private AccountLinkService service; | ||
private AccountLinkCreateOptions createOptions; | ||
|
||
public AccountLinkServiceTest() | ||
{ | ||
this.service = new AccountLinkService(); | ||
|
||
this.createOptions = new AccountLinkCreateOptions() | ||
{ | ||
AccountId = "acct_123", | ||
Collect = "eventually_due", | ||
FailureUrl = "https://stripe.com/failure", | ||
SuccessUrl = "https://stripe.com/success", | ||
Type = "custom_account_verification", | ||
}; | ||
} | ||
|
||
[Fact] | ||
public void Create() | ||
{ | ||
var accountLink = this.service.Create(this.createOptions); | ||
this.AssertRequest(HttpMethod.Post, "/v1/account_links"); | ||
Assert.NotNull(accountLink); | ||
Assert.Equal("account_link", accountLink.Object); | ||
} | ||
|
||
[Fact] | ||
public async Task CreateAsync() | ||
{ | ||
var accountLink = await this.service.CreateAsync(this.createOptions); | ||
this.AssertRequest(HttpMethod.Post, "/v1/account_links"); | ||
Assert.NotNull(accountLink); | ||
Assert.Equal("account_link", accountLink.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