Skip to content

Commit

Permalink
corrected typos (#131)
Browse files Browse the repository at this point in the history
* corrected typos

* updated readme

* corrected more typos

* updated the readme migration
  • Loading branch information
g8rswimmer authored Mar 22, 2022
1 parent 4cff49b commit 199451c
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 65 deletions.
27 changes: 23 additions & 4 deletions v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

> It seems like every v1 is just a prototype.
One of my co-workers said that when we were working on a project, released the first version and then realizing that there were many improvements that needed to be done. That seems to ring true, and this library is not exception. When looking at the improvements that needed to be done, unfortunately these improvements will introduce breaking changes. This version will focus on giving the caller more information from the callouts to allow for better response handling. Another factor is to think about improvements, but first delivering the information first then providing more funcitonality second.
One of my co-workers said that when we were working on a project, released the first version and then realizing that there were many improvements that needed to be done. That seems to ring true, and this library is not exception. When looking at the improvements that needed to be done, unfortunately these improvements will introduce breaking changes. This version will focus on giving the caller more information from the callouts to allow for better response handling. Another factor is to think about improvements, but first delivering the information first then providing more functionality second.

There will be `beta` releases throughout this process and if there are any new functionality requested, it will be discussed to try and get it into this version. Version 1 will still be maintained as I believe that version 2 will need to be mature before the pervious version is even considered to be sunset.

Expand All @@ -19,7 +19,7 @@ go get -u github.com/g8rswimmer/go-twitter/v2

## Changes
The following are changes between `v1` and `v2` of the library.
* One structure for all endpoint callouts. In `v1` there were two structures, `Tweet` and `User`, to preform callouts. This required management of two structures and knowledge which structure contained the desired method callouts. At the time, the grouping looked logical. However with the addtion of the timeline endpoints, it makes more sense to have a single struture `Client` to handle all of the callouts. If the user would like to separate the functionality, interfaces can be used to achieve this.
* One structure for all endpoint callouts. In `v1` there were two structures, `Tweet` and `User`, to preform callouts. This required management of two structures and knowledge which structure contained the desired method callouts. At the time, the grouping looked logical. However with the addition of the timeline endpoints, it makes more sense to have a single structure `Client` to handle all of the callouts. If the user would like to separate the functionality, interfaces can be used to achieve this.
* Endpoint methods will return the entire response. One of the major drawbacks of `v1` was the object returned was not the entire response sent by the callout. For example, the `errors` object in the response is included in `v1` response which does not allow the caller to properly handle partial errors. In `v2`, the first focus is to return the response from twitter to allow the caller to use it as they see fit. However, it does not mean that methods can not be added to the response object to provide groupings, etc.

### Breaking Changes
Expand Down Expand Up @@ -47,6 +47,25 @@ These are some breaking changes and what release they are from. These type of c
```
UserRetweetLookuoOpts -> UserRetweetLookupOpts
```
#### v2.0.0-beta16
* There was a typo in the user following metadata.
```
UserFollowinghMeta -> UserFollowingMeta
```
* There was a typo in the delete user likes response
```
DeteleUserLikesResponse -> DeleteUserLikesResponse
```
* There was a typo in the `EntityURLObj`
```
EntityURLObj.Desription -> EntityURLObj.Description
```
* There was a typo in the `TweetObj` and the JSON tag
```
TweetObj.PossibySensitive -> TweetObj.PossiblySensitive
json: possiby_sensitive -> possibly_sensitive
```

## Features
Here are the current twitter `v2` API features supported.
Expand Down Expand Up @@ -99,7 +118,7 @@ With each response, the rate limits from the response header is returned. This

There is an example of rate limiting from a response [here](./_examples/misc/rate-limit/main.go).

This is an example of a twitter callout and if the limits have been reached, then it will backoff and try again.
This is an example of a twitter callout and if the limits have been reached, then it will back off and try again.
```go
func TweetLikes(ctx context.Context, id string, client *twitter.Client) (*twitter.TweetLikesLookupResponse, error) {
var er *ErrorResponse
Expand All @@ -118,7 +137,7 @@ func TweetLikes(ctx context.Context, id string, client *twitter.Client) (*twitte
```

## Examples
Much like `v1`, there is an `_example` directory to demostrate library usage.
Much like `v1`, there is an `_example` directory to demonstrate library usage.

## Simple Usage
```go
Expand Down
38 changes: 19 additions & 19 deletions v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1072,20 +1072,20 @@ func (c *Client) TweetAllCounts(ctx context.Context, query string, opts TweetAll
return nil, e
}

allCnts := &TweetAllCountsResponse{
allCounts := &TweetAllCountsResponse{
TweetCounts: []*TweetCount{},
Meta: &TweetAllCountsMeta{},
}

if err := decoder.Decode(allCnts); err != nil {
if err := decoder.Decode(allCounts); err != nil {
return nil, &ResponseDecodeError{
Name: "tweet all counts",
Err: err,
RateLimit: rl,
}
}
allCnts.RateLimit = rl
return allCnts, nil
allCounts.RateLimit = rl
return allCounts, nil
}

// UserFollowingLookup will return a user's following users
Expand Down Expand Up @@ -1133,7 +1133,7 @@ func (c *Client) UserFollowingLookup(ctx context.Context, id string, opts UserFo

followingLookup := &UserFollowingLookupResponse{
Raw: &UserRaw{},
Meta: &UserFollowinghMeta{},
Meta: &UserFollowingMeta{},
}

if err := json.Unmarshal(respBytes, followingLookup.Raw); err != nil {
Expand Down Expand Up @@ -1219,7 +1219,7 @@ func (c *Client) UserFollows(ctx context.Context, userID, targetUserID string) (
return raw, nil
}

// DeleteUserFollows llows a user ID to unfollow another user
// DeleteUserFollows allows a user ID to unfollow another user
func (c *Client) DeleteUserFollows(ctx context.Context, userID, targetUserID string) (*UserDeleteFollowsResponse, error) {
switch {
case len(userID) == 0:
Expand Down Expand Up @@ -1853,7 +1853,7 @@ func (c *Client) UserMutesLookup(ctx context.Context, userID string, opts UserMu
default:
}

req, err := http.NewRequestWithContext(ctx, http.MethodGet, userMutesEndpont.urlID(c.Host, userID), nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, userMutesEndpoint.urlID(c.Host, userID), nil)
if err != nil {
return nil, fmt.Errorf("user muted lookup request: %w", err)
}
Expand Down Expand Up @@ -1933,7 +1933,7 @@ func (c *Client) UserMutes(ctx context.Context, userID, targetUserID string) (*U
if err != nil {
return nil, fmt.Errorf("user mutes: json marshal %w", err)
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, userMutesEndpont.urlID(c.Host, userID), bytes.NewReader(enc))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, userMutesEndpoint.urlID(c.Host, userID), bytes.NewReader(enc))
if err != nil {
return nil, fmt.Errorf("user mutes request: %w", err)
}
Expand Down Expand Up @@ -1988,7 +1988,7 @@ func (c *Client) DeleteUserMutes(ctx context.Context, userID, targetUserID strin
default:
}

ep := userMutesEndpont.urlID(c.Host, userID) + "/" + targetUserID
ep := userMutesEndpoint.urlID(c.Host, userID) + "/" + targetUserID
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, ep, nil)
if err != nil {
return nil, fmt.Errorf("user delete mutes request: %w", err)
Expand Down Expand Up @@ -2101,7 +2101,7 @@ func (c *Client) TweetLikesLookup(ctx context.Context, tweetID string, opts Twee
}, nil
}

// UserLikesLookup gets informaiton about a user's liked tweets.
// UserLikesLookup gets information about a user's liked tweets.
func (c *Client) UserLikesLookup(ctx context.Context, userID string, opts UserLikesLookupOpts) (*UserLikesLookupResponse, error) {
switch {
case len(userID) == 0:
Expand Down Expand Up @@ -2233,7 +2233,7 @@ func (c *Client) UserLikes(ctx context.Context, userID, tweetID string) (*UserLi
}

// DeleteUserLikes will unlike the targeted tweet
func (c *Client) DeleteUserLikes(ctx context.Context, userID, tweetID string) (*DeteleUserLikesResponse, error) {
func (c *Client) DeleteUserLikes(ctx context.Context, userID, tweetID string) (*DeleteUserLikesResponse, error) {
switch {
case len(userID) == 0:
return nil, fmt.Errorf("user delete likes: user id is required %w", ErrParameter)
Expand Down Expand Up @@ -2275,7 +2275,7 @@ func (c *Client) DeleteUserLikes(ctx context.Context, userID, tweetID string) (*
return nil, e
}

raw := &DeteleUserLikesResponse{}
raw := &DeleteUserLikesResponse{}
if err := decoder.Decode(raw); err != nil {
return nil, &ResponseDecodeError{
Name: "delete user likes",
Expand Down Expand Up @@ -2645,7 +2645,7 @@ func (c *Client) UpdateList(ctx context.Context, listID string, update ListMetaD
return respBody, nil
}

// DeleteList anables the authenticated user to delete a list
// DeleteList enables the authenticated user to delete a list
func (c *Client) DeleteList(ctx context.Context, listID string) (*ListDeleteResponse, error) {
switch {
case len(listID) == 0:
Expand Down Expand Up @@ -2759,7 +2759,7 @@ func (c *Client) AddListMember(ctx context.Context, listID, userID string) (*Lis

if err := decoder.Decode(respBody); err != nil {
return nil, &ResponseDecodeError{
Name: "add list memeber",
Name: "add list member",
Err: err,
RateLimit: rl,
}
Expand Down Expand Up @@ -2815,7 +2815,7 @@ func (c *Client) RemoveListMember(ctx context.Context, listID, userID string) (*

if err := decoder.Decode(respBody); err != nil {
return nil, &ResponseDecodeError{
Name: "remove list memeber",
Name: "remove list member",
Err: err,
RateLimit: rl,
}
Expand Down Expand Up @@ -3490,7 +3490,7 @@ func (c *Client) SpacesByCreatorLookup(ctx context.Context, userIDs []string, op
default:
}

req, err := http.NewRequestWithContext(ctx, http.MethodGet, spaceByCreatorLookupEndpont.url(c.Host), nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, spaceByCreatorLookupEndpoint.url(c.Host), nil)
if err != nil {
return nil, fmt.Errorf("space by creator lookup request: %w", err)
}
Expand Down Expand Up @@ -3748,7 +3748,7 @@ func (c *Client) CreateComplianceBatchJob(ctx context.Context, jobType Complianc
return nil, fmt.Errorf("create compliance batch job request encode: %w", err)
}

req, err := http.NewRequestWithContext(ctx, http.MethodPost, complainceJobsEndpont.url(c.Host), bytes.NewReader(enc))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, complianceJobsEndpiont.url(c.Host), bytes.NewReader(enc))
if err != nil {
return nil, fmt.Errorf("create compliance batch job request: %w", err)
}
Expand Down Expand Up @@ -3805,7 +3805,7 @@ func (c *Client) ComplianceBatchJob(ctx context.Context, id string) (*Compliance
default:
}

ep := complainceJobsEndpont.url(c.Host) + "/" + id
ep := complianceJobsEndpiont.url(c.Host) + "/" + id
req, err := http.NewRequestWithContext(ctx, http.MethodGet, ep, nil)
if err != nil {
return nil, fmt.Errorf("compliance batch job request: %w", err)
Expand Down Expand Up @@ -3862,7 +3862,7 @@ func (c *Client) ComplianceBatchJobLookup(ctx context.Context, jobType Complianc
default:
}

ep := complainceJobsEndpont.url(c.Host)
ep := complianceJobsEndpiont.url(c.Host)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, ep, nil)
if err != nil {
return nil, fmt.Errorf("compliance batch job lookup request: %w", err)
Expand Down
12 changes: 6 additions & 6 deletions v2/client_compliance_jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func TestClient_CreateComplianceBatchJob(t *testing.T) {
if req.Method != http.MethodPost {
log.Panicf("the method is not correct %s %s", req.Method, http.MethodPost)
}
if strings.Contains(req.URL.String(), string(complainceJobsEndpont)) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), complainceJobsEndpont)
if strings.Contains(req.URL.String(), string(complianceJobsEndpiont)) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), complianceJobsEndpiont)
}
body := `{
"data": {
Expand Down Expand Up @@ -140,8 +140,8 @@ func TestClient_ComplianceBatchJob(t *testing.T) {
if req.Method != http.MethodGet {
log.Panicf("the method is not correct %s %s", req.Method, http.MethodGet)
}
if strings.Contains(req.URL.String(), string(complainceJobsEndpont)+"/job-id") == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), complainceJobsEndpont)
if strings.Contains(req.URL.String(), string(complianceJobsEndpiont)+"/job-id") == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), complianceJobsEndpiont)
}
body := `{
"data": {
Expand Down Expand Up @@ -243,8 +243,8 @@ func TestClient_ComplianceBatchJobLookup(t *testing.T) {
if req.Method != http.MethodGet {
log.Panicf("the method is not correct %s %s", req.Method, http.MethodGet)
}
if strings.Contains(req.URL.String(), string(complainceJobsEndpont)) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), complainceJobsEndpont)
if strings.Contains(req.URL.String(), string(complianceJobsEndpiont)) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), complianceJobsEndpiont)
}
body := `{
"data": [
Expand Down
4 changes: 2 additions & 2 deletions v2/client_likes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ func TestClient_DeleteUserLikes(t *testing.T) {
name string
fields fields
args args
want *DeteleUserLikesResponse
want *DeleteUserLikesResponse
wantErr bool
}{
{
Expand Down Expand Up @@ -685,7 +685,7 @@ func TestClient_DeleteUserLikes(t *testing.T) {
userID: "user-1234",
tweetID: "tweet-1234",
},
want: &DeteleUserLikesResponse{
want: &DeleteUserLikesResponse{
Data: &UserLikesData{
Liked: false,
},
Expand Down
16 changes: 8 additions & 8 deletions v2/client_mutes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func TestClient_UserMutesLookup(t *testing.T) {
if req.Method != http.MethodGet {
log.Panicf("the method is not correct %s %s", req.Method, http.MethodGet)
}
if strings.Contains(req.URL.String(), userMutesEndpont.urlID("", "2244994945")) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), userMutesEndpont)
if strings.Contains(req.URL.String(), userMutesEndpoint.urlID("", "2244994945")) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), userMutesEndpoint)
}
body := `{
"data": [
Expand Down Expand Up @@ -117,8 +117,8 @@ func TestClient_UserMutesLookup(t *testing.T) {
if req.Method != http.MethodGet {
log.Panicf("the method is not correct %s %s", req.Method, http.MethodGet)
}
if strings.Contains(req.URL.String(), userMutesEndpont.urlID("", "2244994945")) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), userMutesEndpont)
if strings.Contains(req.URL.String(), userMutesEndpoint.urlID("", "2244994945")) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), userMutesEndpoint)
}
body := `{
"data": [
Expand Down Expand Up @@ -305,8 +305,8 @@ func TestClient_UserMutes(t *testing.T) {
if req.Method != http.MethodPost {
log.Panicf("the method is not correct %s %s", req.Method, http.MethodPost)
}
if strings.Contains(req.URL.String(), userMutesEndpont.urlID("", "6253282")) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), userMutesEndpont)
if strings.Contains(req.URL.String(), userMutesEndpoint.urlID("", "6253282")) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), userMutesEndpoint)
}
body := `{
"data": {
Expand Down Expand Up @@ -388,8 +388,8 @@ func TestClient_DeleteUserMutes(t *testing.T) {
if req.Method != http.MethodDelete {
log.Panicf("the method is not correct %s %s", req.Method, http.MethodPost)
}
if strings.Contains(req.URL.String(), userMutesEndpont.urlID("", "6253282")+"/2244994945") == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), userMutesEndpont)
if strings.Contains(req.URL.String(), userMutesEndpoint.urlID("", "6253282")+"/2244994945") == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), userMutesEndpoint)
}
body := `{
"data": {
Expand Down
8 changes: 4 additions & 4 deletions v2/client_space_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ func TestClient_SpacesByCreatorLookup(t *testing.T) {
if req.Method != http.MethodGet {
log.Panicf("the method is not correct %s %s", req.Method, http.MethodGet)
}
if strings.Contains(req.URL.String(), string(spaceByCreatorLookupEndpont)) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), spaceByCreatorLookupEndpont)
if strings.Contains(req.URL.String(), string(spaceByCreatorLookupEndpoint)) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), spaceByCreatorLookupEndpoint)
}
body := `{
"data": [
Expand Down Expand Up @@ -295,8 +295,8 @@ func TestClient_SpacesByCreatorLookup(t *testing.T) {
if req.Method != http.MethodGet {
log.Panicf("the method is not correct %s %s", req.Method, http.MethodGet)
}
if strings.Contains(req.URL.String(), string(spaceByCreatorLookupEndpont)) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), spaceByCreatorLookupEndpont)
if strings.Contains(req.URL.String(), string(spaceByCreatorLookupEndpoint)) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), spaceByCreatorLookupEndpoint)
}
body := `{
"data": [
Expand Down
4 changes: 2 additions & 2 deletions v2/client_user_following_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestClient_UserFollowingLookup(t *testing.T) {
},
},
},
Meta: &UserFollowinghMeta{
Meta: &UserFollowingMeta{
ResultCount: 2,
NextToken: "DFEDBNRFT3MHCZZZ",
},
Expand Down Expand Up @@ -212,7 +212,7 @@ func TestClient_UserFollowingLookup(t *testing.T) {
},
},
},
Meta: &UserFollowinghMeta{
Meta: &UserFollowingMeta{
ResultCount: 2,
NextToken: "DFEDBNRFT3MHCZZZ",
},
Expand Down
2 changes: 1 addition & 1 deletion v2/common_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type EntityURLObj struct {
DisplayURL string `json:"display_url"`
Status int `json:"status"`
Title string `json:"title"`
Desription string `json:"description"`
Description string `json:"description"`
UnwoundURL string `json:"unwound_url"`
}

Expand Down
6 changes: 3 additions & 3 deletions v2/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
userAuthLookupEndpoint endpoint = "2/users/me"
userManageRetweetEndpoint endpoint = "2/users/{id}/retweets"
userBlocksEndpoint endpoint = "2/users/{id}/blocking"
userMutesEndpont endpoint = "2/users/{id}/muting"
userMutesEndpoint endpoint = "2/users/{id}/muting"
userRetweetLookupEndpoint endpoint = "2/tweets/{id}/retweeted_by"
tweetRecentSearchEndpoint endpoint = "2/tweets/search/recent"
tweetSearchEndpoint endpoint = "2/tweets/search/all"
Expand Down Expand Up @@ -45,11 +45,11 @@ const (
userFollowedListEndpoint endpoint = "2/users/{id}/followed_lists"
listUserFollowersEndpoint endpoint = "2/lists/{id}/followers"
spaceLookupEndpoint endpoint = "2/spaces"
spaceByCreatorLookupEndpont endpoint = "2/spaces/by/creator_ids"
spaceByCreatorLookupEndpoint endpoint = "2/spaces/by/creator_ids"
spaceBuyersLookupEndpoint endpoint = "2/spaces/{id}/buyers"
spaceTweetsLookupEndpoint endpoint = "2/spaces/{id}/tweets"
spaceSearchEndpoint endpoint = "2/spaces/search"
complainceJobsEndpont endpoint = "2/compliance/jobs"
complianceJobsEndpiont endpoint = "2/compliance/jobs"

idTag = "{id}"
)
Expand Down
Loading

0 comments on commit 199451c

Please sign in to comment.