-
Notifications
You must be signed in to change notification settings - Fork 0
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
11 changed files
with
396 additions
and
417 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
namespace Nullforce.Api.Derpibooru | ||
namespace Nullforce.Api.Derpibooru; | ||
|
||
public class DerpiBase | ||
{ | ||
public class DerpiBase | ||
{ | ||
protected readonly string _apiBaseUri; | ||
protected readonly string _apiKey; | ||
protected string _uri; | ||
public string Uri => _uri; | ||
protected readonly string _apiBaseUri; | ||
protected readonly string _apiKey; | ||
protected string _uri; | ||
public string Uri => _uri; | ||
|
||
public DerpiBase(string apiBaseUri, string apiKey) | ||
{ | ||
_apiBaseUri = apiBaseUri; | ||
_apiKey = apiKey; | ||
} | ||
public DerpiBase(string apiBaseUri, string apiKey) | ||
{ | ||
_apiBaseUri = apiBaseUri; | ||
_apiKey = apiKey; | ||
} | ||
} |
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,45 +1,44 @@ | ||
namespace Nullforce.Api.Derpibooru | ||
namespace Nullforce.Api.Derpibooru; | ||
|
||
public class DerpiClient | ||
{ | ||
public class DerpiClient | ||
{ | ||
private readonly string _apiBaseUri = "https://derpibooru.org/api/v1/json"; | ||
private readonly string _apiKey; | ||
private readonly string _apiBaseUri = "https://derpibooru.org/api/v1/json"; | ||
private readonly string _apiKey; | ||
|
||
public DerpiClient() | ||
{ | ||
} | ||
public DerpiClient() | ||
{ | ||
} | ||
|
||
public DerpiClient(string apiKey) | ||
{ | ||
_apiKey = apiKey; | ||
} | ||
public DerpiClient(string apiKey) | ||
{ | ||
_apiKey = apiKey; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the image response for an image by Id | ||
/// </summary> | ||
/// <param name="imageId">The id of the image</param> | ||
/// <returns>A fluent API wrapper for get image</returns> | ||
public DerpiGetImage GetImage(int imageId) | ||
{ | ||
return new DerpiGetImage(_apiBaseUri, _apiKey, imageId); | ||
} | ||
/// <summary> | ||
/// Gets the image response for an image by Id | ||
/// </summary> | ||
/// <param name="imageId">The id of the image</param> | ||
/// <returns>A fluent API wrapper for get image</returns> | ||
public DerpiGetImage GetImage(int imageId) | ||
{ | ||
return new DerpiGetImage(_apiBaseUri, _apiKey, imageId); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the image response for the featured image | ||
/// </summary> | ||
/// <returns>A fluent API wrapper for featured image</returns> | ||
public DerpiGetFeaturedImage GetFeaturedImage() | ||
{ | ||
return new DerpiGetFeaturedImage(_apiBaseUri, _apiKey); | ||
} | ||
/// <summary> | ||
/// Gets the image response for the featured image | ||
/// </summary> | ||
/// <returns>A fluent API wrapper for featured image</returns> | ||
public DerpiGetFeaturedImage GetFeaturedImage() | ||
{ | ||
return new DerpiGetFeaturedImage(_apiBaseUri, _apiKey); | ||
} | ||
|
||
/// <summary> | ||
/// Exposes the Derpibooru Search as a Fluent API. | ||
/// </summary> | ||
/// <returns>A fluent API wrapper for search</returns> | ||
public DerpiSearch Search() | ||
{ | ||
return new DerpiSearch(_apiBaseUri, _apiKey); | ||
} | ||
/// <summary> | ||
/// Exposes the Derpibooru Search as a Fluent API. | ||
/// </summary> | ||
/// <returns>A fluent API wrapper for search</returns> | ||
public DerpiSearch Search() | ||
{ | ||
return new DerpiSearch(_apiBaseUri, _apiKey); | ||
} | ||
} |
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,13 +1,12 @@ | ||
using Flurl; | ||
|
||
namespace Nullforce.Api.Derpibooru | ||
namespace Nullforce.Api.Derpibooru; | ||
|
||
public class DerpiGetFeaturedImage : DerpiBase | ||
{ | ||
public class DerpiGetFeaturedImage : DerpiBase | ||
public DerpiGetFeaturedImage(string apiBaseUri, string apiKey) | ||
: base(apiBaseUri, apiKey) | ||
{ | ||
public DerpiGetFeaturedImage(string apiBaseUri, string apiKey) | ||
: base(apiBaseUri, apiKey) | ||
{ | ||
_uri = apiBaseUri.AppendPathSegment("images/featured"); | ||
} | ||
_uri = apiBaseUri.AppendPathSegment("images/featured"); | ||
} | ||
} |
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,23 +1,22 @@ | ||
using Flurl; | ||
|
||
namespace Nullforce.Api.Derpibooru | ||
namespace Nullforce.Api.Derpibooru; | ||
|
||
public class DerpiGetImage : DerpiBase | ||
{ | ||
public class DerpiGetImage : DerpiBase | ||
public DerpiGetImage(string apiBaseUri, string apiKey, int imageId) | ||
: base(apiBaseUri, apiKey) | ||
{ | ||
public DerpiGetImage(string apiBaseUri, string apiKey, int imageId) | ||
: base(apiBaseUri, apiKey) | ||
{ | ||
_uri = apiBaseUri.AppendPathSegment($"images/{imageId}"); | ||
} | ||
_uri = apiBaseUri.AppendPathSegment($"images/{imageId}"); | ||
} | ||
|
||
/// <summary> | ||
/// Applies a Derpibooru filter | ||
/// </summary> | ||
/// <param name="filterId">A user or system filter ID (See https://www.derpibooru.org/filters) </param> | ||
public DerpiGetImage WithFilterId(int filterId) | ||
{ | ||
_uri = _uri.SetQueryParam("filter_id", filterId); | ||
return this; | ||
} | ||
/// <summary> | ||
/// Applies a Derpibooru filter | ||
/// </summary> | ||
/// <param name="filterId">A user or system filter ID (See https://www.derpibooru.org/filters) </param> | ||
public DerpiGetImage WithFilterId(int filterId) | ||
{ | ||
_uri = _uri.SetQueryParam("filter_id", filterId); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.