strip .json from urls

This commit is contained in:
Andre Medeiros 2022-03-14 09:40:18 -04:00
parent 3bf38b0630
commit 455788a9c4

View file

@ -319,7 +319,7 @@ func (rac *AuthenticatedClient) AboutInfo(fullname string, opts ...RequestOption
} }
func (rac *AuthenticatedClient) UserPosts(user string, opts ...RequestOption) (*ListingResponse, error) { func (rac *AuthenticatedClient) UserPosts(user string, opts ...RequestOption) (*ListingResponse, error) {
url := fmt.Sprintf("https://oauth.reddit.com/u/%s/submitted.json", user) url := fmt.Sprintf("https://oauth.reddit.com/u/%s/submitted", user)
opts = append([]RequestOption{ opts = append([]RequestOption{
WithMethod("GET"), WithMethod("GET"),
WithToken(rac.accessToken), WithToken(rac.accessToken),
@ -336,7 +336,7 @@ func (rac *AuthenticatedClient) UserPosts(user string, opts ...RequestOption) (*
} }
func (rac *AuthenticatedClient) UserAbout(user string, opts ...RequestOption) (*UserResponse, error) { func (rac *AuthenticatedClient) UserAbout(user string, opts ...RequestOption) (*UserResponse, error) {
url := fmt.Sprintf("https://oauth.reddit.com/u/%s/about.json", user) url := fmt.Sprintf("https://oauth.reddit.com/u/%s/about", user)
opts = append([]RequestOption{ opts = append([]RequestOption{
WithMethod("GET"), WithMethod("GET"),
WithToken(rac.accessToken), WithToken(rac.accessToken),
@ -354,7 +354,7 @@ func (rac *AuthenticatedClient) UserAbout(user string, opts ...RequestOption) (*
} }
func (rac *AuthenticatedClient) SubredditAbout(subreddit string, opts ...RequestOption) (*SubredditResponse, error) { func (rac *AuthenticatedClient) SubredditAbout(subreddit string, opts ...RequestOption) (*SubredditResponse, error) {
url := fmt.Sprintf("https://oauth.reddit.com/r/%s/about.json", subreddit) url := fmt.Sprintf("https://oauth.reddit.com/r/%s/about", subreddit)
opts = append([]RequestOption{ opts = append([]RequestOption{
WithMethod("GET"), WithMethod("GET"),
WithToken(rac.accessToken), WithToken(rac.accessToken),
@ -371,7 +371,7 @@ func (rac *AuthenticatedClient) SubredditAbout(subreddit string, opts ...Request
} }
func (rac *AuthenticatedClient) subredditPosts(subreddit string, sort string, opts ...RequestOption) (*ListingResponse, error) { func (rac *AuthenticatedClient) subredditPosts(subreddit string, sort string, opts ...RequestOption) (*ListingResponse, error) {
url := fmt.Sprintf("https://oauth.reddit.com/r/%s/%s.json", subreddit, sort) url := fmt.Sprintf("https://oauth.reddit.com/r/%s/%s", subreddit, sort)
opts = append([]RequestOption{ opts = append([]RequestOption{
WithMethod("GET"), WithMethod("GET"),
WithToken(rac.accessToken), WithToken(rac.accessToken),
@ -404,7 +404,7 @@ func (rac *AuthenticatedClient) MessageInbox(opts ...RequestOption) (*ListingRes
WithTags([]string{"url:/api/v1/message/inbox"}), WithTags([]string{"url:/api/v1/message/inbox"}),
WithMethod("GET"), WithMethod("GET"),
WithToken(rac.accessToken), WithToken(rac.accessToken),
WithURL("https://oauth.reddit.com/message/inbox.json"), WithURL("https://oauth.reddit.com/message/inbox"),
WithEmptyResponseBytes(122), WithEmptyResponseBytes(122),
}, opts...) }, opts...)
req := NewRequest(opts...) req := NewRequest(opts...)
@ -428,7 +428,7 @@ func (rac *AuthenticatedClient) MessageUnread(opts ...RequestOption) (*ListingRe
WithTags([]string{"url:/api/v1/message/unread"}), WithTags([]string{"url:/api/v1/message/unread"}),
WithMethod("GET"), WithMethod("GET"),
WithToken(rac.accessToken), WithToken(rac.accessToken),
WithURL("https://oauth.reddit.com/message/unread.json"), WithURL("https://oauth.reddit.com/message/unread"),
WithEmptyResponseBytes(122), WithEmptyResponseBytes(122),
}, opts...) }, opts...)