Skip to content

Commit de20254

Browse files
committed
fix directory struct #18
1 parent 9528392 commit de20254

33 files changed

Lines changed: 917 additions & 1013 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ This is a library for using the Twitter API v2 in the Go language. (It is still
3636
- Hide replies
3737
- [ ] `PUT /2/tweets/:id/hidden`
3838
- Users
39-
- Users lookup
39+
- User lookup
4040
- [x] `GET /2/users`
4141
- [x] `GET /2/users/:id`
4242
- [x] `GET /2/users/by`

api/resource/users/users.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

api/resource/users/users_by.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

api/resource/users/users_by_username.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

api/resource/users/users_id.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

client.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"os"
88
"time"
99

10-
"github.com/michimani/gotwi/types"
11-
"github.com/michimani/gotwi/types/response"
10+
"github.com/michimani/gotwi/internal/gotwierrors"
11+
"github.com/michimani/gotwi/internal/util"
1212
)
1313

1414
const (
@@ -21,6 +21,12 @@ type TwitterClient struct {
2121
AccessToken string
2222
}
2323

24+
type ClientResponse struct {
25+
StatusCode int
26+
Status string
27+
Body []byte
28+
}
29+
2430
func NewClient() *TwitterClient {
2531
return &TwitterClient{
2632
Client: &http.Client{
@@ -58,7 +64,7 @@ func (c *TwitterClient) IsReady() bool {
5864
return true
5965
}
6066

61-
func (c *TwitterClient) Exec(req *http.Request) (*response.ClientResponse, error) {
67+
func (c *TwitterClient) Exec(req *http.Request) (*ClientResponse, error) {
6268
res, err := c.Client.Do(req)
6369
if err != nil {
6470
return nil, err
@@ -70,28 +76,28 @@ func (c *TwitterClient) Exec(req *http.Request) (*response.ClientResponse, error
7076
return nil, err
7177
}
7278

73-
return &response.ClientResponse{
79+
return &ClientResponse{
7480
StatusCode: res.StatusCode,
7581
Status: res.Status,
7682
Body: bytes,
7783
}, nil
7884
}
7985

80-
func (c *TwitterClient) Prepare(endpointBase, method string, p types.Parameters) (*http.Request, error) {
86+
func (c *TwitterClient) Prepare(endpointBase, method string, p util.Parameters) (*http.Request, error) {
8187
if p == nil {
82-
return nil, fmt.Errorf(types.ErrorParametersNil, endpointBase)
88+
return nil, fmt.Errorf(gotwierrors.ErrorParametersNil, endpointBase)
8389
}
8490

8591
if !c.IsReady() {
86-
return nil, fmt.Errorf(types.ErrorClientNotReady)
92+
return nil, fmt.Errorf(gotwierrors.ErrorClientNotReady)
8793
}
8894

8995
endpoint := p.ResolveEndpoint(endpointBase)
9096
p.SetAccessToken(c.AccessToken)
9197
return newRequest(endpoint, method, p)
9298
}
9399

94-
func newRequest(endpoint, method string, p types.Parameters) (*http.Request, error) {
100+
func newRequest(endpoint, method string, p util.Parameters) (*http.Request, error) {
95101
req, err := http.NewRequest(method, endpoint, p.Body())
96102
if err != nil {
97103
return nil, err

fields/expansions.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package fields
2+
3+
type Expansion string
4+
5+
const (
6+
ExpansionPinnedTweetID Expansion = "pinned_tweet_id"
7+
)

fields/tweet_fields.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package fields
2+
3+
type TweetField string
4+
5+
const (
6+
Attachments TweetField = "attachments"
7+
AuthorID TweetField = "author_id"
8+
ContextAnnotations TweetField = "context_annotations"
9+
ConversationID TweetField = "conversation_id"
10+
TweetCreatedAt TweetField = "created_at"
11+
TweetEntities TweetField = "entities"
12+
Geo TweetField = "geo"
13+
TweetID TweetField = "id"
14+
InReplyToUserID TweetField = "in_reply_to_user_id"
15+
Lang TweetField = "lang"
16+
NonPublicMetrics TweetField = "non_public_metrics"
17+
TweetPublicMetrics TweetField = "public_metrics"
18+
OrganicMetrics TweetField = "organic_metrics"
19+
PromotedMetrics TweetField = "promoted_metrics"
20+
PossiblySensitive TweetField = "possibly_sensitive"
21+
ReferencedTweets TweetField = "referenced_tweets"
22+
ReplySettings TweetField = "reply_settings"
23+
Source TweetField = "source"
24+
Text TweetField = "text"
25+
TweetWithheld TweetField = "withheld"
26+
)

fields/user_fields.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package fields
2+
3+
type UserField string
4+
5+
const (
6+
UserCreatedAt UserField = "created_at"
7+
Description UserField = "description"
8+
Entities UserField = "entities"
9+
UserID UserField = "id"
10+
Location UserField = "location"
11+
Name UserField = "name"
12+
UserPinnedTweetID UserField = "pinned_tweet_id"
13+
ProfileImageURL UserField = "profile_image_url"
14+
Protected UserField = "protected"
15+
PublicMetrics UserField = "public_metrics"
16+
URL UserField = "url"
17+
Username UserField = "username"
18+
Verified UserField = "verified"
19+
Withheld UserField = "withheld"
20+
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package types
1+
package gotwierrors
22

33
const (
44
ErrorClientNotReady string = "Twitter client is not ready."

0 commit comments

Comments
 (0)