Adding inventory microservice
Deploy Promiscuity Auth API / deploy (push) Successful in 46s
Deploy Promiscuity Character API / deploy (push) Successful in 46s
Deploy Promiscuity Locations API / deploy (push) Successful in 46s
k8s smoke test / test (push) Successful in 7s

This commit is contained in:
2026-03-15 10:21:49 -05:00
parent 9809869cbe
commit 9a7d6544ef
27 changed files with 1483 additions and 7 deletions
@@ -0,0 +1,6 @@
namespace InventoryApi.Models;
public class ConsumeInventoryItemRequest
{
public int Quantity { get; set; } = 1;
}
@@ -0,0 +1,8 @@
namespace InventoryApi.Models;
public class EquipInventoryItemRequest
{
public string OwnerId { get; set; } = string.Empty;
public string EquipmentSlot { get; set; } = string.Empty;
}
@@ -0,0 +1,10 @@
namespace InventoryApi.Models;
public class GrantInventoryItemRequest
{
public string ItemKey { get; set; } = string.Empty;
public int Quantity { get; set; } = 1;
public int? PreferredSlot { get; set; }
}
@@ -0,0 +1,38 @@
using MongoDB.Bson.Serialization.Attributes;
namespace InventoryApi.Models;
public class InventoryItem
{
[BsonId]
public string Id { get; set; } = Guid.NewGuid().ToString();
[BsonElement("itemKey")]
public string ItemKey { get; set; } = string.Empty;
[BsonElement("quantity")]
public int Quantity { get; set; } = 1;
[BsonElement("ownerType")]
public string OwnerType { get; set; } = string.Empty;
[BsonElement("ownerId")]
public string OwnerId { get; set; } = string.Empty;
[BsonElement("ownerUserId")]
public string? OwnerUserId { get; set; }
[BsonElement("slot")]
[BsonIgnoreIfNull]
public int? Slot { get; set; }
[BsonElement("equippedSlot")]
[BsonIgnoreIfNull]
public string? EquippedSlot { get; set; }
[BsonElement("createdUtc")]
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
[BsonElement("updatedUtc")]
public DateTime UpdatedUtc { get; set; } = DateTime.UtcNow;
}
@@ -0,0 +1,32 @@
namespace InventoryApi.Models;
public class InventoryItemResponse
{
public string Id { get; set; } = string.Empty;
public string ItemKey { get; set; } = string.Empty;
public int Quantity { get; set; }
public string OwnerType { get; set; } = string.Empty;
public string OwnerId { get; set; } = string.Empty;
public int? Slot { get; set; }
public string? EquippedSlot { get; set; }
public DateTime UpdatedUtc { get; set; }
public static InventoryItemResponse FromModel(InventoryItem item) => new()
{
Id = item.Id,
ItemKey = item.ItemKey,
Quantity = item.Quantity,
OwnerType = item.OwnerType,
OwnerId = item.OwnerId,
Slot = item.Slot,
EquippedSlot = item.EquippedSlot,
UpdatedUtc = item.UpdatedUtc
};
}
@@ -0,0 +1,22 @@
namespace InventoryApi.Models;
public enum InventoryMutationStatus
{
Ok,
ItemNotFound,
Invalid,
Conflict
}
public class InventoryMutationResult
{
public InventoryMutationStatus Status { get; init; } = InventoryMutationStatus.Ok;
public string OwnerType { get; init; } = string.Empty;
public string OwnerId { get; init; } = string.Empty;
public List<InventoryItem> Items { get; init; } = [];
public static implicit operator InventoryMutationStatus(InventoryMutationResult result) => result.Status;
}
@@ -0,0 +1,10 @@
namespace InventoryApi.Models;
public class InventoryOwnerResponse
{
public string OwnerType { get; set; } = string.Empty;
public string OwnerId { get; set; } = string.Empty;
public List<InventoryItemResponse> Items { get; set; } = [];
}
@@ -0,0 +1,10 @@
namespace InventoryApi.Models;
public class MoveInventoryItemRequest
{
public string ItemId { get; set; } = string.Empty;
public int ToSlot { get; set; }
public int? Quantity { get; set; }
}
@@ -0,0 +1,16 @@
namespace InventoryApi.Models;
public class OwnerAccessResult
{
public bool IsSupported { get; init; }
public bool Exists { get; init; }
public bool IsAuthorized { get; init; }
public string OwnerType { get; init; } = string.Empty;
public string OwnerId { get; init; } = string.Empty;
public string? OwnerUserId { get; init; }
}
@@ -0,0 +1,18 @@
namespace InventoryApi.Models;
public class TransferInventoryItemRequest
{
public string ItemId { get; set; } = string.Empty;
public string FromOwnerType { get; set; } = string.Empty;
public string FromOwnerId { get; set; } = string.Empty;
public string ToOwnerType { get; set; } = string.Empty;
public string ToOwnerId { get; set; } = string.Empty;
public int? ToSlot { get; set; }
public int? Quantity { get; set; }
}
@@ -0,0 +1,18 @@
namespace InventoryApi.Models;
public class TransferInventoryResponse
{
public string MovedItemId { get; set; } = string.Empty;
public string FromOwnerType { get; set; } = string.Empty;
public string FromOwnerId { get; set; } = string.Empty;
public string ToOwnerType { get; set; } = string.Empty;
public string ToOwnerId { get; set; } = string.Empty;
public List<InventoryItemResponse> FromItems { get; set; } = [];
public List<InventoryItemResponse> ToItems { get; set; } = [];
}
@@ -0,0 +1,8 @@
namespace InventoryApi.Models;
public class UnequipInventoryItemRequest
{
public string OwnerId { get; set; } = string.Empty;
public int? PreferredSlot { get; set; }
}