Skip to content

Commit 43c30d1

Browse files
committed
Add support for the Person resource
1 parent 64147e3 commit 43c30d1

14 files changed

+513
-2
lines changed

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ environment:
55
COVERALLS_REPO_TOKEN:
66
secure: T0PmP8uyzCseacBCDRBlti2y9Tz5DL6fknea0MKWvbPYrzADmLY2/5kOTfYIsPUk
77
# If you bump this, don't forget to bump `MinimumMockVersion` in `BaseStripeTest.cs` as well.
8-
STRIPE_MOCK_VERSION: 0.33.0
8+
STRIPE_MOCK_VERSION: 0.35.0
99

1010
deploy:
1111
- provider: NuGet
+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
namespace Stripe
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Newtonsoft.Json;
6+
using Stripe.Infrastructure;
7+
8+
public class Person : StripeEntity, IHasId, IHasObject
9+
{
10+
[JsonProperty("id")]
11+
public string Id { get; set; }
12+
13+
[JsonProperty("object")]
14+
public string Object { get; set; }
15+
16+
[JsonProperty("account")]
17+
public string AccountId { get; set; }
18+
19+
[JsonProperty("address")]
20+
public Address Address { get; set; }
21+
22+
[JsonProperty("address_kana")]
23+
public AddressJapan AddressKana { get; set; }
24+
25+
[JsonProperty("address_kanji")]
26+
public AddressJapan AddressKanji { get; set; }
27+
28+
[JsonProperty("created")]
29+
public DateTime Created { get; set; }
30+
31+
[JsonProperty("dob")]
32+
public BirthDay Dob { get; set; }
33+
34+
[JsonProperty("email")]
35+
public string Email { get; set; }
36+
37+
[JsonProperty("first_name")]
38+
public string FirstName { get; set; }
39+
40+
[JsonProperty("first_name_kana")]
41+
public string FirstNameKana { get; set; }
42+
43+
[JsonProperty("first_name_kanji")]
44+
public string FirstNameKanji { get; set; }
45+
46+
[JsonProperty("gender")]
47+
public string Gender { get; set; }
48+
49+
[JsonProperty("id_number_provider")]
50+
public bool IdNumberProvided { get; set; }
51+
52+
[JsonProperty("last_name")]
53+
public string LastName { get; set; }
54+
55+
[JsonProperty("last_name_kana")]
56+
public string LastNameKana { get; set; }
57+
58+
[JsonProperty("last_name_kanji")]
59+
public string LastNameKanji { get; set; }
60+
61+
[JsonProperty("maiden_name")]
62+
public string MaidenName { get; set; }
63+
64+
[JsonProperty("metadata")]
65+
public Dictionary<string, string> Metadata { get; set; }
66+
67+
[JsonProperty("phone")]
68+
public string Phone { get; set; }
69+
70+
[JsonProperty("relationship")]
71+
public Relationship Relationship { get; set; }
72+
73+
[JsonProperty("requirements")]
74+
public Requirements Requirements { get; set; }
75+
76+
[JsonProperty("ssn_last_4_provided")]
77+
public bool SsnLast4Provided { get; set; }
78+
79+
[JsonProperty("verification")]
80+
public LegalEntityVerification Verification { get; set; }
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class Relationship : StripeEntity
6+
{
7+
[JsonProperty("account_opener")]
8+
public bool AccountOpener { get; set; }
9+
10+
[JsonProperty("director")]
11+
public bool Director { get; set; }
12+
13+
[JsonProperty("executive")]
14+
public bool Executive { get; set; }
15+
16+
[JsonProperty("owner")]
17+
public bool Owner { get; set; }
18+
19+
[JsonProperty("percent_ownership")]
20+
public decimal? PercentOwnership { get; set; }
21+
22+
[JsonProperty("title")]
23+
public string Title { get; set; }
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class Requirements : StripeEntity
6+
{
7+
[JsonProperty("currently_due")]
8+
public string[] CurrentlyDue { get; set; }
9+
10+
[JsonProperty("eventually_due")]
11+
public string[] EventuallyDue { get; set; }
12+
13+
[JsonProperty("past_due")]
14+
public string[] PastDue { get; set; }
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class PersonCreateOptions : PersonSharedOptions
6+
{
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class PersonListOptions : ListOptions
6+
{
7+
[JsonProperty("relationship")]
8+
public RelationshipListOptions Relationship { get; set; }
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
namespace Stripe
2+
{
3+
using System.Collections.Generic;
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
using Stripe.Infrastructure;
7+
8+
public class PersonService : ServiceNested<Person>,
9+
INestedCreatable<Person, PersonCreateOptions>,
10+
INestedListable<Person, PersonListOptions>,
11+
INestedRetrievable<Person>,
12+
INestedUpdatable<Person, PersonUpdateOptions>
13+
{
14+
public PersonService()
15+
: base(null)
16+
{
17+
}
18+
19+
public PersonService(string apiKey)
20+
: base(apiKey)
21+
{
22+
}
23+
24+
public override string BasePath => "/accounts/{PARENT_ID}/persons";
25+
26+
public bool ExpandBalanceTransaction { get; set; }
27+
28+
public bool ExpandTransfer { get; set; }
29+
30+
public virtual Person Create(string accountId, PersonCreateOptions options = null, RequestOptions requestOptions = null)
31+
{
32+
return this.CreateNestedEntity(accountId, options, requestOptions);
33+
}
34+
35+
public virtual Task<Person> CreateAsync(string accountId, PersonCreateOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
36+
{
37+
return this.CreateNestedEntityAsync(accountId, options, requestOptions, cancellationToken);
38+
}
39+
40+
public virtual Person Delete(string accountId, string personId, RequestOptions requestOptions = null)
41+
{
42+
return this.DeleteNestedEntity(accountId, personId, null, requestOptions);
43+
}
44+
45+
public virtual Task<Person> DeleteAsync(string accountId, string personId, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
46+
{
47+
return this.DeleteNestedEntityAsync(accountId, personId, null, requestOptions, cancellationToken);
48+
}
49+
50+
public virtual Person Get(string accountId, string personId, RequestOptions requestOptions = null)
51+
{
52+
return this.GetNestedEntity(accountId, personId, null, requestOptions);
53+
}
54+
55+
public virtual Task<Person> GetAsync(string accountId, string personId, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
56+
{
57+
return this.GetNestedEntityAsync(accountId, personId, null, requestOptions, cancellationToken);
58+
}
59+
60+
public virtual StripeList<Person> List(string accountId, PersonListOptions options = null, RequestOptions requestOptions = null)
61+
{
62+
return this.ListNestedEntities(accountId, options, requestOptions);
63+
}
64+
65+
public virtual Task<StripeList<Person>> ListAsync(string accountId, PersonListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
66+
{
67+
return this.ListNestedEntitiesAsync(accountId, options, requestOptions, cancellationToken);
68+
}
69+
70+
public virtual Person Update(string accountId, string personId, PersonUpdateOptions options, RequestOptions requestOptions = null)
71+
{
72+
return this.UpdateNestedEntity(accountId, personId, options, requestOptions);
73+
}
74+
75+
public virtual Task<Person> UpdateAsync(string accountId, string personId, PersonUpdateOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
76+
{
77+
return this.UpdateNestedEntityAsync(accountId, personId, options, requestOptions, cancellationToken);
78+
}
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
namespace Stripe
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Newtonsoft.Json;
6+
using Stripe.Infrastructure;
7+
8+
public abstract class PersonSharedOptions : BaseOptions
9+
{
10+
[JsonProperty("address")]
11+
public AddressOptions Address { get; set; }
12+
13+
[JsonProperty("address_kana")]
14+
public AddressJapanOptions AddressKana { get; set; }
15+
16+
[JsonProperty("address_kanji")]
17+
public AddressJapanOptions AddressKanji { get; set; }
18+
19+
[JsonProperty("dob")]
20+
public AccountDobOptions Dob { get; set; }
21+
22+
[JsonProperty("email")]
23+
public string Email { get; set; }
24+
25+
[JsonProperty("first_name")]
26+
public string FirstName { get; set; }
27+
28+
[JsonProperty("first_name_kana")]
29+
public string FirstNameKana { get; set; }
30+
31+
[JsonProperty("first_name_kanji")]
32+
public string FirstNameKanji { get; set; }
33+
34+
[JsonProperty("gender")]
35+
public string Gender { get; set; }
36+
37+
[JsonProperty("id_number")]
38+
public string IdNumber { get; set; }
39+
40+
[JsonProperty("last_name")]
41+
public string LastName { get; set; }
42+
43+
[JsonProperty("last_name_kana")]
44+
public string LastNameKana { get; set; }
45+
46+
[JsonProperty("last_name_kanji")]
47+
public string LastNameKanji { get; set; }
48+
49+
[JsonProperty("maiden_name")]
50+
public string MaidenName { get; set; }
51+
52+
[JsonProperty("metadata")]
53+
public Dictionary<string, string> Metadata { get; set; }
54+
55+
[JsonProperty("personal_id_number")]
56+
public string PersonalIdNumber { get; set; }
57+
58+
[JsonProperty("phone")]
59+
public string Phone { get; set; }
60+
61+
[JsonProperty("relationship")]
62+
public RelationshipOptions Relationship { get; set; }
63+
64+
[JsonProperty("ssn_last_4")]
65+
public string SSNLast4 { get; set; }
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class PersonUpdateOptions : PersonSharedOptions
6+
{
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class RelationshipListOptions : INestedOptions
6+
{
7+
[JsonProperty("director")]
8+
public bool? Director { get; set; }
9+
10+
[JsonProperty("executive")]
11+
public bool? Executive { get; set; }
12+
13+
[JsonProperty("owner")]
14+
public bool? Owner { get; set; }
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class RelationshipOptions : INestedOptions
6+
{
7+
[JsonProperty("account_opener")]
8+
public bool? AccountOpener { get; set; }
9+
10+
[JsonProperty("director")]
11+
public bool? Director { get; set; }
12+
13+
[JsonProperty("executive")]
14+
public bool? Executive { get; set; }
15+
16+
[JsonProperty("owner")]
17+
public bool? Owner { get; set; }
18+
19+
[JsonProperty("percent_ownership")]
20+
public decimal? PercentOwnership { get; set; }
21+
22+
[JsonProperty("title")]
23+
public string Title { get; set; }
24+
}
25+
}

src/StripeTests/BaseStripeTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class BaseStripeTest
1919
/// <remarks>
2020
/// If you bump this, don't forget to bump `STRIPE_MOCK_VERSION` in appveyor.yml as well.
2121
/// </remarks>
22-
private const string MockMinimumVersion = "0.33.0";
22+
private const string MockMinimumVersion = "0.35.0";
2323

2424
private static Mock<HttpClientHandler> mockHandler = null;
2525

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace StripeTests
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Threading.Tasks;
6+
7+
using Newtonsoft.Json;
8+
using Stripe;
9+
using Xunit;
10+
11+
public class PersonTest : BaseStripeTest
12+
{
13+
[Fact]
14+
public void Deserialize()
15+
{
16+
string json = GetFixture("/v1/accounts/acct_123/persons/person_123");
17+
var person = Mapper<Person>.MapFromJson(json);
18+
Assert.NotNull(person);
19+
Assert.IsType<Person>(person);
20+
Assert.NotNull(person.Id);
21+
Assert.Equal("person", person.Object);
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)