x 0.19.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/CHANGELOG.md +648 -15
- data/README.md +506 -73
- data/SECURITY.md +66 -0
- data/UPGRADING.md +670 -0
- data/lib/x/version.rb +16 -1
- data/lib/x.rb +13 -1
- data/sig/manifest.yaml +5 -0
- data/sig/x.rbs +5 -361
- metadata +57 -49
- data/bin/console +0 -10
- data/bin/setup +0 -6
- data/lib/x/account_uploader.rb +0 -168
- data/lib/x/authenticator.rb +0 -21
- data/lib/x/bearer_token_authenticator.rb +0 -36
- data/lib/x/client.rb +0 -191
- data/lib/x/client_credentials.rb +0 -208
- data/lib/x/connection.rb +0 -183
- data/lib/x/errors/bad_gateway.rb +0 -6
- data/lib/x/errors/bad_request.rb +0 -6
- data/lib/x/errors/client_error.rb +0 -6
- data/lib/x/errors/connection_exception.rb +0 -6
- data/lib/x/errors/error.rb +0 -4
- data/lib/x/errors/forbidden.rb +0 -6
- data/lib/x/errors/gateway_timeout.rb +0 -6
- data/lib/x/errors/gone.rb +0 -6
- data/lib/x/errors/http_error.rb +0 -84
- data/lib/x/errors/internal_server_error.rb +0 -6
- data/lib/x/errors/invalid_media_type.rb +0 -6
- data/lib/x/errors/network_error.rb +0 -6
- data/lib/x/errors/not_acceptable.rb +0 -6
- data/lib/x/errors/not_found.rb +0 -6
- data/lib/x/errors/payload_too_large.rb +0 -6
- data/lib/x/errors/server_error.rb +0 -6
- data/lib/x/errors/service_unavailable.rb +0 -6
- data/lib/x/errors/too_many_redirects.rb +0 -6
- data/lib/x/errors/too_many_requests.rb +0 -58
- data/lib/x/errors/unauthorized.rb +0 -6
- data/lib/x/errors/unprocessable_entity.rb +0 -6
- data/lib/x/media_upload_validator.rb +0 -36
- data/lib/x/media_uploader.rb +0 -234
- data/lib/x/oauth2_authenticator.rb +0 -169
- data/lib/x/oauth_authenticator.rb +0 -182
- data/lib/x/rate_limit.rb +0 -89
- data/lib/x/redirect_handler.rb +0 -109
- data/lib/x/request_builder.rb +0 -93
- data/lib/x/response_parser.rb +0 -81
- data/lib/x/stream_parser.rb +0 -75
data/lib/x/version.rb
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "rubygems/version"
|
|
2
4
|
|
|
3
5
|
module X
|
|
4
6
|
# The current version of the X gem
|
|
5
|
-
|
|
7
|
+
# @api public
|
|
8
|
+
VERSION = "1.0.0"
|
|
9
|
+
|
|
10
|
+
# The version as a Gem::Version, which compares one release with another
|
|
11
|
+
#
|
|
12
|
+
# VERSION is a String, as a version constant is throughout Ruby, so that what reads it can split it, match it, or
|
|
13
|
+
# send it wherever a String belongs, such as the release a crash reporter is told. This builds the Gem::Version
|
|
14
|
+
# that compares it with another version, which a String compares by character rather than by segment.
|
|
15
|
+
#
|
|
16
|
+
# @api public
|
|
17
|
+
# @return [Gem::Version] the version
|
|
18
|
+
# @example Take a path that a later release opened
|
|
19
|
+
# X.gem_version >= Gem::Version.new("1.1")
|
|
20
|
+
def self.gem_version = Gem::Version.new(VERSION)
|
|
6
21
|
end
|
data/lib/x.rb
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "x/core"
|
|
4
|
+
require "x/uploads"
|
|
5
|
+
require "x/streams"
|
|
6
|
+
require "x/resources"
|
|
7
|
+
require_relative "x/version"
|
|
8
|
+
|
|
9
|
+
module X
|
|
10
|
+
Client.include(Resources::API)
|
|
11
|
+
Client.include(Uploads::API)
|
|
12
|
+
Client.include(Streams::API)
|
|
13
|
+
end
|
data/sig/manifest.yaml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# The standard libraries the signatures of x refer to, which rbs collection loads for code that depends on it
|
|
2
|
+
#
|
|
3
|
+
# rbs collection reads every library named here as a standard library, so the gems x depends on are left to their
|
|
4
|
+
# gemspecs, from which it installs their signatures.
|
|
5
|
+
dependencies: []
|
data/sig/x.rbs
CHANGED
|
@@ -1,367 +1,11 @@
|
|
|
1
1
|
module X
|
|
2
|
-
VERSION:
|
|
2
|
+
VERSION: String
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
AUTHENTICATION_HEADER: String
|
|
6
|
-
|
|
7
|
-
def header: (Net::HTTPRequest? request) -> Hash[String, String]
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
class BearerTokenAuthenticator < Authenticator
|
|
11
|
-
attr_accessor bearer_token: String
|
|
12
|
-
def initialize: (bearer_token: String) -> void
|
|
13
|
-
def header: (Net::HTTPRequest? request) -> Hash[String, String]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
class OAuthAuthenticator < Authenticator
|
|
17
|
-
OAUTH_VERSION: String
|
|
18
|
-
OAUTH_SIGNATURE_METHOD: String
|
|
19
|
-
OAUTH_SIGNATURE_ALGORITHM: String
|
|
20
|
-
|
|
21
|
-
attr_accessor api_key: String
|
|
22
|
-
attr_accessor api_key_secret: String
|
|
23
|
-
attr_accessor access_token: String
|
|
24
|
-
attr_accessor access_token_secret: String
|
|
25
|
-
def initialize: (api_key: String, api_key_secret: String, access_token: String, access_token_secret: String) -> void
|
|
26
|
-
def header: (Net::HTTPRequest request) -> Hash[String, String]
|
|
27
|
-
|
|
28
|
-
private
|
|
29
|
-
def parse_request: (Net::HTTPRequest request) -> [String, String, Hash[String, String]]
|
|
30
|
-
def parse_query_params: (String query_string) -> Hash[String, String]
|
|
31
|
-
def uri_without_query: (URI::Generic uri) -> String
|
|
32
|
-
def build_oauth_header: (String method, String url, Hash[String, String] query_params) -> String
|
|
33
|
-
def default_oauth_params: -> Hash[String, String]
|
|
34
|
-
def generate_signature: (String method, String url, Hash[String, String] params) -> String
|
|
35
|
-
def hmac_signature: (String base_string) -> String
|
|
36
|
-
def signature_base_string: (String method, String url, Hash[String, String] params) -> String
|
|
37
|
-
def signing_key: -> String
|
|
38
|
-
def format_oauth_header: (Hash[String, String] params) -> String
|
|
39
|
-
def escape: (String value) -> String
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
class Error < StandardError
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
class ClientError < HTTPError
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
class BadGateway < ClientError
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
class BadRequest < ClientError
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
class ConnectionException < ClientError
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
class HTTPError < Error
|
|
58
|
-
JSON_CONTENT_TYPE_REGEXP: Regexp
|
|
59
|
-
|
|
60
|
-
attr_reader response : Net::HTTPResponse
|
|
61
|
-
attr_reader code : String
|
|
62
|
-
|
|
63
|
-
def initialize: (response: Net::HTTPResponse) -> void
|
|
64
|
-
|
|
65
|
-
private
|
|
66
|
-
def error_message: (Net::HTTPResponse response) -> String
|
|
67
|
-
def message_from_json_response: (Net::HTTPResponse response) -> String
|
|
68
|
-
def json?: (Net::HTTPResponse response) -> bool
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
class Forbidden < ClientError
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
class GatewayTimeout < ClientError
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
class Gone < ClientError
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
class InternalServerError < ServerError
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
class NetworkError < Error
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
class NotAcceptable < ClientError
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
class NotFound < ClientError
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
class PayloadTooLarge < ClientError
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
class ServerError < HTTPError
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
class ServiceUnavailable < ServerError
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
class TooManyRedirects < Error
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
class InvalidMediaType < Error
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
class TooManyRequests < ClientError
|
|
108
|
-
@rate_limits: Array[RateLimit]
|
|
109
|
-
|
|
110
|
-
def rate_limit: -> RateLimit?
|
|
111
|
-
def rate_limits: -> Array[RateLimit]
|
|
112
|
-
def reset_at: -> Time
|
|
113
|
-
def reset_in: -> Integer?
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
class Unauthorized < ClientError
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
class UnprocessableEntity < ClientError
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
class Connection
|
|
123
|
-
DEFAULT_HOST: String
|
|
124
|
-
DEFAULT_PORT: Integer
|
|
125
|
-
DEFAULT_OPEN_TIMEOUT: Integer
|
|
126
|
-
DEFAULT_READ_TIMEOUT: Integer
|
|
127
|
-
DEFAULT_WRITE_TIMEOUT: Integer
|
|
128
|
-
|
|
129
|
-
NETWORK_ERRORS: Array[(singleton(Errno::ECONNREFUSED) | singleton(Errno::ECONNRESET) | singleton(Net::OpenTimeout) | singleton(Net::ReadTimeout) | singleton(OpenSSL::SSL::SSLError))]
|
|
130
|
-
|
|
131
|
-
@proxy_url: URI::Generic | String
|
|
132
|
-
|
|
133
|
-
extend Forwardable
|
|
134
|
-
|
|
135
|
-
attr_accessor open_timeout : Float | Integer
|
|
136
|
-
attr_accessor read_timeout : Float | Integer
|
|
137
|
-
attr_accessor write_timeout : Float | Integer
|
|
138
|
-
attr_accessor debug_output : IO
|
|
139
|
-
|
|
140
|
-
attr_reader proxy_uri: URI::Generic?
|
|
141
|
-
attr_reader proxy_host : String?
|
|
142
|
-
attr_reader proxy_port : Integer?
|
|
143
|
-
attr_reader proxy_user : String?
|
|
144
|
-
attr_reader proxy_pass : String?
|
|
145
|
-
|
|
146
|
-
def initialize: (?open_timeout: Float | Integer, ?read_timeout: Float | Integer, ?write_timeout: Float | Integer, ?proxy_url: URI::Generic? | String?, ?debug_output: IO) -> void
|
|
147
|
-
def proxy_url=: (URI::Generic | String proxy_url) -> void
|
|
148
|
-
def perform: (request: Net::HTTPRequest) -> Net::HTTPResponse
|
|
149
|
-
def perform_stream: (request: Net::HTTPRequest) { (Net::HTTPResponse) -> void } -> void
|
|
150
|
-
|
|
151
|
-
private
|
|
152
|
-
def build_http_client: (?String host, ?Integer port) -> Net::HTTP
|
|
153
|
-
def configure_http_client: (Net::HTTP http_client) -> Net::HTTP
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
class RateLimit
|
|
157
|
-
RATE_LIMIT_TYPE: String
|
|
158
|
-
APP_LIMIT_TYPE: String
|
|
159
|
-
USER_LIMIT_TYPE: String
|
|
160
|
-
TYPES: Array[String]
|
|
161
|
-
|
|
162
|
-
attr_accessor type: String
|
|
163
|
-
attr_accessor response: Net::HTTPResponse
|
|
164
|
-
def initialize: (type: String, response: Net::HTTPResponse) -> void
|
|
165
|
-
def limit: -> Integer
|
|
166
|
-
def remaining: -> Integer
|
|
167
|
-
def reset_at: -> Time
|
|
168
|
-
def reset_in: -> Integer?
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
class RequestBuilder
|
|
172
|
-
HTTP_METHODS: Hash[Symbol, (singleton(Net::HTTP::Get) | singleton(Net::HTTP::Post) | singleton(Net::HTTP::Put) | singleton(Net::HTTP::Delete))]
|
|
173
|
-
DEFAULT_HEADERS: Hash[String, String]
|
|
174
|
-
|
|
175
|
-
def initialize: (?content_type: String, ?user_agent: String) -> void
|
|
176
|
-
def build: (http_method: Symbol, uri: URI::Generic, ?body: String?, ?headers: Hash[String, String], ?authenticator: Authenticator) -> (Net::HTTPRequest)
|
|
177
|
-
|
|
178
|
-
private
|
|
179
|
-
def create_request: (http_method: Symbol, uri: URI::Generic, body: String?) -> (Net::HTTPRequest)
|
|
180
|
-
def add_authentication: (request: Net::HTTPRequest, authenticator: Authenticator) -> void
|
|
181
|
-
def add_headers: (request: Net::HTTPRequest, headers: Hash[String, String]) -> void
|
|
182
|
-
def escape_query_params: (URI::Generic uri) -> URI::Generic
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
class RedirectHandler
|
|
186
|
-
DEFAULT_MAX_REDIRECTS: Integer
|
|
187
|
-
|
|
188
|
-
attr_reader authenticator: Authenticator
|
|
189
|
-
attr_reader connection: Connection
|
|
190
|
-
attr_reader request_builder: RequestBuilder
|
|
191
|
-
attr_reader max_redirects: Integer
|
|
192
|
-
def initialize: (?connection: Connection, ?request_builder: RequestBuilder, ?max_redirects: Integer) -> void
|
|
193
|
-
def handle: (response: Net::HTTPResponse, request: Net::HTTPRequest, base_url: String, ?authenticator: Authenticator, ?redirect_count: Integer) -> Net::HTTPResponse
|
|
194
|
-
|
|
195
|
-
private
|
|
196
|
-
def build_new_uri: (Net::HTTPResponse response, String base_url) -> URI::Generic
|
|
197
|
-
def build_request: (Net::HTTPRequest request, URI::Generic new_uri, Integer response_code, Authenticator authenticator) -> Net::HTTPRequest
|
|
198
|
-
def send_new_request: (URI::Generic new_uri, Net::HTTPRequest new_request) -> Net::HTTPResponse
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
class ResponseParser
|
|
202
|
-
ERROR_MAP: Hash[Integer, singleton(BadGateway) | singleton(BadRequest) | singleton(ConnectionException) | singleton(Forbidden) | singleton(GatewayTimeout) | singleton(Gone) | singleton(InternalServerError) | singleton(NotAcceptable) | singleton(NotFound) | singleton(PayloadTooLarge) | singleton(ServiceUnavailable) | singleton(TooManyRequests) | singleton(Unauthorized) | singleton(UnprocessableEntity)]
|
|
203
|
-
|
|
204
|
-
def parse: (response: Net::HTTPResponse, ?array_class: Class?, ?object_class: Class?) -> untyped
|
|
205
|
-
|
|
206
|
-
private
|
|
207
|
-
def error: (Net::HTTPResponse response) -> HTTPError
|
|
208
|
-
def error_class: (Net::HTTPResponse response) -> (singleton(BadGateway) | singleton(BadRequest) | singleton(ConnectionException) | singleton(Forbidden) | singleton(GatewayTimeout) | singleton(Gone) | singleton(InternalServerError) | singleton(NotAcceptable) | singleton(NotFound) | singleton(PayloadTooLarge) | singleton(ServiceUnavailable) | singleton(TooManyRequests) | singleton(Unauthorized) | singleton(UnprocessableEntity))
|
|
209
|
-
def json?: (Net::HTTPResponse response) -> bool
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
class StreamParser
|
|
213
|
-
LINE_DELIMITER: String
|
|
214
|
-
|
|
215
|
-
def process: (response: Net::HTTPResponse, response_parser: ResponseParser, ?array_class: Class?, ?object_class: Class?) { (untyped) -> void } -> void
|
|
216
|
-
|
|
217
|
-
private
|
|
218
|
-
def process_buffer: (buffer: String, array_class: Class?, object_class: Class?) { (untyped) -> void } -> void
|
|
219
|
-
def process_remaining: (buffer: String, array_class: Class?, object_class: Class?) { (untyped) -> void } -> void
|
|
220
|
-
def yield_json: (line: String, array_class: Class?, object_class: Class?) { (untyped) -> void } -> void
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
class OAuth2Authenticator < Authenticator
|
|
224
|
-
TOKEN_PATH: String
|
|
225
|
-
TOKEN_HOST: String
|
|
226
|
-
REFRESH_GRANT_TYPE: String
|
|
227
|
-
EXPIRATION_BUFFER: Integer
|
|
228
|
-
|
|
229
|
-
attr_accessor client_id: String
|
|
230
|
-
attr_accessor client_secret: String
|
|
231
|
-
attr_accessor access_token: String
|
|
232
|
-
attr_accessor refresh_token: String
|
|
233
|
-
attr_accessor expires_at: Time?
|
|
234
|
-
attr_accessor connection: Connection
|
|
235
|
-
def initialize: (client_id: String, client_secret: String, access_token: String, refresh_token: String, ?expires_at: Time?, ?connection: Connection) -> void
|
|
236
|
-
def header: (Net::HTTPRequest? request) -> Hash[String, String]
|
|
237
|
-
def token_expired?: -> bool
|
|
238
|
-
def refresh_token!: -> Hash[String, untyped]
|
|
239
|
-
|
|
240
|
-
private
|
|
241
|
-
def send_token_request: -> Net::HTTPResponse
|
|
242
|
-
def build_token_request: -> Net::HTTP::Post
|
|
243
|
-
def handle_token_response: (Net::HTTPResponse response) -> Hash[String, untyped]
|
|
244
|
-
def update_tokens: (Hash[String, untyped] token_response) -> void
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
module ClientCredentials
|
|
248
|
-
attr_reader api_key: String?
|
|
249
|
-
attr_reader api_key_secret: String?
|
|
250
|
-
attr_reader access_token: String?
|
|
251
|
-
attr_reader access_token_secret: String?
|
|
252
|
-
attr_reader bearer_token: String?
|
|
253
|
-
attr_reader client_id: String?
|
|
254
|
-
attr_reader client_secret: String?
|
|
255
|
-
attr_reader refresh_token: String?
|
|
256
|
-
def api_key=: (String api_key) -> void
|
|
257
|
-
def api_key_secret=: (String api_key_secret) -> void
|
|
258
|
-
def access_token=: (String access_token) -> void
|
|
259
|
-
def access_token_secret=: (String access_token_secret) -> void
|
|
260
|
-
def bearer_token=: (String bearer_token) -> void
|
|
261
|
-
def client_id=: (String client_id) -> void
|
|
262
|
-
def client_secret=: (String client_secret) -> void
|
|
263
|
-
def refresh_token=: (String refresh_token) -> void
|
|
264
|
-
|
|
265
|
-
private
|
|
266
|
-
def initialize_credentials: (api_key: String?, api_key_secret: String?, access_token: String?, access_token_secret: String?, bearer_token: String?, client_id: String?, client_secret: String?, refresh_token: String?) -> void
|
|
267
|
-
def initialize_authenticator: -> (Authenticator | BearerTokenAuthenticator | OAuthAuthenticator | OAuth2Authenticator)
|
|
268
|
-
def oauth_authenticator: -> OAuthAuthenticator?
|
|
269
|
-
def oauth2_authenticator: -> OAuth2Authenticator?
|
|
270
|
-
def bearer_authenticator: -> BearerTokenAuthenticator?
|
|
271
|
-
end
|
|
4
|
+
def self.gem_version: () -> Gem::Version
|
|
272
5
|
|
|
273
6
|
class Client
|
|
274
|
-
include
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
DEFAULT_ARRAY_CLASS: singleton(Array)
|
|
278
|
-
DEFAULT_OBJECT_CLASS: singleton(Hash)
|
|
279
|
-
extend Forwardable
|
|
280
|
-
@authenticator: Authenticator | BearerTokenAuthenticator | OAuthAuthenticator | OAuth2Authenticator
|
|
281
|
-
@connection: Connection
|
|
282
|
-
@request_builder: RequestBuilder
|
|
283
|
-
@redirect_handler: RedirectHandler
|
|
284
|
-
@response_parser: ResponseParser
|
|
285
|
-
@stream_parser: StreamParser
|
|
286
|
-
|
|
287
|
-
attr_accessor base_url: String
|
|
288
|
-
attr_accessor default_array_class: singleton(Array)
|
|
289
|
-
attr_accessor default_object_class: singleton(Hash)
|
|
290
|
-
attr_reader authenticator: Authenticator | BearerTokenAuthenticator | OAuthAuthenticator | OAuth2Authenticator
|
|
291
|
-
def initialize: (?api_key: String?, ?api_key_secret: String?, ?access_token: String?, ?access_token_secret: String?, ?bearer_token: String?, ?client_id: String?, ?client_secret: String?, ?refresh_token: String?, ?base_url: String, ?open_timeout: Integer, ?read_timeout: Integer, ?write_timeout: Integer, ?debug_output: untyped, ?proxy_url: String?, ?default_array_class: singleton(Array), ?default_object_class: singleton(Hash), ?max_redirects: Integer) -> void
|
|
292
|
-
def get: (String endpoint, ?headers: Hash[String, String], ?array_class: Class, ?object_class: Class) -> untyped
|
|
293
|
-
def post: (String endpoint, ?String? body, ?headers: Hash[String, String], ?array_class: Class, ?object_class: Class) -> untyped
|
|
294
|
-
def put: (String endpoint, ?String? body, ?headers: Hash[String, String], ?array_class: Class, ?object_class: Class) -> untyped
|
|
295
|
-
def delete: (String endpoint, ?headers: Hash[String, String], ?array_class: Class, ?object_class: Class) -> untyped
|
|
296
|
-
def stream: (String endpoint, ?headers: Hash[String, String], ?array_class: Class, ?object_class: Class) { (untyped) -> void } -> void
|
|
297
|
-
|
|
298
|
-
private
|
|
299
|
-
def initialize_default_classes: (default_array_class: singleton(Array), default_object_class: singleton(Hash)) -> void
|
|
300
|
-
def execute_request: (:delete | :get | :post | :put http_method, String endpoint, ?body: String?, ?headers: Hash[String, String], ?array_class: Class, ?object_class: Class) -> nil
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
module MediaUploader
|
|
304
|
-
MAX_RETRIES: Integer
|
|
305
|
-
BYTES_PER_MB: Integer
|
|
306
|
-
DM_GIF: String
|
|
307
|
-
DM_IMAGE: String
|
|
308
|
-
DM_VIDEO: String
|
|
309
|
-
SUBTITLES: String
|
|
310
|
-
TWEET_GIF: String
|
|
311
|
-
TWEET_IMAGE: String
|
|
312
|
-
TWEET_VIDEO: String
|
|
313
|
-
MIME_TYPES: Array[String]
|
|
314
|
-
GIF_MIME_TYPE: String
|
|
315
|
-
JPEG_MIME_TYPE: String
|
|
316
|
-
MP4_MIME_TYPE: String
|
|
317
|
-
PNG_MIME_TYPE: String
|
|
318
|
-
SUBRIP_MIME_TYPE: String
|
|
319
|
-
WEBP_MIME_TYPE: String
|
|
320
|
-
MIME_TYPE_MAP: Hash[String, String]
|
|
321
|
-
PROCESSING_INFO_STATES: Array[String]
|
|
322
|
-
extend MediaUploader
|
|
323
|
-
|
|
324
|
-
def upload: (client: Client, file_path: String, media_category: String, ?boundary: String) -> untyped
|
|
325
|
-
def upload_binary: (client: Client, content: String, media_category: String, ?boundary: String) -> untyped
|
|
326
|
-
def chunked_upload: (client: Client, file_path: String, media_category: String, ?media_type: String, ?boundary: String, ?chunk_size_mb: Integer) -> untyped
|
|
327
|
-
def await_processing: (client: Client, media: untyped) -> untyped
|
|
328
|
-
def await_processing!: (client: Client, media: untyped) -> untyped
|
|
329
|
-
def infer_media_type: (String file_path, String media_category) -> String
|
|
330
|
-
|
|
331
|
-
private
|
|
332
|
-
def split: (String file_path, Integer chunk_size) -> Array[String]
|
|
333
|
-
def init: (client: Client, file_path: String, media_type: String, media_category: String) -> untyped
|
|
334
|
-
def append: (client: Client, file_paths: Array[String], media: untyped, ?boundary: String) -> Array[String]
|
|
335
|
-
def upload_chunk: (client: Client, media_id: String, upload_body: String, file_path: String, ?headers: Hash[String, String]) -> Integer?
|
|
336
|
-
def cleanup_file: (String file_path) -> Integer?
|
|
337
|
-
def finalize: (client: Client, media: untyped) -> untyped
|
|
338
|
-
def construct_upload_body: (content: String, ?media_category: String, ?segment_index: Integer, ?boundary: String) -> String
|
|
339
|
-
end
|
|
340
|
-
|
|
341
|
-
module MediaUploadValidator
|
|
342
|
-
MEDIA_CATEGORIES: Array[String]
|
|
343
|
-
extend MediaUploadValidator
|
|
344
|
-
|
|
345
|
-
def validate_file_path!: (file_path: String) -> nil
|
|
346
|
-
def validate_media_category!: (media_category: String) -> nil
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
module AccountUploader
|
|
350
|
-
V1_BASE_URL: String
|
|
351
|
-
SUPPORTED_EXTENSIONS: Array[String]
|
|
352
|
-
MIME_TYPE_MAP: Hash[String, String]
|
|
353
|
-
extend AccountUploader
|
|
354
|
-
|
|
355
|
-
def update_profile_image: (client: Client, file_path: String, ?boundary: String) -> untyped
|
|
356
|
-
def upload_profile_image_binary: (client: Client, content: String, ?boundary: String) -> untyped
|
|
357
|
-
def update_profile_banner: (client: Client, file_path: String, ?width: Integer?, ?height: Integer?, ?offset_left: Integer?, ?offset_top: Integer?, ?boundary: String) -> untyped
|
|
358
|
-
def upload_profile_banner_binary: (client: Client, content: String, ?width: Integer?, ?height: Integer?, ?offset_left: Integer?, ?offset_top: Integer?, ?boundary: String) -> untyped
|
|
359
|
-
|
|
360
|
-
private
|
|
361
|
-
def v1_client: (Client client) -> Client
|
|
362
|
-
def validate_file!: (String file_path) -> nil
|
|
363
|
-
def construct_multipart_body: (field_name: String, content: String, boundary: String) -> String
|
|
364
|
-
def construct_banner_body: (content: String, width: Integer?, height: Integer?, offset_left: Integer?, offset_top: Integer?, boundary: String) -> String
|
|
365
|
-
def multipart_field: (String name, untyped value, String boundary) -> String
|
|
7
|
+
include Resources::API
|
|
8
|
+
include Uploads::API
|
|
9
|
+
include Streams::API
|
|
366
10
|
end
|
|
367
11
|
end
|
metadata
CHANGED
|
@@ -1,77 +1,85 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: x
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik Berlin
|
|
8
|
-
bindir:
|
|
8
|
+
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
13
|
+
name: x-core
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- -
|
|
16
|
+
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 1.0.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
|
-
- -
|
|
23
|
+
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
25
|
+
version: 1.0.0
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: x-uploads
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - '='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 1.0.0
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - '='
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 1.0.0
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: x-streams
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - '='
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 1.0.0
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - '='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 1.0.0
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: x-resources
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - '='
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 1.0.0
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - '='
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: 1.0.0
|
|
26
68
|
email:
|
|
27
69
|
- sferik@gmail.com
|
|
28
70
|
executables: []
|
|
29
71
|
extensions: []
|
|
30
72
|
extra_rdoc_files: []
|
|
31
73
|
files:
|
|
74
|
+
- ".yardopts"
|
|
32
75
|
- CHANGELOG.md
|
|
33
76
|
- LICENSE.txt
|
|
34
77
|
- README.md
|
|
35
|
-
-
|
|
36
|
-
-
|
|
78
|
+
- SECURITY.md
|
|
79
|
+
- UPGRADING.md
|
|
37
80
|
- lib/x.rb
|
|
38
|
-
- lib/x/account_uploader.rb
|
|
39
|
-
- lib/x/authenticator.rb
|
|
40
|
-
- lib/x/bearer_token_authenticator.rb
|
|
41
|
-
- lib/x/client.rb
|
|
42
|
-
- lib/x/client_credentials.rb
|
|
43
|
-
- lib/x/connection.rb
|
|
44
|
-
- lib/x/errors/bad_gateway.rb
|
|
45
|
-
- lib/x/errors/bad_request.rb
|
|
46
|
-
- lib/x/errors/client_error.rb
|
|
47
|
-
- lib/x/errors/connection_exception.rb
|
|
48
|
-
- lib/x/errors/error.rb
|
|
49
|
-
- lib/x/errors/forbidden.rb
|
|
50
|
-
- lib/x/errors/gateway_timeout.rb
|
|
51
|
-
- lib/x/errors/gone.rb
|
|
52
|
-
- lib/x/errors/http_error.rb
|
|
53
|
-
- lib/x/errors/internal_server_error.rb
|
|
54
|
-
- lib/x/errors/invalid_media_type.rb
|
|
55
|
-
- lib/x/errors/network_error.rb
|
|
56
|
-
- lib/x/errors/not_acceptable.rb
|
|
57
|
-
- lib/x/errors/not_found.rb
|
|
58
|
-
- lib/x/errors/payload_too_large.rb
|
|
59
|
-
- lib/x/errors/server_error.rb
|
|
60
|
-
- lib/x/errors/service_unavailable.rb
|
|
61
|
-
- lib/x/errors/too_many_redirects.rb
|
|
62
|
-
- lib/x/errors/too_many_requests.rb
|
|
63
|
-
- lib/x/errors/unauthorized.rb
|
|
64
|
-
- lib/x/errors/unprocessable_entity.rb
|
|
65
|
-
- lib/x/media_upload_validator.rb
|
|
66
|
-
- lib/x/media_uploader.rb
|
|
67
|
-
- lib/x/oauth2_authenticator.rb
|
|
68
|
-
- lib/x/oauth_authenticator.rb
|
|
69
|
-
- lib/x/rate_limit.rb
|
|
70
|
-
- lib/x/redirect_handler.rb
|
|
71
|
-
- lib/x/request_builder.rb
|
|
72
|
-
- lib/x/response_parser.rb
|
|
73
|
-
- lib/x/stream_parser.rb
|
|
74
81
|
- lib/x/version.rb
|
|
82
|
+
- sig/manifest.yaml
|
|
75
83
|
- sig/x.rbs
|
|
76
84
|
homepage: https://sferik.github.io/x-ruby
|
|
77
85
|
licenses:
|
|
@@ -79,8 +87,8 @@ licenses:
|
|
|
79
87
|
metadata:
|
|
80
88
|
allowed_push_host: https://rubygems.org
|
|
81
89
|
bug_tracker_uri: https://github.com/sferik/x-ruby/issues
|
|
82
|
-
changelog_uri: https://github.com/sferik/x-ruby/blob/
|
|
83
|
-
documentation_uri: https://
|
|
90
|
+
changelog_uri: https://github.com/sferik/x-ruby/blob/main/CHANGELOG.md
|
|
91
|
+
documentation_uri: https://sferik.github.io/x-ruby/api/
|
|
84
92
|
funding_uri: https://github.com/sponsors/sferik/
|
|
85
93
|
homepage_uri: https://sferik.github.io/x-ruby
|
|
86
94
|
rubygems_mfa_required: 'true'
|
|
@@ -92,14 +100,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
92
100
|
requirements:
|
|
93
101
|
- - ">="
|
|
94
102
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '3.
|
|
103
|
+
version: '3.4'
|
|
96
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
105
|
requirements:
|
|
98
106
|
- - ">="
|
|
99
107
|
- !ruby/object:Gem::Version
|
|
100
108
|
version: '0'
|
|
101
109
|
requirements: []
|
|
102
|
-
rubygems_version: 4.0.
|
|
110
|
+
rubygems_version: 4.0.21
|
|
103
111
|
specification_version: 4
|
|
104
112
|
summary: A Ruby interface to the X API.
|
|
105
113
|
test_files: []
|
data/bin/console
DELETED