Skip to content

Commit

Permalink
Merge branch 'v2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacrys committed Dec 12, 2024
2 parents 36f521d + be88a85 commit 2ae5605
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 1 deletion.
65 changes: 65 additions & 0 deletions ResumeSharpLib/Models/JsonJob.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using NodaTime;
using NodaTime.Serialization.JsonNet;

namespace ResumeSharpLib
{

/// <summary>
/// The JsonJob object based on https://jsonresume.org/job-description-schema/
/// </summary>
public partial class JsonJob
{
[JsonProperty("title")]
public string Title { get; set; }

[JsonProperty("company")]
public string Company { get; set; }

[JsonProperty("type")]
public string Type { get; set; }

[JsonProperty("date")]
public OffsetDateTime Date { get; set; }

[JsonProperty("description")]
public string Description { get; set; }

[JsonProperty("location")]
public string Location { get; set; }

[JsonProperty("remote")]
public string Remote { get; set; }

[JsonProperty("salary")]
public string Salary { get; set; }

[JsonProperty("experience")]
public string Experience { get; set; }

[JsonProperty("responsibilities")]
public List<string> Responsibilities { get; set; }

[JsonProperty("qualification")]
public List<string> Qualifications { get; set; }

[JsonProperty("skills")]
public List<Skill> Skills { get; set; }

}


public partial class JsonJob
{
/// <summary>
/// Create a JsonResume object from json string
/// </summary>
/// <param name="json">the json string</param>
/// <returns></returns>
public static JsonJob FromJson(string json) => JsonConvert.DeserializeObject<JsonJob>(json, Converter.Settings);
}
}
34 changes: 34 additions & 0 deletions ResumeSharpLib/Utils/Extensions/JsonJobExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;
using ResumeSharpLib.Utils;

namespace ResumeSharpLib.Utils.Extensions
{
public static class JsonJobExtensions
{
/// <summary>
/// Adds a skill item to the job object
/// </summary>
/// <param name="jsonJob">the job object</param>
/// <param name="skill">the skill item</param>
/// <returns></returns>
public static JsonJob AddSkill(this JsonJob jsonJob, Skill skill)
{
Utilities.AddItemToList(jsonJob.Skills, skill);
return jsonJob;
}

public static JsonJob AddQualification(this JsonJob jsonJob, string qualification)
{
Utilities.AddItemToList(jsonJob.Qualifications, qualification);
return jsonJob;
}

public static JsonJob AddResponsibility(this JsonJob jsonJob, string responsibility)
{
Utilities.AddItemToList(jsonJob.Responsibilities, responsibility);
return jsonJob;
}
}
}
13 changes: 12 additions & 1 deletion ResumeSharpTests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public void AddJsonResumeTest()
Assert.AreEqual(jsonResume.Projects.Count, 1);
}


[TestMethod]
public void AddJsonJobTest()
{
JsonJob jsonJob = new JsonJob();
jsonJob.AddSkill(new Skill())
.AddQualification("")
.AddResponsibility("");

Assert.AreEqual(jsonJob.Skills.Count, 1);
Assert.AreEqual(jsonJob.Qualifications.Count, 1);
Assert.AreEqual(jsonJob.Responsibilities.Count, 1);
}
}
}

0 comments on commit 2ae5605

Please sign in to comment.