-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxtweetretweet.go
More file actions
123 lines (108 loc) · 4.11 KB
/
xtweetretweet.go
File metadata and controls
123 lines (108 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package xtwitterscraper
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"github.com/Xquik-dev/x-twitter-scraper-go/internal/apijson"
"github.com/Xquik-dev/x-twitter-scraper-go/internal/requestconfig"
"github.com/Xquik-dev/x-twitter-scraper-go/option"
"github.com/Xquik-dev/x-twitter-scraper-go/packages/param"
"github.com/Xquik-dev/x-twitter-scraper-go/packages/respjson"
)
// X write actions (tweets, likes, follows, DMs)
//
// XTweetRetweetService contains methods and other services that help with
// interacting with the x-twitter-scraper API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewXTweetRetweetService] method instead.
type XTweetRetweetService struct {
options []option.RequestOption
}
// NewXTweetRetweetService generates a new service that applies the given options
// to each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewXTweetRetweetService(opts ...option.RequestOption) (r XTweetRetweetService) {
r = XTweetRetweetService{}
r.options = opts
return
}
// Retweet
func (r *XTweetRetweetService) New(ctx context.Context, id string, body XTweetRetweetNewParams, opts ...option.RequestOption) (res *XTweetRetweetNewResponse, err error) {
opts = slices.Concat(r.options, opts)
if id == "" {
err = errors.New("missing required id parameter")
return nil, err
}
path := fmt.Sprintf("x/tweets/%s/retweet", url.PathEscape(id))
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Unretweet
func (r *XTweetRetweetService) Delete(ctx context.Context, id string, body XTweetRetweetDeleteParams, opts ...option.RequestOption) (res *XTweetRetweetDeleteResponse, err error) {
opts = slices.Concat(r.options, opts)
if id == "" {
err = errors.New("missing required id parameter")
return nil, err
}
path := fmt.Sprintf("x/tweets/%s/retweet", url.PathEscape(id))
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...)
return res, err
}
type XTweetRetweetNewResponse struct {
Success bool `json:"success" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Success respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r XTweetRetweetNewResponse) RawJSON() string { return r.JSON.raw }
func (r *XTweetRetweetNewResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type XTweetRetweetDeleteResponse struct {
Success bool `json:"success" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Success respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r XTweetRetweetDeleteResponse) RawJSON() string { return r.JSON.raw }
func (r *XTweetRetweetDeleteResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type XTweetRetweetNewParams struct {
// X account identifier (@username or account ID)
Account string `json:"account" api:"required"`
paramObj
}
func (r XTweetRetweetNewParams) MarshalJSON() (data []byte, err error) {
type shadow XTweetRetweetNewParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *XTweetRetweetNewParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type XTweetRetweetDeleteParams struct {
// X account identifier (@username or account ID)
Account string `json:"account" api:"required"`
paramObj
}
func (r XTweetRetweetDeleteParams) MarshalJSON() (data []byte, err error) {
type shadow XTweetRetweetDeleteParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *XTweetRetweetDeleteParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}