-
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 #1388 from stripe/remi-add-terminal
Add support for Terminal resources
- Loading branch information
Showing
23 changed files
with
672 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/Stripe.net/Entities/Terminal/ConnectionTokens/ConnectionToken.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,16 @@ | ||
namespace Stripe.Terminal | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class ConnectionToken : StripeEntity, IHasObject | ||
{ | ||
[JsonProperty("object")] | ||
public string Object { get; set; } | ||
|
||
[JsonProperty("secret")] | ||
public string Secret { 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,22 @@ | ||
namespace Stripe.Terminal | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class Location : StripeEntity, IHasId, IHasObject | ||
{ | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
[JsonProperty("object")] | ||
public string Object { get; set; } | ||
|
||
[JsonProperty("address")] | ||
public Address Address { get; set; } | ||
|
||
[JsonProperty("display_name")] | ||
public string DisplayName { 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,37 @@ | ||
namespace Stripe.Terminal | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class Reader : StripeEntity, IHasObject | ||
{ | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
[JsonProperty("object")] | ||
public string Object { get; set; } | ||
|
||
[JsonProperty("device_sw_version")] | ||
public string DeviceSwVersion { get; set; } | ||
|
||
[JsonProperty("device_type")] | ||
public string DeviceType { get; set; } | ||
|
||
[JsonProperty("ip_address")] | ||
public string IpAddress { get; set; } | ||
|
||
[JsonProperty("label")] | ||
public string Label { get; set; } | ||
|
||
[JsonProperty("location")] | ||
public string Location { get; set; } | ||
|
||
[JsonProperty("serial_number")] | ||
public string SerialNumber { get; set; } | ||
|
||
[JsonProperty("status")] | ||
public string Status { 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
8 changes: 8 additions & 0 deletions
8
src/Stripe.net/Services/Terminal/ConnectionTokens/ConnectionTokenCreateOptions.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.Terminal | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class ConnectionTokenCreateOptions : BaseOptions | ||
{ | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Stripe.net/Services/Terminal/ConnectionTokens/ConnectionTokenService.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,33 @@ | ||
namespace Stripe.Terminal | ||
{ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Stripe.Infrastructure; | ||
|
||
public class ConnectionTokenService : Service<ConnectionToken>, | ||
ICreatable<ConnectionToken, ConnectionTokenCreateOptions> | ||
{ | ||
public ConnectionTokenService() | ||
: base(null) | ||
{ | ||
} | ||
|
||
public ConnectionTokenService(string apiKey) | ||
: base(apiKey) | ||
{ | ||
} | ||
|
||
public override string BasePath => "/terminal/connection_tokens"; | ||
|
||
public virtual ConnectionToken Create(ConnectionTokenCreateOptions options = null, RequestOptions requestOptions = null) | ||
{ | ||
return this.CreateEntity(options, requestOptions); | ||
} | ||
|
||
public virtual Task<ConnectionToken> CreateAsync(ConnectionTokenCreateOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.CreateEntityAsync(options, requestOptions, cancellationToken); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Stripe.net/Services/Terminal/Locations/LocationCreateOptions.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.Terminal | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class LocationCreateOptions : LocationSharedOptions | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Stripe.net/Services/Terminal/Locations/LocationListOptions.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.Terminal | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class LocationListOptions : ListOptions | ||
{ | ||
[JsonProperty("operator_account")] | ||
public string OperatorAccount { get; set; } | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/Stripe.net/Services/Terminal/Locations/LocationService.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,63 @@ | ||
namespace Stripe.Terminal | ||
{ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Stripe.Infrastructure; | ||
|
||
public class LocationService : Service<Location>, | ||
ICreatable<Location, LocationCreateOptions> | ||
{ | ||
public LocationService() | ||
: base(null) | ||
{ | ||
} | ||
|
||
public LocationService(string apiKey) | ||
: base(apiKey) | ||
{ | ||
} | ||
|
||
public override string BasePath => "/terminal/locations"; | ||
|
||
public virtual Location Create(LocationCreateOptions options, RequestOptions requestOptions = null) | ||
{ | ||
return this.CreateEntity(options, requestOptions); | ||
} | ||
|
||
public virtual Task<Location> CreateAsync(LocationCreateOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.CreateEntityAsync(options, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual Location Get(string locationId, RequestOptions requestOptions = null) | ||
{ | ||
return this.GetEntity(locationId, null, requestOptions); | ||
} | ||
|
||
public virtual Task<Location> GetAsync(string locationId, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.GetEntityAsync(locationId, null, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual StripeList<Location> List(LocationListOptions options = null, RequestOptions requestOptions = null) | ||
{ | ||
return this.ListEntities(options, requestOptions); | ||
} | ||
|
||
public virtual Task<StripeList<Location>> ListAsync(LocationListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.ListEntitiesAsync(options, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual Location Update(string locationId, LocationUpdateOptions options, RequestOptions requestOptions = null) | ||
{ | ||
return this.UpdateEntity(locationId, options, requestOptions); | ||
} | ||
|
||
public virtual Task<Location> UpdateAsync(string locationId, LocationUpdateOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.UpdateEntityAsync(locationId, options, requestOptions, cancellationToken); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Stripe.net/Services/Terminal/Locations/LocationSharedOptions.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,13 @@ | ||
namespace Stripe.Terminal | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class LocationSharedOptions : BaseOptions | ||
{ | ||
[JsonProperty("address")] | ||
public AddressOptions Address { get; set; } | ||
|
||
[JsonProperty("display_name")] | ||
public string DisplayName { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Stripe.net/Services/Terminal/Locations/LocationUpdateOptions.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.Terminal | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class LocationUpdateOptions : LocationSharedOptions | ||
{ | ||
[JsonProperty("operator_account")] | ||
public string OperatorAccount { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Stripe.net/Services/Terminal/Readers/ReaderCreateOptions.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,13 @@ | ||
namespace Stripe.Terminal | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class ReaderCreateOptions : ReaderSharedOptions | ||
{ | ||
[JsonProperty("location")] | ||
public string Location { get; set; } | ||
|
||
[JsonProperty("registration_code")] | ||
public string RegistrationCode { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Stripe.net/Services/Terminal/Readers/ReaderListOptions.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,13 @@ | ||
namespace Stripe.Terminal | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class ReaderListOptions : ListOptions | ||
{ | ||
[JsonProperty("location")] | ||
public string Location { get; set; } | ||
|
||
[JsonProperty("operator_account")] | ||
public string OperatorAccount { 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,63 @@ | ||
namespace Stripe.Terminal | ||
{ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Stripe.Infrastructure; | ||
|
||
public class ReaderService : Service<Reader>, | ||
ICreatable<Reader, ReaderCreateOptions> | ||
{ | ||
public ReaderService() | ||
: base(null) | ||
{ | ||
} | ||
|
||
public ReaderService(string apiKey) | ||
: base(apiKey) | ||
{ | ||
} | ||
|
||
public override string BasePath => "/terminal/readers"; | ||
|
||
public virtual Reader Create(ReaderCreateOptions options, RequestOptions requestOptions = null) | ||
{ | ||
return this.CreateEntity(options, requestOptions); | ||
} | ||
|
||
public virtual Task<Reader> CreateAsync(ReaderCreateOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.CreateEntityAsync(options, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual Reader Get(string readerId, RequestOptions requestOptions = null) | ||
{ | ||
return this.GetEntity(readerId, null, requestOptions); | ||
} | ||
|
||
public virtual Task<Reader> GetAsync(string readerId, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.GetEntityAsync(readerId, null, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual StripeList<Reader> List(ReaderListOptions options = null, RequestOptions requestOptions = null) | ||
{ | ||
return this.ListEntities(options, requestOptions); | ||
} | ||
|
||
public virtual Task<StripeList<Reader>> ListAsync(ReaderListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.ListEntitiesAsync(options, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual Reader Update(string readerId, ReaderUpdateOptions options, RequestOptions requestOptions = null) | ||
{ | ||
return this.UpdateEntity(readerId, options, requestOptions); | ||
} | ||
|
||
public virtual Task<Reader> UpdateAsync(string readerId, ReaderUpdateOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.UpdateEntityAsync(readerId, options, requestOptions, cancellationToken); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Stripe.net/Services/Terminal/Readers/ReaderSharedOptions.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.Terminal | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class ReaderSharedOptions : BaseOptions | ||
{ | ||
[JsonProperty("label")] | ||
public string Label { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Stripe.net/Services/Terminal/Readers/ReaderUpdateOptions.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.Terminal | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class ReaderUpdateOptions : ReaderSharedOptions | ||
{ | ||
[JsonProperty("operator_account")] | ||
public string OperatorAccount { get; set; } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/StripeTests/Entities/Terminal/ConnectionTokens/ConnectionTokenTest.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 StripeTests.Terminal | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
using Newtonsoft.Json; | ||
using Stripe; | ||
using Stripe.Terminal; | ||
using Xunit; | ||
|
||
public class ConnectionTokenTest : BaseStripeTest | ||
{ | ||
[Fact] | ||
public void Deserialize() | ||
{ | ||
var json = GetResourceAsString("api_fixtures.connection_token.json"); | ||
var connectionToken = Mapper<ConnectionToken>.MapFromJson(json); | ||
Assert.NotNull(connectionToken); | ||
Assert.IsType<ConnectionToken>(connectionToken); | ||
Assert.NotNull(connectionToken.Secret); | ||
Assert.Equal("terminal.connection_token", connectionToken.Object); | ||
} | ||
} | ||
} |
Oops, something went wrong.