Skip to content

Commit 4feeae0

Browse files
committed
Internal improvements
- Added endpoint operations - Added given name, family name and phone number fields - Moved to 1.0.6
1 parent c253599 commit 4feeae0

File tree

8 files changed

+142
-13
lines changed

8 files changed

+142
-13
lines changed

samples/Example.Cli/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ class Program
1717
static async Task AsyncMain(string[] args) {
1818
ApiClient cc = new ApiClient(Environment.GetEnvironmentVariable("API_KEY"), Environment.GetEnvironmentVariable("API_SECRET"));
1919
cc.Authentication = new SessionAuthentication(Environment.GetEnvironmentVariable("SESSION_TOKEN"));
20-
21-
DeviceSetupTokenEntity entity = await cc.Devices.AddDeviceSetupTokenAsync();
2220
}
2321
}
2422
}

src/WifiPlug.Api/Entities/ActivateUserEntity.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,23 @@ public class ActivateUserEntity
3333
/// </summary>
3434
[JsonProperty(PropertyName = "password")]
3535
public string Password { get; set; }
36+
37+
/// <summary>
38+
/// Gets or sets the given name.
39+
/// </summary>
40+
[JsonProperty(PropertyName = "given_name", DefaultValueHandling = DefaultValueHandling.Ignore)]
41+
public string GivenName { get; set; }
42+
43+
/// <summary>
44+
/// Gets or sets the family name.
45+
/// </summary>
46+
[JsonProperty(PropertyName = "family_name", DefaultValueHandling = DefaultValueHandling.Ignore)]
47+
public string FamilyName { get; set; }
48+
49+
/// <summary>
50+
/// Gets or sets the phone number.
51+
/// </summary>
52+
[JsonProperty(PropertyName = "phone", DefaultValueHandling = DefaultValueHandling.Ignore)]
53+
public string PhoneNumber { get; set; }
3654
}
3755
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace WifiPlug.Api.Entities
7+
{
8+
/// <summary>
9+
/// Represents an endpoint add entity.
10+
/// </summary>
11+
public class EndpointAddEntity
12+
{
13+
/// <summary>
14+
/// Gets or sets the application UUID.
15+
/// </summary>
16+
[JsonProperty("application")]
17+
public Guid ApplicationUUID { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets the device model.
21+
/// </summary>
22+
[JsonProperty("device_model")]
23+
public string DeviceModel { get; set; }
24+
25+
/// <summary>
26+
/// Gets or sets the device operating system.
27+
/// </summary>
28+
[JsonProperty("device_os")]
29+
public string DeviceOS { get; set; }
30+
31+
/// <summary>
32+
/// Gets or sets the 2-letter country code.
33+
/// </summary>
34+
[JsonProperty("country")]
35+
public string Country { get; set; }
36+
}
37+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace WifiPlug.Api.Entities
7+
{
8+
/// <summary>
9+
/// Represents a request to edit an endpoints notification token.
10+
/// </summary>
11+
public class EndpointEditNotificationEntity
12+
{
13+
/// <summary>
14+
/// Gets or sets the push token.
15+
/// </summary>
16+
[JsonProperty("push_token")]
17+
public string PushToken { get; set; }
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace WifiPlug.Api.Entities
7+
{
8+
/// <summary>
9+
/// Represents an endpoint.
10+
/// </summary>
11+
public class EndpointEntity
12+
{
13+
/// <summary>
14+
/// Gets or sets the UUID.
15+
/// </summary>
16+
[JsonProperty("uuid")]
17+
public Guid UUID { get; set; }
18+
}
19+
}

src/WifiPlug.Api/Operations/IUserOperations.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,28 @@ public interface IUserOperations
101101
Task<UserEntity> ActivateUserAsync(ActivateUserEntity entity, CancellationToken cancellationToken = default(CancellationToken));
102102

103103
/// <summary>
104-
/// Adds a user notification token to the current user.
104+
/// Adds an endpoint entity.
105105
/// </summary>
106-
/// <param name="entity">The entity.</param>
106+
/// <param name="entity">The endpoint add entity.</param>
107+
/// <param name="cancellationToken">The cancellation token.</param>
108+
/// <returns></returns>
109+
Task<EndpointEntity> AddEndpointAsync(EndpointAddEntity entity, CancellationToken cancellationToken = default(CancellationToken));
110+
111+
/// <summary>
112+
/// Gets an endpoint entity.
113+
/// </summary>
114+
/// <param name="endpointUuid">The endpoint UUID.</param>
115+
/// <param name="cancellationToken">The cancellation token.</param>
116+
/// <returns></returns>
117+
Task<EndpointEntity> GetEndpointAsync(Guid endpointUuid, CancellationToken cancellationToken = default(CancellationToken));
118+
119+
/// <summary>
120+
/// Edits an endpoints notification token.
121+
/// </summary>
122+
/// <param name="endpointUuid">The endpoint UUID.</param>
123+
/// <param name="entity">The endpoint add notification entity.</param>
107124
/// <param name="cancellationToken">The cancellation token.</param>
108-
/// <remarks>This operation is internal and won't work with normal API keys. Nor is it stable.</remarks>
109125
/// <returns></returns>
110-
Task AddUserNotificationAsync(UserNotificationAddEntity entity, CancellationToken cancellationToken = default(CancellationToken));
126+
Task EditEndpointNotificationAsync(Guid endpointUuid, EndpointEditNotificationEntity entity, CancellationToken cancellationToken = default(CancellationToken));
111127
}
112128
}

src/WifiPlug.Api/Operations/UserOperations.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,38 @@ public class UserOperations : IUserOperations
133133
public Task<UserEntity> ActivateUserAsync(ActivateUserEntity entity, CancellationToken cancellationToken = default(CancellationToken)) {
134134
return _client.RequestJsonSerializedAsync<ActivateUserEntity, UserEntity>(HttpMethod.Post, "user/activate", entity, cancellationToken);
135135
}
136+
137+
/// <summary>
138+
/// Adds an endpoint entity.
139+
/// </summary>
140+
/// <param name="entity">The endpoint add entity.</param>
141+
/// <param name="cancellationToken">The cancellation token.</param>
142+
/// <remarks>This operation is internal and won't work with normal API keys. Nor is it stable.</remarks>
143+
/// <returns>The endpoint entity.</returns>
144+
public Task<EndpointEntity> AddEndpointAsync(EndpointAddEntity entity, CancellationToken cancellationToken = default(CancellationToken)) {
145+
return _client.RequestJsonSerializedAsync<EndpointAddEntity, EndpointEntity>(HttpMethod.Post, "user/endpoint/add", entity, cancellationToken);
146+
}
136147

137148
/// <summary>
138-
/// Adds a user notification token to the current user.
149+
/// Gets an endpoint entity.
139150
/// </summary>
140-
/// <param name="entity">The entity.</param>
151+
/// <param name="endpointUuid">The endpoint UUID.</param>
152+
/// <param name="cancellationToken">The cancellation token.</param>
153+
/// <returns>The endpoint entity.</returns>
154+
public Task<EndpointEntity> GetEndpointAsync(Guid endpointUuid, CancellationToken cancellationToken = default(CancellationToken)) {
155+
return _client.RequestJsonSerializedAsync<EndpointEntity>(HttpMethod.Get, $"user/endpoint/{endpointUuid}", cancellationToken);
156+
}
157+
158+
/// <summary>
159+
/// Edits an endpoints notification token.
160+
/// </summary>
161+
/// <param name="endpointUuid">The endpoint UUID.</param>
162+
/// <param name="entity">The endpoint add notification entity.</param>
141163
/// <param name="cancellationToken">The cancellation token.</param>
142164
/// <remarks>This operation is internal and won't work with normal API keys. Nor is it stable.</remarks>
143165
/// <returns></returns>
144-
public Task AddUserNotificationAsync(UserNotificationAddEntity entity, CancellationToken cancellationToken = default(CancellationToken)) {
145-
return _client.RequestJsonSerializedAsync(HttpMethod.Post, "user/notification/add", entity, cancellationToken);
166+
public Task EditEndpointNotificationAsync(Guid endpointUuid, EndpointEditNotificationEntity entity, CancellationToken cancellationToken = default(CancellationToken)) {
167+
return _client.RequestJsonSerializedAsync(HttpMethod.Post, $"user/endpoint/{endpointUuid}/push_notification", entity, cancellationToken);
146168
}
147169

148170
/// <summary>

src/WifiPlug.Api/WifiPlug.Api.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
<PackageProjectUrl>https://wifiplug.co.uk</PackageProjectUrl>
1212
<RepositoryUrl>https://github.com/wifiplug/api-client-net</RepositoryUrl>
1313
<RepositoryType>git</RepositoryType>
14-
<AssemblyVersion>0.1.0.5</AssemblyVersion>
15-
<FileVersion>0.1.0.5</FileVersion>
14+
<AssemblyVersion>0.1.0.6</AssemblyVersion>
15+
<FileVersion>0.1.0.6</FileVersion>
1616
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1717
<PackageIconUrl>https://s3.eu-west-2.amazonaws.com/wifiplug-pub/nuget-icons/wifiplug.png</PackageIconUrl>
1818
<PackageLicenseUrl>https://github.com/wifiplug/api-client-net/blob/master/LICENSE</PackageLicenseUrl>
19-
<Version>1.0.5</Version>
19+
<Version>1.0.6</Version>
2020
</PropertyGroup>
2121

2222
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

0 commit comments

Comments
 (0)