Skip to content

Commit f1ad803

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

File tree

10 files changed

+439
-0
lines changed

10 files changed

+439
-0
lines changed
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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("first_name")]
35+
public string FirstName { get; set; }
36+
37+
[JsonProperty("first_name_kana")]
38+
public string FirstNameKana { get; set; }
39+
40+
[JsonProperty("first_name_kanji")]
41+
public string FirstNameKanji { get; set; }
42+
43+
[JsonProperty("gender")]
44+
public string Gender { get; set; }
45+
46+
[JsonProperty("last_name")]
47+
public string LastName { get; set; }
48+
49+
[JsonProperty("last_name_kana")]
50+
public string LastNameKana { get; set; }
51+
52+
[JsonProperty("last_name_kanji")]
53+
public string LastNameKanji { get; set; }
54+
55+
[JsonProperty("maiden_name")]
56+
public string MaidenName { get; set; }
57+
58+
[JsonProperty("relationship")]
59+
public Relationship Relationship { get; set; }
60+
61+
[JsonProperty("requirements")]
62+
public Requirements Requirements { get; set; }
63+
64+
[JsonProperty("ssn_last_4_provided")]
65+
public bool SsnLast4Provided { get; set; }
66+
67+
[JsonProperty("verification")]
68+
public LegalEntityVerification Verification { get; set; }
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class Relationship : StripeEntity
6+
{
7+
[JsonProperty("controller")]
8+
public bool Controller { get; set; }
9+
10+
[JsonProperty("director")]
11+
public bool Director { get; set; }
12+
13+
[JsonProperty("email")]
14+
public string Email { 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("phone")]
23+
public string Phone { get; set; }
24+
25+
[JsonProperty("representative")]
26+
public bool Representative { get; set; }
27+
28+
[JsonProperty("title")]
29+
public string Title { get; set; }
30+
}
31+
}
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,16 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class PersonListOptions : ListOptions
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,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,52 @@
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("first_name")]
23+
public string FirstName { get; set; }
24+
25+
[JsonProperty("first_name_kana")]
26+
public string FirstNameKana { get; set; }
27+
28+
[JsonProperty("first_name_kanji")]
29+
public string FirstNameKanji { get; set; }
30+
31+
[JsonProperty("gender")]
32+
public string Gender { get; set; }
33+
34+
[JsonProperty("last_name")]
35+
public string LastName { get; set; }
36+
37+
[JsonProperty("last_name_kana")]
38+
public string LastNameKana { get; set; }
39+
40+
[JsonProperty("last_name_kanji")]
41+
public string LastNameKanji { get; set; }
42+
43+
[JsonProperty("maiden_name")]
44+
public string MaidenName { get; set; }
45+
46+
[JsonProperty("personal_id_number")]
47+
public string PersonalIdNumber { get; set; }
48+
49+
[JsonProperty("ssn_last_4")]
50+
public string SSNLast4 { get; set; }
51+
}
52+
}
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,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)