Skip to content

Commit

Permalink
chore: add various todo comments for future maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
nozzlegear committed Jan 17, 2024
1 parent aa24753 commit c27740f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ShopifySharp.Tests/ShopifyException_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using JetBrains.Annotations;
using ShopifySharp.Filters;
using ShopifySharp.Infrastructure;
using ShopifySharp.Lists;
Expand All @@ -13,6 +14,7 @@
namespace ShopifySharp.Tests
{
[Trait("Category", "ShopifyException"), Trait("Category", "DotNetFramework"), Collection("DotNetFramework tests")]
[TestSubject(typeof(ShopifyException)), TestSubject(typeof(ShopifyRateLimitException))]
public class ShopifyException_Tests
{
private HttpRequestMessage PrepareRequest(HttpMethod method, string path, HttpContent content = null)
Expand Down Expand Up @@ -286,6 +288,8 @@ public async Task Does_Not_Reach_Rate_Limit_With_Smart_Retry_Policy()
[Fact]
public async Task Catches_Rate_Limit()
{
// TODO: refactor this to use Dependency Injection and fake the rate limit response

int requestCount = 60;
var service = new OrderService(Utils.MyShopifyUrl, Utils.AccessToken);
ShopifyRateLimitException ex = null;
Expand Down Expand Up @@ -316,6 +320,8 @@ public async Task Catches_Rate_Limit()
[Fact]
public async Task Catches_Rate_Limit_With_Base_Exception()
{
// TODO: refactor this to use Dependency Injection and fake the rate limit response

int requestCount = 60;
var service = new OrderService(Utils.MyShopifyUrl, Utils.AccessToken);
ShopifyException ex = null;
Expand Down
1 change: 1 addition & 0 deletions ShopifySharp/Lists/LinkHeaderParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private static PagingLink<T> GetPageInfoParam<T>(string linkHeaderValue, Regex l

string matchedUrl = match.Groups[1].Value;

// TODO: refactor this to use the domain utility?
if (!Uri.TryCreate(matchedUrl, UriKind.Absolute, out var uri))
{
throw new ShopifyException($"Cannot parse page link url: '{matchedUrl}'");
Expand Down
1 change: 1 addition & 0 deletions ShopifySharp/Services/Multipass/MultipassService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ string multipassSecret

private static string ValidateShopifyUrl(string shopifyUrl)
{
// TODO: refactor this to use the domain utility
if (Uri.IsWellFormedUriString(shopifyUrl, UriKind.Absolute) == false)
{
//Shopify typically returns the shop URL without a scheme. If the user is storing that as-is, the uri will not be well formed.
Expand Down
4 changes: 4 additions & 0 deletions ShopifySharp/Services/ShopifyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ protected async Task<ListResult<T>> ExecuteGetListAsync<T>(
/// <param name="rawResponse">The response body returned by Shopify.</param>
public static void CheckResponseExceptions(HttpResponseMessage response, string rawResponse)
{
// TODO: make this method protected virtual so inheriting members can override it (e.g. the PartnerService which is doing its own custom error checking right now)

var statusCode = (int)response.StatusCode;

// No error if response was between 200 and 300.
Expand Down Expand Up @@ -410,6 +412,7 @@ public static void CheckResponseExceptions(HttpResponseMessage response, string

var contentType = response.Content.Headers.GetValues("Content-Type").FirstOrDefault();

// TODO: there's probably a better way to check if the content type is json
if (contentType.StartsWithIgnoreCase("application/json") || contentType.StartsWithIgnoreCase("text/json"))
{
IEnumerable<string> errors;
Expand Down Expand Up @@ -461,6 +464,7 @@ public static void CheckResponseExceptions(HttpResponseMessage response, string
/// </summary>
public static bool TryParseErrorJson(string json, out List<string> output)
{
// TODO: obsolete and replace this with a json error parsing util?
output = null;

if (string.IsNullOrEmpty(json))
Expand Down

0 comments on commit c27740f

Please sign in to comment.