-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
349 additions
and
66 deletions.
There are no files selected for viewing
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 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 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 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 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 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 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 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
64 changes: 64 additions & 0 deletions
64
src/Umbraco.Cms.Integrations.Commerce.Shopify/Helpers/HttpResponseHelper.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Web; | ||
|
||
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Helpers | ||
{ | ||
public static class HttpResponseHelper | ||
{ | ||
/// <summary> | ||
/// Retrieve Shopify page_info query string parameters used for pagination from forward/backwards operations. | ||
/// </summary> | ||
/// <param name="response"></param> | ||
/// <returns></returns> | ||
public static Tuple<string, string> GetPageInfo(this HttpResponseMessage response) | ||
{ | ||
string previousPageInfo = string.Empty; | ||
string nextPageInfo = string.Empty; | ||
|
||
if (!response.Headers.Contains("Link")) | ||
{ | ||
return default; | ||
} | ||
|
||
var linkHeader = response.Headers.GetValues("Link").FirstOrDefault(); | ||
if (linkHeader != null && linkHeader.Contains("rel")) | ||
{ | ||
if (linkHeader.Contains("previous") && linkHeader.Contains("next")) | ||
{ | ||
var relArr = linkHeader.Split(','); | ||
foreach (var item in relArr) | ||
{ | ||
var link = item.Split(';'); | ||
var servicePageInfo = HttpUtility.ParseQueryString(link[0].Replace("<", string.Empty).Replace(">", string.Empty)).Get("page_info"); | ||
if (link[1].Contains("previous")) | ||
{ | ||
previousPageInfo = servicePageInfo; | ||
} | ||
else if (link[1].Contains("next")) | ||
{ | ||
nextPageInfo = servicePageInfo; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
var link = linkHeader.Split(';'); | ||
var servicePageInfo = HttpUtility.ParseQueryString(link[0].Replace("<", string.Empty).Replace(">", string.Empty)).Get("page_info"); | ||
if (link[1].Contains("previous")) | ||
{ | ||
previousPageInfo = servicePageInfo; | ||
} | ||
else if (link[1].Contains("next")) | ||
{ | ||
nextPageInfo = servicePageInfo; | ||
} | ||
} | ||
|
||
} | ||
|
||
return new Tuple<string, string>(previousPageInfo, nextPageInfo); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Umbraco.Cms.Integrations.Commerce.Shopify/Models/Dtos/RequestDto.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Models.Dtos | ||
{ | ||
public class RequestDto | ||
{ | ||
[JsonProperty("ids")] | ||
public string[] Ids { 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
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
Oops, something went wrong.