Skip to content

Commit 057cf39

Browse files
NFToken details (#35)
* Added model and request * Fixed XAppJwt namespaces * Clarified private member naming * Updated readme
1 parent 0fdedc9 commit 057cf39

File tree

8 files changed

+74
-20
lines changed

8 files changed

+74
-20
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The `GetPingAsync()` method allows you to verify API access (valid credentials)
6767
var pong = await MiscClient.GetPingAsync();
6868
```
6969

70-
Returns: [`XummPong`](https://github.com/XRPL-Labs/XUMM.NET.SDK/blob/main/XUMM.Net/Models/Misc/XummPong.cs)
70+
Returns: [`XummPong`](https://github.com/XRPL-Labs/XUMM.NET.SDK/blob/main/src/XUMM.NET.SDK/Models/Misc/XummPong.cs)
7171
```C#
7272
var pong = new XummPong
7373
{
@@ -133,7 +133,21 @@ live from the XRP ledger, as fetched for you by the XUMM backend.
133133
var txInfo = await MiscClient.GetTransactionAsync("00000000-0000-0000-0000-000000000000");
134134
```
135135

136-
Returns: [`XummTransaction`](https://github.com/XRPL-Labs/XUMM.NET.SDK/blob/main/XUMM.Net/Models/Misc/XummTransaction.cs)
136+
Returns: [`XummTransaction`](https://github.com/XRPL-Labs/XUMM.NET.SDK/blob/main/src/XUMM.NET.SDK/Models/Misc/XummTransaction.cs)
137+
138+
139+
##### IXummXAppJwtClient.GetNFTokenDetailAsync()
140+
141+
The `GetNFTokenDetailAsync` method allows you to get basic XLS20 token information as fetched/parsed/cached for you by the XUMM backend.
142+
143+
**Note**: it's best to retrieve these results **yourself** instead of relying on the XUMM platform to get live XRPL transaction information!
144+
145+
```C#
146+
@inject IXummXAppJwtClient XAppJwtClient
147+
var detall = await XAppJwtClient.GetNFTokenDetailAsync("", "");
148+
```
149+
150+
Returns: [`XummXAppJwtNFTokenDetail`](https://github.com/XRPL-Labs/XUMM.NET.SDK/blob/main/src/XUMM.NET.SDK/Models/XAppJwt/XummXAppJwtNFTokenDetail.cs)
137151

138152

139153
#### App Storage
@@ -183,7 +197,7 @@ var payload = new XummPostJsonPayload(
183197

184198
As you can see the payload looks like a regular XRPL transaction, wrapped in an `TxJson` object, omitting the mandatory `Account`, `Fee` and `Sequence` properties. They will be added containing the correct values when the payload is signed by an app user.
185199

186-
Optionally (besides `TxJson`) a payload can contain these properties ([XummPayloadBodyBase definition](https://github.com/XRPL-Labs/XUMM.NET.SDK/blob/main/XUMM.Net/Models/Payload/XummPayloadBodyBase.cs)):
200+
Optionally (besides `TxJson`) a payload can contain these properties ([XummPayloadBodyBase definition](https://github.com/XRPL-Labs/XUMM.NET.SDK/blob/main/src/XUMM.NET.SDK/Models/Payload/XummPayloadBodyBase.cs)):
187201
188202
- `XummPayloadOptions` to define payload options like a return URL, expiration, etc.
189203
- `XummPayloadCustomMeta` to add metadata, user instruction, your own unique ID, ...

src/XUMM.NET.SDK/Clients/Interfaces/IXummXAppJwtClient.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Threading.Tasks;
22
using XUMM.NET.SDK.Models.XAppJwt;
3-
using XUMM.NET.SDK.Models.XAppJWT;
43

54
namespace XUMM.NET.SDK.Clients.Interfaces;
65

@@ -33,4 +32,12 @@ public interface IXummXAppJwtClient
3332
/// <param name="jwt">The JWT obtained by calling the /authorize endpoint first.</param>
3433
/// <param name="key">Key/value store: key (lower case, a-z, 0-9, min. 3 chars)</param>
3534
Task<XummXAppJwtUserDataUpdateResponse> DeleteUserDataAsync(string jwt, string key);
35+
36+
/// <summary>
37+
/// This method allows you to get basic XLS20 token information as fetched/parsed/cached for you by the Xumm backend.
38+
/// Note: it's best to retrieve these results yourself instead of relying on the Xumm platform to get live XRPL transaction information!
39+
/// </summary>
40+
/// <param name="jwt">The JWT obtained by calling the /authorize endpoint first.</param>
41+
/// <param name="tokenId">The NFTokenID.</param>
42+
Task<XummXAppJwtNFTokenDetail> GetNFTokenDetailAsync(string jwt, string tokenId);
3643
}

src/XUMM.NET.SDK/Clients/XummXAppJwtClient.cs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
using System.Threading.Tasks;
33
using XUMM.NET.SDK.Clients.Interfaces;
44
using XUMM.NET.SDK.Models.XAppJwt;
5-
using XUMM.NET.SDK.Models.XAppJWT;
65

76
namespace XUMM.NET.SDK.Clients;
87

98
public class XummXAppJwtClient : IXummXAppJwtClient
109
{
11-
private readonly IXummHttpClient _httpClient;
10+
private readonly IXummHttpClient _xummHttpClient;
1211

1312
/// <summary>
1413
/// Initializes a new instance of the <see cref="XummXAppJwtClient"/> class.
1514
/// </summary>
16-
public XummXAppJwtClient(IXummHttpClient httpClient)
15+
public XummXAppJwtClient(IXummHttpClient xummhttpClient)
1716
{
18-
_httpClient = httpClient;
17+
_xummHttpClient = xummhttpClient;
1918
}
2019

2120
/// <inheritdoc />
@@ -26,35 +25,49 @@ public async Task<XummXAppJwtAuthorizeResponse> AuthorizeAsync(string oneTimeTok
2625
throw new ArgumentException("Value cannot be null or white space", nameof(oneTimeToken));
2726
}
2827

29-
var httpClient = _httpClient.GetHttpClient(true);
28+
var httpClient = _xummHttpClient.GetHttpClient(true);
3029
httpClient.DefaultRequestHeaders.Add("X-API-OTT", oneTimeToken);
31-
return await _httpClient.GetAsync<XummXAppJwtAuthorizeResponse>(httpClient, "xapp-jwt/authorize");
30+
return await _xummHttpClient.GetAsync<XummXAppJwtAuthorizeResponse>(httpClient, "xapp-jwt/authorize");
3231
}
3332

3433
/// <inheritdoc />
3534
public async Task<XummXAppJwtUserDataResponse> GetUserDataAsync(string jwt, string key)
3635
{
37-
var httpClient = _httpClient.GetHttpClient(false);
36+
var httpClient = _xummHttpClient.GetHttpClient(false);
3837
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwt}");
3938

40-
return await _httpClient.GetAsync<XummXAppJwtUserDataResponse>(httpClient, $"xapp-jwt/userdata/{key}");
39+
return await _xummHttpClient.GetAsync<XummXAppJwtUserDataResponse>(httpClient, $"xapp-jwt/userdata/{key}");
4140
}
4241

4342
/// <inheritdoc />
4443
public async Task<XummXAppJwtUserDataUpdateResponse> SetUserDataAsync(string jwt, string key, string json)
4544
{
46-
var httpClient = _httpClient.GetHttpClient(false);
45+
var httpClient = _xummHttpClient.GetHttpClient(false);
4746
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwt}");
4847

49-
return await _httpClient.PostAsync<XummXAppJwtUserDataUpdateResponse>(httpClient, $"xapp-jwt/userdata/{key}", json);
48+
return await _xummHttpClient.PostAsync<XummXAppJwtUserDataUpdateResponse>(httpClient, $"xapp-jwt/userdata/{key}", json);
5049
}
5150

5251
/// <inheritdoc />
5352
public async Task<XummXAppJwtUserDataUpdateResponse> DeleteUserDataAsync(string jwt, string key)
5453
{
55-
var httpClient = _httpClient.GetHttpClient(false);
54+
var httpClient = _xummHttpClient.GetHttpClient(false);
5655
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwt}");
5756

58-
return await _httpClient.DeleteAsync<XummXAppJwtUserDataUpdateResponse>(httpClient, $"xapp-jwt/userdata/{key}");
57+
return await _xummHttpClient.DeleteAsync<XummXAppJwtUserDataUpdateResponse>(httpClient, $"xapp-jwt/userdata/{key}");
58+
}
59+
60+
/// <inheritdoc />
61+
public async Task<XummXAppJwtNFTokenDetail> GetNFTokenDetailAsync(string jwt, string tokenId)
62+
{
63+
if (string.IsNullOrWhiteSpace(tokenId))
64+
{
65+
throw new ArgumentException("Value cannot be null or white space", nameof(tokenId));
66+
}
67+
68+
var httpClient = _xummHttpClient.GetHttpClient(false);
69+
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwt}");
70+
71+
return await _xummHttpClient.GetAsync<XummXAppJwtNFTokenDetail>(httpClient, $"xapp-jwt/nftoken-detail/{tokenId}");
5972
}
6073
}

src/XUMM.NET.SDK/Models/XAppJwt/XummXAppJwtAppResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.Json.Serialization;
22

3-
namespace XUMM.NET.SDK.Models.XAppJWT;
3+
namespace XUMM.NET.SDK.Models.XAppJwt;
44

55
public class XummXAppJwtAppResponse
66
{

src/XUMM.NET.SDK/Models/XAppJwt/XummXAppJwtAuthorizeResponse.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Text.Json.Serialization;
22
using XUMM.NET.SDK.Models.XApp;
3-
using XUMM.NET.SDK.Models.XAppJWT;
43

54
namespace XUMM.NET.SDK.Models.XAppJwt;
65

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace XUMM.NET.SDK.Models.XAppJwt;
4+
5+
public class XummXAppJwtNFTokenDetail
6+
{
7+
[JsonPropertyName("issuer")]
8+
public string? Issuer { get; set; }
9+
10+
[JsonPropertyName("token")]
11+
public string? Token { get; set; }
12+
13+
[JsonPropertyName("owner")]
14+
public string? Owner { get; set; }
15+
16+
[JsonPropertyName("name")]
17+
public string? Name { get; set; }
18+
19+
[JsonPropertyName("image")]
20+
public string? Image { get; set; }
21+
}

src/XUMM.NET.SDK/Models/XAppJwt/XummXAppJwtUserDataResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Text.Json;
33
using System.Text.Json.Serialization;
44

5-
namespace XUMM.NET.SDK.Models.XAppJWT;
5+
namespace XUMM.NET.SDK.Models.XAppJwt;
66

77
public class XummXAppJwtUserDataResponse
88
{

src/XUMM.NET.SDK/Models/XAppJwt/XummXAppJwtUserDataUpdateResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.Json.Serialization;
22

3-
namespace XUMM.NET.SDK.Models.XAppJWT;
3+
namespace XUMM.NET.SDK.Models.XAppJwt;
44

55
public class XummXAppJwtUserDataUpdateResponse
66
{

0 commit comments

Comments
 (0)