Skip to content

Commit

Permalink
Cleaned up Tweet fetch to include preview images (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
csharpfritz authored Aug 13, 2023
1 parent d0db68e commit a14db9b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 93 deletions.
1 change: 1 addition & 0 deletions src/TagzApp.Providers.Twitter/Models/SampleTweets.json

Large diffs are not rendered by default.

71 changes: 35 additions & 36 deletions src/TagzApp.Providers.Twitter/Models/Tweet.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace TagzApp.Providers.Twitter.Models;



public class TwitterData
{
public Tweet[] data { get; set; }
Expand All @@ -10,26 +11,26 @@ public class TwitterData

public class Includes
{
public User[] users { get; set; }
public Medium[] media { get; set; }
public User[] users { get; set; }
}

public class User
public class Medium
{
public string id { get; set; }
public string name { get; set; }
public string username { get; set; }
public string media_key { get; set; }
public string? preview_image_url { get; set; }
public string type { get; set; }
public string? alt_text { get; set; }
public int? height { get; set; }
public int? width { get; set; }
}

public class Medium
public class User
{
public string url { get; set; }
public string type { get; set; }
public int width { get; set; }
public string media_key { get; set; }
public int height { get; set; }
public string alt_text { get; set; }
public string preview_image_url { get; set; }
public string profile_image_url { get; set; }
public string username { get; set; }
public string name { get; set; }
public string id { get; set; }
}

public class Meta
Expand All @@ -43,51 +44,36 @@ public class Meta
public class Tweet
{
public string author_id { get; set; }
public string id { get; set; }
public Entities entities { get; set; }
public string[] edit_history_tweet_ids { get; set; }
public DateTime created_at { get; set; }
public string text { get; set; }
public Entities entities { get; set; }
public string[] edit_history_tweet_ids { get; set; }
public Attachments attachments { get; set; }
public string id { get; set; }
}

public class Entities
{
public Mention[] mentions { get; set; }
public Hashtag[] hashtags { get; set; }
public Url[] urls { get; set; }
public Hashtag[] hashtags { get; set; }
public Annotation[] annotations { get; set; }
public Mention[] mentions { get; set; }
public Cashtag[] cashtags { get; set; }
}

public class Mention
{
public int start { get; set; }
public int end { get; set; }
public string username { get; set; }
public string id { get; set; }
}

public class Hashtag
{
public int start { get; set; }
public int end { get; set; }
public string tag { get; set; }
}

public class Url
{
public int start { get; set; }
public int end { get; set; }
public string url { get; set; }
public string expanded_url { get; set; }
public string display_url { get; set; }
public string media_key { get; set; }
public Image[] images { get; set; }
public int status { get; set; }
public string title { get; set; }
public string description { get; set; }
public string unwound_url { get; set; }
public string media_key { get; set; }
}

public class Image
Expand All @@ -97,6 +83,13 @@ public class Image
public int height { get; set; }
}

public class Hashtag
{
public int start { get; set; }
public int end { get; set; }
public string tag { get; set; }
}

public class Annotation
{
public int start { get; set; }
Expand All @@ -106,6 +99,14 @@ public class Annotation
public string normalized_text { get; set; }
}

public class Mention
{
public int start { get; set; }
public int end { get; set; }
public string username { get; set; }
public string id { get; set; }
}

public class Cashtag
{
public int start { get; set; }
Expand All @@ -117,5 +118,3 @@ public class Attachments
{
public string[] media_keys { get; set; }
}


Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<None Remove="Models\SampleTweets.json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Models\SampleTweets.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
Expand Down
78 changes: 21 additions & 57 deletions src/TagzApp.Providers.Twitter/TwitterProvider.cs

Large diffs are not rendered by default.

0 comments on commit a14db9b

Please sign in to comment.