-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/websocket enhancements (#20)
* Initial WebSocket re-implementation * Removed unused models. * Resolved comments on pull request. * Replaced .HasValue with != null for deserialized Result check. * Updated documentation for WebSockets.
- Loading branch information
1 parent
66d80d8
commit d2cf5c3
Showing
9 changed files
with
347 additions
and
430 deletions.
There are no files selected for viewing
283 changes: 91 additions & 192 deletions
283
Fortnox.NET.Tests/Fortnox.NET.Tests/WebSocket/FortnoxWebSocketClientTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Fortnox.NET/WebSockets/WebSocketCommands.cs → ...ET/WebSockets/Models/WebSocketCommands.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
This file was deleted.
Oops, something went wrong.
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,76 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Fortnox.NET.WebSockets.Models | ||
{ | ||
public enum WebSocketEventType | ||
{ | ||
[EnumMember(Value = "invoice-created-v1")] | ||
InvoiceCreated, | ||
[EnumMember(Value = "invoice-updated-v1")] | ||
InvoiceUpdated, | ||
[EnumMember(Value = "invoice-cancelled-v1")] | ||
InvoiceCancelled, | ||
[EnumMember(Value = "invoicepayment-bookkeep-v1")] | ||
InvoicePaymentBookkeep, | ||
[EnumMember(Value = "invoicepayment-deleted-v1")] | ||
InvoicePaymentDeleted, | ||
[EnumMember(Value = "reminder-sent-v1")] | ||
ReminderSentV1, | ||
[EnumMember(Value = "reminder-sent-v2")] | ||
ReminderSent, | ||
|
||
[EnumMember(Value = "customer-created-v1")] | ||
CustomerCreated, | ||
[EnumMember(Value = "customer-updated-v1")] | ||
CustomerUpdated, | ||
[EnumMember(Value = "customer-deleted-v1")] | ||
CustomerDeleted, | ||
|
||
[EnumMember(Value = "order-created-v1")] | ||
OrderCreated, | ||
[EnumMember(Value = "order-updated-v1")] | ||
OrderUpdated, | ||
[EnumMember(Value = "order-cancelled-v1")] | ||
OrderCancelled, | ||
|
||
[EnumMember(Value = "offer-created-v1")] | ||
OfferCreated, | ||
[EnumMember(Value = "offer-updated-v1")] | ||
OfferUpdated, | ||
|
||
[EnumMember(Value = "article-created-v1")] | ||
ArticleCreated, | ||
[EnumMember(Value = "article-updated-v1")] | ||
ArticleUpdated, | ||
[EnumMember(Value = "article-deleted-v1")] | ||
ArticleDeleted, | ||
|
||
[EnumMember(Value = "currency-created-v1")] | ||
CurrencyCreated, | ||
[EnumMember(Value = "currency-updated-v1")] | ||
CurrencyUpdated, | ||
[EnumMember(Value = "currency-deleted-v1")] | ||
CurrencyDeleted, | ||
|
||
[EnumMember(Value = "termofdelivery-created-v1")] | ||
TermOfDeliveryCreated, | ||
[EnumMember(Value = "termofdelivery-updated-v1")] | ||
TermOfDeliveryUpdated, | ||
[EnumMember(Value = "termofdelivery-deleted-v1")] | ||
TermOfDeliveryDeleted, | ||
|
||
[EnumMember(Value = "wayofdelivery-created-v1")] | ||
WayOfDeliveryCreated, | ||
[EnumMember(Value = "wayofdelivery-updated-v1")] | ||
WayOfDeliveryUpdated, | ||
[EnumMember(Value = "wayofdelivery-deleted-v1")] | ||
WayOfDeliveryDeleted, | ||
|
||
[EnumMember(Value = "termsofpayments-created-v1")] | ||
TermsOfPaymentsCreated, | ||
[EnumMember(Value = "termsofpayments-updated-v1")] | ||
TermsOfPaymentsUpdated, | ||
[EnumMember(Value = "termsofpayments-deleted-v1")] | ||
TermsOfPaymentDeleted, | ||
} | ||
} |
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,54 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Fortnox.NET.WebSockets.Models | ||
{ | ||
public enum WebSocketResponseType | ||
{ | ||
CommandResponse = 0, | ||
EventResponse = 1, | ||
} | ||
|
||
public class WebSocketResponse | ||
{ | ||
[JsonIgnore] | ||
public WebSocketResponseType Type; | ||
|
||
[JsonProperty(PropertyName = "response")] | ||
public string Response { get; set; } | ||
|
||
[JsonProperty(PropertyName = "result")] | ||
public string Result { get; set; } | ||
|
||
[JsonProperty(PropertyName = "tenantIds")] | ||
public Dictionary<string, long> TenantIDs { get; set; } | ||
|
||
[JsonProperty(PropertyName = "invalidTokens")] | ||
public List<string> InvalidTokens { get; set; } | ||
|
||
[JsonProperty(PropertyName = "invalidTopics")] | ||
public List<string> InvalidTopics { get; set; } | ||
|
||
[JsonProperty(PropertyName = "offset")] | ||
public string Offset { get; set; } | ||
|
||
[JsonProperty(PropertyName = "tenantId")] | ||
public long? TenantId { get; set; } | ||
|
||
[JsonProperty(PropertyName = "topic")] | ||
public string Topic { get; set; } | ||
|
||
[JsonProperty(PropertyName = "entityId")] | ||
public string EntityId { get; set; } | ||
|
||
[JsonProperty(PropertyName = "type")] | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public WebSocketEventType EventType { get; set; } | ||
|
||
[JsonProperty(PropertyName = "timestamp")] | ||
public DateTime Timestamp { 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