Skip to content

Commit

Permalink
README.md updated for Unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
erkanzsy committed Jul 6, 2023
1 parent 4bcc9c0 commit 0d20056
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 35 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,26 @@ package main

import (
"fmt"
threads_api "github.com/erkanzsy/threads-api"
threadsapi "github.com/erkanzsy/threads-api"
)

func main() {
userId, _ := threads_api.UserIDFromUsername("zuck")
userId, err := threadsapi.UserIDFromUsername("zuck")
if err != nil {
fmt.Println(err)
}
fmt.Println(userId) // 314216

profile, _ := threads_api.UserProfile("zuck", "314216")
profile, err := threadsapi.UserProfile("zuck", "314216")
if err != nil {
fmt.Println(err)
}
fmt.Println(profile.Data.UserData.User.Username) // zuck

threads, _ := threads_api.UserThreads("zuck", "314216")
threads, err := threadsapi.UserThreads("zuck", "314216")
if err != nil {
fmt.Println(err)
}
fmt.Println(threads.Data.MediaData.Threads[0].ThreadItems[0].Post.User.Username) // zuck
}
```
Expand Down
32 changes: 32 additions & 0 deletions profile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package threads_api

type UserProfileData struct {
Data struct {
UserData struct {
User struct {
IsPrivate bool `json:"is_private"`
ProfilePicURL string `json:"profile_pic_url"`
Username string `json:"username"`
HdProfilePicVersions []struct {
Height int `json:"height"`
URL string `json:"url"`
Width int `json:"width"`
} `json:"hd_profile_pic_versions"`
IsVerified bool `json:"is_verified"`
Biography string `json:"biography"`
BiographyWithEntities any `json:"biography_with_entities"`
FollowerCount int `json:"follower_count"`
ProfileContextFacepileUsers any `json:"profile_context_facepile_users"`
BioLinks []struct {
URL string `json:"url"`
} `json:"bio_links"`
Pk string `json:"pk"`
FullName string `json:"full_name"`
ID any `json:"id"`
} `json:"user"`
} `json:"userData"`
} `json:"data"`
Extensions struct {
IsFinal bool `json:"is_final"`
} `json:"extensions"`
}
31 changes: 0 additions & 31 deletions schema.go → threads.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
package threads_api

type UserProfileData struct {
Data struct {
UserData struct {
User struct {
IsPrivate bool `json:"is_private"`
ProfilePicURL string `json:"profile_pic_url"`
Username string `json:"username"`
HdProfilePicVersions []struct {
Height int `json:"height"`
URL string `json:"url"`
Width int `json:"width"`
} `json:"hd_profile_pic_versions"`
IsVerified bool `json:"is_verified"`
Biography string `json:"biography"`
BiographyWithEntities any `json:"biography_with_entities"`
FollowerCount int `json:"follower_count"`
ProfileContextFacepileUsers any `json:"profile_context_facepile_users"`
BioLinks []struct {
URL string `json:"url"`
} `json:"bio_links"`
Pk string `json:"pk"`
FullName string `json:"full_name"`
ID any `json:"id"`
} `json:"user"`
} `json:"userData"`
} `json:"data"`
Extensions struct {
IsFinal bool `json:"is_final"`
} `json:"extensions"`
}

type UserThreadsData struct {
Data struct {
MediaData struct {
Expand Down

0 comments on commit 0d20056

Please sign in to comment.