-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Facebook: Added more logic for the videos endpoint
- Loading branch information
Showing
6 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
src/Skybrud.Social/Facebook/Endpoints/FacebookVideosEndpoint.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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Skybrud.Social.Facebook.Endpoints.Raw; | ||
using Skybrud.Social.Facebook.Options.Videos; | ||
using Skybrud.Social.Facebook.Responses.Videos; | ||
|
||
namespace Skybrud.Social.Facebook.Endpoints { | ||
|
||
/// <summary> | ||
/// Class representing the implementation of the videos endpoint. | ||
/// </summary> | ||
public class FacebookVideosEndpoint { | ||
|
||
#region Properties | ||
|
||
/// <summary> | ||
/// Gets a reference to the Facebook service. | ||
/// </summary> | ||
public FacebookService Service { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets a reference to the raw endpoint. | ||
/// </summary> | ||
public FacebookVideosRawEndpoint Raw { | ||
get { return Service.Client.Videos; } | ||
} | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
internal FacebookVideosEndpoint(FacebookService service) { | ||
Service = service; | ||
} | ||
|
||
#endregion | ||
|
||
#region Methods | ||
|
||
/// <summary> | ||
/// Gets information about the video with the specified <code>id</code>. | ||
/// </summary> | ||
/// <param name="id">The ID of the video.</param> | ||
public FacebookVideoResponse GetVideo(string id) { | ||
return FacebookVideoResponse.ParseResponse(Raw.GetVideo(id)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets information about the video matching the specified <code>options</code>. | ||
/// </summary> | ||
/// <param name="options">The options for the call to the API.</param> | ||
public FacebookVideoResponse GetVideo(FacebookGetVideoOptions options) { | ||
return FacebookVideoResponse.ParseResponse(Raw.GetVideo(options)); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
|
||
} |
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
39 changes: 39 additions & 0 deletions
39
src/Skybrud.Social/Facebook/Responses/Videos/FacebookVideoResponse.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Skybrud.Social.Facebook.Objects.Videos; | ||
using Skybrud.Social.Http; | ||
using Skybrud.Social.Json; | ||
|
||
namespace Skybrud.Social.Facebook.Responses.Videos { | ||
|
||
public class FacebookVideoResponse : FacebookResponse<FacebookVideo> { | ||
|
||
#region Constructors | ||
|
||
private FacebookVideoResponse(SocialHttpResponse response) : base(response) { } | ||
|
||
#endregion | ||
|
||
#region Static methods | ||
|
||
public static FacebookVideoResponse ParseResponse(SocialHttpResponse response) { | ||
|
||
if (response == null) return null; | ||
|
||
// Parse the raw JSON response | ||
JsonObject obj = response.GetBodyAsJsonObject(); | ||
if (obj == null) return null; | ||
|
||
// Validate the response | ||
ValidateResponse(response, obj); | ||
|
||
// Initialize the response object | ||
return new FacebookVideoResponse(response) { | ||
Body = FacebookVideo.Parse(obj) | ||
}; | ||
|
||
} | ||
|
||
#endregion | ||
|
||
} | ||
|
||
} |
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