Skip to content

Commit

Permalink
Updated Documentation. (#30)
Browse files Browse the repository at this point in the history
* Refactoring.

* Update README.md
  • Loading branch information
DamienDennehy authored Aug 15, 2020
1 parent fcf8ae3 commit 7d24f8b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 18 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ jobs:
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.4

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301

- name: Setup Java JDK
uses: actions/setup-java@v1
with:
Expand Down Expand Up @@ -157,4 +152,4 @@ jobs:
- name: Push to NuGet
run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_AUTH_TOKEN}} .\artifacts\**\*.nupkg --skip-duplicate --no-symbols true
env:
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLE: false
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLE: false
3 changes: 2 additions & 1 deletion Imgur.API.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{95D79228
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Imgur.API.Tests", "tests\Imgur.API.Tests\Imgur.API.Tests.csproj", "{65F14BBA-B4B5-4243-823A-4FAF41AB67BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Imgur.API.Tests.Integration", "tests\Imgur.API.Tests.Integration\Imgur.API.Tests.Integration\Imgur.API.Tests.Integration.csproj", "{4AD6F734-769C-437F-88BC-75727427F210}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Imgur.API.Tests.Integration", "tests\Imgur.API.Tests.Integration\Imgur.API.Tests.Integration\Imgur.API.Tests.Integration.csproj", "{4AD6F734-769C-437F-88BC-75727427F210}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D42AD5DE-ED8F-42B5-A22D-4AC6B811DF95}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
README.md = README.md
EndProjectSection
EndProject
Global
Expand Down
58 changes: 47 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# Imgur.API
Imgur.API is a .NET implementation of Imgur's API.

It supports Imgur's free and RapidAPI's commercial API endpoints.

![Build](https://github.com/DamienDennehy/Imgur.API/workflows/Build/badge.svg)

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ImgurAPI&metric=alert_status)](https://sonarcloud.io/dashboard?id=ImgurAPI)

[![NuGet](https://img.shields.io/nuget/vpre/Imgur.API.svg)](https://www.nuget.org/packages/Imgur.API/)

## Getting Started

### Register Client
Register your App at https://api.imgur.com/oauth2/addclient

Expand All @@ -20,9 +17,47 @@ var apiClient = new ApiClient("YOUR_CLIENT_KEY");
~~~

## Using OAuth
### Getting an Authorization Url
The Authorization Url should be loaded in a browser, allowing the user to login to Imgur.

~~~
var apiClient = new ApiClient("YOUR_CLIENT_KEY", "YOUR_CLIENT_SECRET");
var httpClient = new HttpClient();
var oAuth2Endpoint = new OAuth2Endpoint(apiClient, httpClient);
var authUrl = oAuth2Endpoint.GetAuthorizationUrl();
~~~

Once user has logged in, they are redirected to your previously set Url.
Once the token information is available and parsed create a token.

~~~
var token = new OAuth2Token
{
AccessToken = "YOUR_TOKEN",
RefreshToken = "YOUR_REFRESH_TOKEN",
AccountId = YOUR_ACCOUNT_ID,
AccountUsername = "YOUR_ACCOUNT_PASSWORD",
ExpiresIn = YOUR_EXPIRATION,
TokenType = "YOUR_TOKEN"
};
~~~

Then set the token on the ApiClient.

~~~
apiClient.SetOAuth2Token(token);
~~~

Continue to use the rest of the Endpoints.

~~~
var imageEndpoint = new ImageEndpoint(apiClient, httpClient);
~~~

## Uploading Images & Video
### Uploading Image

~~~
var apiClient = new ApiClient("YOUR_CLIENT_KEY");
var httpClient = new HttpClient();
Expand All @@ -32,8 +67,10 @@ using var fileStream = File.OpenRead(filePath);
var imageEndpoint = new ImageEndpoint(apiClient, httpClient);
var imageUpload = await imageEndpoint.UploadImageAsync(fileStream);
~~~
~~~

### Uploading Video

~~~
var apiClient = new ApiClient("YOUR_CLIENT_KEY");
var httpClient = new HttpClient();
Expand All @@ -43,8 +80,10 @@ using var fileStream = File.OpenRead(filePath);
var imageEndpoint = new ImageEndpoint(apiClient, httpClient);
var imageUpload = await imageEndpoint.UploadVideoAsync(fileStream);
~~~
~~~

### Uploading Video with Progress

~~~
var apiClient = new ApiClient("YOUR_CLIENT_KEY");
var httpClient = new HttpClient();
Expand All @@ -61,11 +100,8 @@ void report(int byteProgress)
{
//Do something with the progress here.
}
~~~
~~~

## API Definition
As of August 2020 two Endpoints are available:
* OAuthEndpoint
* ImageEndpoint

The methods on the endpoints match what is available at the official Imgur API at https://apidocs.imgur.com/
Several Endpoints are available.
The methods on the Endpoints match what is available at the official Imgur API at https://apidocs.imgur.com/
4 changes: 4 additions & 0 deletions src/Imgur.API/Imgur.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RepositoryUrl>https://github.com/DamienDennehy/Imgur.API</RepositoryUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Description>Imgur.API is a .NET implementation of Imgur's API.</Description>
<PackageTags>imgur;media;image;video;upload</PackageTags>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand All @@ -17,6 +20,7 @@

<ItemGroup>
<Content Include="..\..\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
<Content Include="..\..\LICENSE" Link="LICENSE" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 7d24f8b

Please sign in to comment.