-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from ButterCMS/feature/api-changes
feat: Update due to API changes
- Loading branch information
Showing
8 changed files
with
119 additions
and
6 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
6 changes: 4 additions & 2 deletions
6
ButterCMS/Models/PostStatusEnum.cs → ButterCMS/Models/StatusEnum.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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
namespace ButterCMS.Models | ||
{ | ||
public enum PostStatusEnum | ||
public enum StatusEnum | ||
{ | ||
Unknown = 0, | ||
Draft = 1, | ||
Published = 2 | ||
Published = 2, | ||
Scheduled = 3 | ||
} | ||
} | ||
|
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.Collections.Generic; | ||
using ButterCMS; | ||
using ButterCMS.Models; | ||
using Newtonsoft.Json; | ||
|
||
public class PageFields | ||
{ | ||
[JsonProperty("title")] | ||
public string Title { get; set; } | ||
|
||
[JsonProperty("description")] | ||
public string Description { get; set; } | ||
} | ||
|
||
|
||
namespace ButterCMSDemo | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var apiKey = Environment.GetEnvironmentVariable("API_KEY"); | ||
if (string.IsNullOrEmpty(apiKey)) | ||
{ | ||
Console.WriteLine("API_KEY environment variable is not set"); | ||
return; | ||
} | ||
|
||
var client = new ButterCMSClient(apiKey); | ||
|
||
try | ||
{ | ||
Dictionary<string, string> parameters = new Dictionary<string, string>(); | ||
parameters.Add("preview", "1"); | ||
|
||
var pageResponse = client.RetrievePage<PageFields>("*", "test-page-1", parameters); | ||
var page = pageResponse.Data; | ||
Console.WriteLine("Page retrieved successfully"); | ||
Console.WriteLine($"Page Slug: {page.Slug}"); | ||
Console.WriteLine($"Page Status: {page.Status}"); | ||
Console.WriteLine($"Page Scheduled: {page.Scheduled}"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine($"Error fetching page: {ex.Message}"); | ||
} | ||
|
||
try | ||
{ | ||
var postResponse = client.RetrievePost("test-blog-post"); | ||
var post = postResponse.Data; | ||
Console.WriteLine("Post retrieved successfully"); | ||
Console.WriteLine($"Post Slug: {post.Slug}"); | ||
Console.WriteLine($"Post Status: {post.Status}"); | ||
Console.WriteLine($"Post Scheduled: {post.Scheduled}"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine($"Error fetching post: {ex.Message}"); | ||
} | ||
} | ||
} | ||
} |
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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="../ButterCMS/ButterCMS.csproj" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
</ItemGroup> | ||
</Project> |
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,24 @@ | ||
# Stage 1: Build C# SDK and Demo | ||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | ||
|
||
WORKDIR /src | ||
|
||
# Copy the library | ||
COPY ButterCMS/ ./ButterCMS/ | ||
|
||
# Copy the demo app | ||
COPY Demo/ ./Demo/ | ||
|
||
WORKDIR /src/Demo | ||
RUN dotnet restore | ||
RUN dotnet publish -c Release -o /app/out | ||
|
||
# Stage 2: Run the Demo | ||
FROM mcr.microsoft.com/dotnet/runtime:6.0 | ||
WORKDIR /app | ||
COPY --from=build /app/out . | ||
|
||
ENV API_KEY=your_api_key | ||
ENV API_BASE_URL=https://api.buttercms.com/ | ||
|
||
CMD ["dotnet", "buttercms-demo.dll"] |
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