Skip to content

Commit

Permalink
Add AcceptHeaders helper class to efine the ProtectedBranch preview A…
Browse files Browse the repository at this point in the history
…PI header in one place, change calls to use this
  • Loading branch information
ryangribble committed Dec 19, 2015
1 parent a54a67b commit 8bb5d3c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Octokit/Clients/RepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ public Task<Branch> EditBranch(string owner, string name, string branch, BranchU
Ensure.ArgumentNotNullOrEmptyString(branch, "branchName");
Ensure.ArgumentNotNull(update, "update");

const string previewAcceptsHeader = "application/vnd.github.loki-preview+json";
return ApiConnection.Patch<Branch>(ApiUrls.RepoBranch(owner, name, branch), update, previewAcceptsHeader);
return ApiConnection.Patch<Branch>(ApiUrls.RepoBranch(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview);
}

/// <summary>
Expand Down Expand Up @@ -408,8 +407,7 @@ public Task<IReadOnlyList<Branch>> GetAllBranches(string owner, string name)
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

const string previewAcceptsHeader = "application/vnd.github.loki-preview+json";
return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(owner, name), null, previewAcceptsHeader);
return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(owner, name), null, AcceptHeaders.ProtectedBranchesApiPreview);
}


Expand Down Expand Up @@ -521,8 +519,7 @@ public Task<Branch> GetBranch(string owner, string repositoryName, string branch
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
Ensure.ArgumentNotNullOrEmptyString(branchName, "branchName");

const string previewAcceptsHeader = "application/vnd.github.loki-preview+json";
return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(owner, repositoryName, branchName), null, previewAcceptsHeader);
return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(owner, repositoryName, branchName), null, AcceptHeaders.ProtectedBranchesApiPreview);
}
}
}
8 changes: 8 additions & 0 deletions Octokit/Helpers/AcceptHeaders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Octokit
{
public static class AcceptHeaders
{
public const string ProtectedBranchesApiPreview = "application/vnd.github.loki-preview+json";
}
}

1 change: 1 addition & 0 deletions Octokit/Octokit-Mono.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<Compile Include="Clients\IAssigneesClient.cs" />
<Compile Include="Clients\IIssuesClient.cs" />
<Compile Include="Clients\IMilestonesClient.cs" />
<Compile Include="Helpers\AcceptHeaders.cs" />
<Compile Include="Helpers\ParameterAttribute.cs" />
<Compile Include="Helpers\ReflectionExtensions.cs" />
<Compile Include="Models\Request\BranchUpdate.cs" />
Expand Down
1 change: 1 addition & 0 deletions Octokit/Octokit-Portable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<Compile Include="Exceptions\NotFoundException.cs" />
<Compile Include="Exceptions\TwoFactorChallengeFailedException.cs" />
<Compile Include="Exceptions\TwoFactorRequiredException.cs" />
<Compile Include="Helpers\AcceptHeaders.cs" />
<Compile Include="Helpers\ApiExtensions.cs" />
<Compile Include="Helpers\ApiUrls.cs" />
<Compile Include="Helpers\AuthorizationExtensions.cs" />
Expand Down
1 change: 1 addition & 0 deletions Octokit/Octokit-netcore45.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<Compile Include="Helpers\IReadOnlyPagedCollection.cs" />
<Compile Include="Helpers\ModelExtensions.cs" />
<Compile Include="Helpers\ParameterAttribute.cs" />
<Compile Include="Helpers\AcceptHeaders.cs" />
<Compile Include="Helpers\ReflectionExtensions.cs" />
<Compile Include="Helpers\TwoFactorChallengeResult.cs" />
<Compile Include="Helpers\UriExtensions.cs" />
Expand Down
1 change: 1 addition & 0 deletions Octokit/Octokit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<Compile Include="Exceptions\RepositoryFormatException.cs" />
<Compile Include="Exceptions\RepositoryWebHookConfigException.cs" />
<Compile Include="Exceptions\TwoFactorAuthorizationException.cs" />
<Compile Include="Helpers\AcceptHeaders.cs" />
<Compile Include="Helpers\ApiErrorExtensions.cs" />
<Compile Include="Helpers\ApiUrls.Authorizations.cs" />
<Compile Include="Helpers\ApiUrls.Keys.cs" />
Expand Down

0 comments on commit 8bb5d3c

Please sign in to comment.