diff --git a/GatherContent.Net/GatherContent.Net.csproj b/GatherContent.Net/GatherContent.Net.csproj
index 7fe582b..c43e63b 100644
--- a/GatherContent.Net/GatherContent.Net.csproj
+++ b/GatherContent.Net/GatherContent.Net.csproj
@@ -53,6 +53,9 @@
+
+
+
diff --git a/GatherContent.Net/GatherContentClient.cs b/GatherContent.Net/GatherContentClient.cs
index d081881..a4f9c40 100644
--- a/GatherContent.Net/GatherContentClient.cs
+++ b/GatherContent.Net/GatherContentClient.cs
@@ -14,7 +14,7 @@ public class GatherContentClient
private readonly string _apiKey;
private readonly string _version;
- public GatherContentClient(string accountName, string apiKey, string version = "0.2.1")
+ public GatherContentClient(string accountName, string apiKey, string version = "0.4")
{
_accountName = accountName;
_apiKey = apiKey;
@@ -32,6 +32,18 @@ public async Task GetProjectsAsync()
return await PostAsync("get_projects");
}
+ public PageItem GetPage(string pageID) {
+ return GetPageAsync(pageID).Result;
+ }
+
+ public async Task GetPageAsync(string pageID) {
+ var result = await PostAsync("get_page", new[] { new KeyValuePair("id", pageID) });
+ if (result.page != null) {
+ result.page.SetContents();
+ }
+ return result;
+ }
+
public PageData GetPagesByProject(string projectId)
{
return GetPagesByProjectAsync(projectId).Result;
@@ -39,7 +51,13 @@ public PageData GetPagesByProject(string projectId)
public async Task GetPagesByProjectAsync(string projectId)
{
- return await PostAsync("get_pages_by_project", new[] { new KeyValuePair("id", projectId) });
+ var result = await PostAsync("get_pages_by_project", new[] { new KeyValuePair("id", projectId) });
+ if (result.pages != null) {
+ foreach (var page in result.pages) {
+ page.SetContents();
+ }
+ }
+ return result;
}
public FileData GetFilesByProject(string projectId)
@@ -91,6 +109,5 @@ private async Task PostAsync(string requestUri, IEnumerable
+ /// Base64 page contents
+ ///
+ public string config { get; set; }
+ ///
+ /// Page content
+ ///
+ public PageContent[] contents { get; set; }
+ ///
+ /// Exception when calling
+ ///
+ public Exception contentsException { get; set; }
+
+ ///
+ /// Populates by converted the Base64 content.
+ ///
+ public void SetContents() {
+ if (string.IsNullOrWhiteSpace(this.config)) {
+ this.contents = new PageContent[0];
+ }
+ try {
+ var configData = Convert.FromBase64String(this.config);
+ var configJson = Encoding.UTF8.GetString(configData);
+ this.contents = JsonConvert.DeserializeObject(configJson);
+ } catch (Exception ex) {
+ this.contentsException = ex;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/GatherContent.Net/PageContent.cs b/GatherContent.Net/PageContent.cs
new file mode 100644
index 0000000..791113d
--- /dev/null
+++ b/GatherContent.Net/PageContent.cs
@@ -0,0 +1,23 @@
+namespace GatherContent.Net {
+ ///
+ /// Content tab.
+ ///
+ public class PageContent {
+ ///
+ /// Label for the content tab. Defaults to "Content".
+ ///
+ public string label { get; set; }
+ ///
+ /// Internal tab identifier.
+ ///
+ public string name { get; set; }
+ ///
+ ///
+ ///
+ public bool hidden { get; set; }
+ ///
+ /// Elements containing HTML or text that makeup this tab.
+ ///
+ public PageContentElement[] elements { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/GatherContent.Net/PageContentElements.cs b/GatherContent.Net/PageContentElements.cs
new file mode 100644
index 0000000..0875351
--- /dev/null
+++ b/GatherContent.Net/PageContentElements.cs
@@ -0,0 +1,43 @@
+namespace GatherContent.Net {
+ ///
+ /// Text elements within a content tab.
+ ///
+ public class PageContentElement {
+ ///
+ /// Element type, such as "text".
+ ///
+ public string type { get; set; }
+ ///
+ /// Internal element identifier.
+ ///
+ public string name { get; set; }
+ ///
+ ///
+ ///
+ public bool required { get; set; }
+ ///
+ /// User declared content label.
+ ///
+ public string label { get; set; }
+ ///
+ /// Content HTML or text.
+ ///
+ public string value { get; set; }
+ ///
+ ///
+ ///
+ public string microcopy { get; set; }
+ ///
+ /// How the content is limited, such as "words".
+ ///
+ public string limit_type { get; set; }
+ ///
+ /// Numeric limit of the content. Defaults to "0".
+ ///
+ public string limit { get; set; }
+ ///
+ /// True if does not contain HTML.
+ ///
+ public bool plain_text { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/GatherContent.Net/PageItem.cs b/GatherContent.Net/PageItem.cs
new file mode 100644
index 0000000..dea8cba
--- /dev/null
+++ b/GatherContent.Net/PageItem.cs
@@ -0,0 +1,6 @@
+namespace GatherContent.Net {
+ public class PageItem {
+ public bool success { get; set; }
+ public Page page { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/GatherContent.Net/Properties/AssemblyInfo.cs b/GatherContent.Net/Properties/AssemblyInfo.cs
index 1a6e2c4..02459c6 100644
--- a/GatherContent.Net/Properties/AssemblyInfo.cs
+++ b/GatherContent.Net/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -32,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.2.0.0")]
-[assembly: AssemblyFileVersion("0.2.0.0")]
+[assembly: AssemblyVersion("0.3.0.0")]
+[assembly: AssemblyFileVersion("0.3.0.0")]
diff --git a/README.md b/README.md
index 861b359..00b986b 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,8 @@ Currently you can:
Get a list of projects for your API Key
Pages
Get the pages for a given project
+ Page
+ Get a single page
Files
Get the files for a given project and download them