Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix structure for UserObj.Entities #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions v2/user_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,28 @@ func userFieldStringArray(arr []UserField) []string {
return strs
}

// User entities structure as defined at https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user
type UserEntitiesObj struct {
URL *EntitiesObj `json:"url,omitempty"`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not seeing in the URL entity where the annotations, hash tags, mentions, and cash tags are included.

you could have it like this

type UserURLEnttityObj struct {
    URLs        []EntityURLObj        `json:"urls"` 
}
type UserEntitiesObj struct {
    URL *UserURLEnttityObj   `json:"url"`
    Description *EntitiesObj    `json:"description"`
}

Description *EntitiesObj `json:"description,omitempty"`
}

// UserObj contains Twitter user account metadata describing the referenced user
type UserObj struct {
ID string `json:"id"`
Name string `json:"name"`
UserName string `json:"username"`
CreatedAt string `json:"created_at,omitempty"`
Description string `json:"description,omitempty"`
Entities *EntitiesObj `json:"entities,omitempty"`
Location string `json:"location,omitempty"`
PinnedTweetID string `json:"pinned_tweet_id,omitempty"`
ProfileImageURL string `json:"profile_image_url,omitempty"`
Protected bool `json:"protected,omitempty"`
PublicMetrics *UserMetricsObj `json:"public_metrics,omitempty"`
URL string `json:"url,omitempty"`
Verified bool `json:"verified,omitempty"`
WithHeld *WithHeldObj `json:"withheld,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
UserName string `json:"username"`
CreatedAt string `json:"created_at,omitempty"`
Description string `json:"description,omitempty"`
Entities *UserEntitiesObj `json:"entities,omitempty"`
Location string `json:"location,omitempty"`
PinnedTweetID string `json:"pinned_tweet_id,omitempty"`
ProfileImageURL string `json:"profile_image_url,omitempty"`
Protected bool `json:"protected,omitempty"`
PublicMetrics *UserMetricsObj `json:"public_metrics,omitempty"`
URL string `json:"url,omitempty"`
Verified bool `json:"verified,omitempty"`
WithHeld *WithHeldObj `json:"withheld,omitempty"`
}

// UserMetricsObj contains details about activity for this user
Expand Down