Skip to content

Commit

Permalink
Merge pull request #134 from Archomeda/feature/recipes-eod-update
Browse files Browse the repository at this point in the history
Update recipes to schema 2022-03-09T02:00:00.000Z
  • Loading branch information
Archomeda authored Mar 12, 2023
2 parents 2630f13 + d340871 commit 3e2fa01
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 23 deletions.
74 changes: 60 additions & 14 deletions Gw2Sharp.Tests/TestFiles/Recipes/Recipes.bulk.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
],
"ingredients": [
{
"item_id": 73537,
"type": "Item",
"id": 73537,
"count": 5
}
],
Expand All @@ -34,59 +35,104 @@
],
"ingredients": [
{
"item_id": 46699,
"type": "Item",
"id": 46699,
"count": 1
},
{
"item_id": 45883,
"type": "Item",
"id": 45883,
"count": 1
},
{
"item_id": 45884,
"type": "Item",
"id": 45884,
"count": 1
},
{
"item_id": 46746,
"type": "Item",
"id": 46746,
"count": 1
}
],
"id": 7382,
"chat_link": "[&CdYcAAA=]"
},
{
"id": 13132,
"type": "GuildDecoration",
"output_item_id": 90083,
"output_item_count": 1,
"min_rating": 200,
"time_to_craft_ms": 1000,
"disciplines": [
"Scribe"
],
"min_rating": 200,
"flags": [
"AutoLearned"
],
"ingredients": [
{
"item_id": 70926,
"type": "Item",
"id": 70926,
"count": 1
},
{
"item_id": 70426,
"type": "Item",
"id": 70426,
"count": 4
},
{
"item_id": 75862,
"type": "Item",
"id": 75862,
"count": 4
}
],
"guild_ingredients": [
},
{
"upgrade_id": 721,
"type": "GuildUpgrade",
"id": 721,
"count": 8
}
],
"output_upgrade_id": 1028,
"id": 13132,
"chat_link": "[&CUwzAAA=]"
},
{
"id": 13598,
"type": "Insignia",
"output_item_id": 96315,
"output_item_count": 1,
"time_to_craft_ms": 1000,
"disciplines": [
"Leatherworker",
"Armorsmith",
"Tailor"
],
"min_rating": 400,
"flags": [
"LearnedFromItem"
],
"ingredients": [
{
"type": "Item",
"id": 96471,
"count": 10
},
{
"type": "Item",
"id": 19721,
"count": 5
},
{
"type": "Item",
"id": 76614,
"count": 5
},
{
"type": "Currency",
"id": 61,
"count": 150
}
],
"chat_link": "[&CR41AAA=]"
}
]
12 changes: 8 additions & 4 deletions Gw2Sharp.Tests/TestFiles/Recipes/Recipes.single.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@
],
"ingredients": [
{
"item_id": 75939,
"type": "Item",
"id": 75939,
"count": 1
},
{
"item_id": 74218,
"type": "Item",
"id": 74218,
"count": 1
},
{
"item_id": 76402,
"type": "Item",
"id": 76402,
"count": 1
},
{
"item_id": 72261,
"type": "Item",
"id": 72261,
"count": 1
}
],
Expand Down
1 change: 1 addition & 0 deletions Gw2Sharp/WebApi/V2/Clients/Recipes/RecipesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Gw2Sharp.WebApi.V2.Clients
/// A client of the Guild Wars 2 API v2 recipes endpoint.
/// </summary>
[EndpointPath("recipes")]
[EndpointSchemaVersion("2022-03-09T02:00:00.000Z")]
public class RecipesClient : BaseEndpointBulkClient<Recipe, int>, IRecipesClient
{
private readonly IRecipesSearchClient search;
Expand Down
10 changes: 9 additions & 1 deletion Gw2Sharp/WebApi/V2/Models/Recipes/Recipe.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Gw2Sharp.WebApi.V2.Clients;

namespace Gw2Sharp.WebApi.V2.Models
Expand Down Expand Up @@ -63,8 +64,15 @@ public class Recipe : ApiV2BaseObject, IIdentifiable<int>
/// <summary>
/// The recipe ingredients from the guild.
/// If the recipe doesn't require any guild ingredients, this value is <see langword="null"/>.
/// <para/>
/// This property has been moved into <see cref="Ingredients"/> started with schema version 2022-03.09T02:00:00.000Z.
/// Gw2Sharp v1.x has roll-forward support, but this will be removed starting with v2.0.
/// </summary>
public IReadOnlyList<RecipeGuildIngredient>? GuildIngredients { get; set; }
[Obsolete("Deprecated since schema version 2022-03-09T02:00:00.000Z. Use Ingredients and filter by Guild type instead. This will be removed from Gw2Sharp starting from version 2.0.")]
public IReadOnlyList<RecipeGuildIngredient>? GuildIngredients => this.Ingredients
.Where(x => x.Type.Value == RecipeIngredientType.GuildUpgrade)
.Select(x => new RecipeGuildIngredient { UpgradeId = x.Id, Count = x.Count })
.ToList();

/// <summary>
/// The output guild upgrade id.
Expand Down
2 changes: 2 additions & 0 deletions Gw2Sharp/WebApi/V2/Models/Recipes/RecipeGuildIngredient.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using Gw2Sharp.WebApi.V2.Clients;

namespace Gw2Sharp.WebApi.V2.Models
{
/// <summary>
/// Represents a recipe ingredient from the guild.
/// </summary>
[Obsolete("Deprecated since 2021-09-28. Use RecipeIngredient instead. This will be removed from Gw2Sharp starting from version 2.0.")]
public class RecipeGuildIngredient
{
/// <summary>
Expand Down
29 changes: 25 additions & 4 deletions Gw2Sharp/WebApi/V2/Models/Recipes/RecipeIngredient.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
using System;
using Gw2Sharp.WebApi.V2.Clients;

namespace Gw2Sharp.WebApi.V2.Models
{
/// <summary>
/// Represents a recipe ingredient.
/// </summary>
public class RecipeIngredient
{
/// <inheritdoc cref="Id"/>
[Obsolete("Deprecated since schema version 2022-03-09T02:00:00.000Z. Use Id instead. This will be removed from Gw2Sharp starting from version 2.0.")]
public int ItemId
{
get => this.Id;
set => this.Id = value;
}

/// <summary>
/// The item id.
/// Can be resolved against <see cref="IGw2WebApiV2Client.Items"/>.
/// The ingredient id.
/// Can be resolved against:
/// <list type="bullet">
/// <item><see cref="IGw2WebApiV2Client.Items"/> when <see cref="Type"/> is <see cref="RecipeIngredientType.Item"/></item>
/// <item><see cref="IGuildClient.Upgrades"/> when <see cref="Type"/> is <see cref="RecipeIngredientType.GuildUpgrade"/></item>
/// <item><see cref="IGw2WebApiV2Client.Currencies"/> when <see cref="Type"/> is <see cref="RecipeIngredientType.Currency"/></item>
/// </list>
/// </summary>
public int ItemId { get; set; }
public int Id { get; set; }

/// <summary>
/// The number of items.
/// The ingredient count.
/// </summary>
public int Count { get; set; }

/// <summary>
/// The ingredient type.
/// </summary>
public ApiEnum<RecipeIngredientType> Type { get; set; } = new();
}
}
28 changes: 28 additions & 0 deletions Gw2Sharp/WebApi/V2/Models/Recipes/RecipeIngredientType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Gw2Sharp.WebApi.V2.Models
{
/// <summary>
/// A recipe ingredient type.
/// </summary>
public enum RecipeIngredientType
{
/// <summary>
/// Unknown recipe ingredient type.
/// </summary>
Unknown,

/// <summary>
/// Item ingredient type.
/// </summary>
Item,

/// <summary>
/// Guild upgrade ingredient type.
/// </summary>
GuildUpgrade,

/// <summary>
/// Currency ingredient type.
/// </summary>
Currency
}
}

0 comments on commit 3e2fa01

Please sign in to comment.