forked from CrustyJew/RedditSharp-DEPRECATED-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomain.cs
More file actions
50 lines (42 loc) · 1.69 KB
/
Domain.cs
File metadata and controls
50 lines (42 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Newtonsoft.Json;
using RedditSharp.Things;
using System;
namespace RedditSharp
{
/// <summary>
/// A domain submitted to reddit.
/// </summary>
public class Domain : RedditObject
{
private string DomainPostUrl => $"/domain/{Name}.json";
private string DomainNewUrl => $"/domain/{Name}/new.json?sort=new";
private string DomainHotUrl => $"/domain/{Name}/hot.json";
private const string FrontPageUrl = "/.json";
/// <summary>
/// Domain name
/// </summary>
[JsonIgnore]
public string Name { get; set; }
/// <summary>
/// Get a <see cref="Listing{T}"/> of posts made for this domain.
/// </summary>
/// <param name="max">Maximum number of records to return. -1 for unlimited.</param>
public Listing<Post> GetPosts(int max = -1) => Listing<Post>.Create(WebAgent, DomainPostUrl, max, 100);
/// <summary>
/// Get a <see cref="Listing{T}"/> of posts made for this domain that are in the new queue.
/// </summary>
public Listing<Post> GetNew(int max = -1) => Listing<Post>.Create(WebAgent, DomainNewUrl, max, 100);
/// <summary>
/// Get a <see cref="Listing{T}"/> of posts made for this domain that are in the hot queue.
/// </summary>
public Listing<Post> GetHot(int max = -1) => Listing<Post>.Create(WebAgent, DomainHotUrl, max, 100);
#pragma warning disable 1591
protected internal Domain(IWebAgent agent, Uri domain) : base(agent)
{
Name = domain.Host;
}
#pragma warning restore 1591
/// <inheritdoc/>
public override string ToString() => "/domain/" + Name;
}
}