api-generator 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a140a5dadd45d555260b30f52d6d837c9b15533fb53d4470295ee2660568c704
4
+ data.tar.gz: 5f33f87739b38ef57fd49528fd77bd28dd3416cf7a637055c734954069a209b2
5
+ SHA512:
6
+ metadata.gz: 54758dffffe9e86aac09cda047b6bef2b4e337e9e63d5cb4ef1e9019116153f5f6805075b4fff2daafc6f6a6d93a300fe01e9acea8d59389e0820279410530d2
7
+ data.tar.gz: 39f53e64a8a96bdd46d45181c083f7c43fbee01b1c8af524288733fe5c41fa6b20f1b09082e874859aa685d9eecd8e7c7cff387261324d81b5fbb4e0bbab79c8
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'faraday'
4
+
5
+ gem 'sorbet', group: :development
6
+ gem 'sorbet-runtime'
@@ -0,0 +1,21 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ faraday (0.17.0)
5
+ multipart-post (>= 1.2, < 3)
6
+ multipart-post (2.1.1)
7
+ sorbet (0.4.5049)
8
+ sorbet-static (= 0.4.5049)
9
+ sorbet-runtime (0.4.5049)
10
+ sorbet-static (0.4.5049-universal-darwin-14)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ faraday
17
+ sorbet
18
+ sorbet-runtime
19
+
20
+ BUNDLED WITH
21
+ 1.17.3
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'api_generator/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'api-generator'
7
+ spec.version = ApiGenerator::VERSION
8
+ spec.authors = ['Kyle Hiller']
9
+ spec.email = ['kyle.r.hiller@gmail.com']
10
+ spec.summary = 'Generates API calls to Faraday using metaprogramming'
11
+ spec.license = 'MIT'
12
+
13
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
14
+ f.match(%r{^(test|spec|features|rbi)/})
15
+ end
16
+
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'faraday'
22
+ spec.add_dependency 'sorbet-runtime'
23
+
24
+ spec.add_development_dependency 'sorbet'
25
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ require 'api_generator/client'
5
+ require 'api_generator/url'
6
+ require 'api_generator/version'
7
+
8
+ module ApiGenerator
9
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module ApiGenerator
5
+ class Client
6
+ extend T::Sig
7
+
8
+ attr_reader :url
9
+ attr_accessor :rest_method
10
+
11
+ REST_METHODS = %i[
12
+ put
13
+ get
14
+ patch
15
+ delete
16
+ post
17
+ ]
18
+
19
+ sig { params(url: ApiGenerator::Url, rest_method: Symbol).void }
20
+ def initialize(url: ApiGenerator::Url.new(""), rest_method: :get)
21
+ @url = T.let(url, ApiGenerator::Url)
22
+ @rest_method = T.let(rest_method, Symbol)
23
+ end
24
+
25
+
26
+ sig { params(options: T::Hash[Symbol, T.any(String, Symbol, Integer, Date, OpenSSL::ASN1::Boolean)]).returns(Faraday::Response) }
27
+ def execute(options)
28
+ Faraday.send(rest_method) do |req|
29
+ req.params = options
30
+ req.url = url.url
31
+ end
32
+ end
33
+
34
+ sig { params(method: Symbol, args: T.untyped, block: T.nilable(T.proc.void)).returns(T.self_type) }
35
+ def method_missing(method, *args, &block)
36
+ if REST_METHODS.any?(method)
37
+ return ApiGenerator::Client.new(url: url, rest_method: method)
38
+ end
39
+
40
+ ApiGenerator::Client.new(url: ApiGenerator::Url.send(url), rest_method: rest_method)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module ApiGenerator
5
+ class Url
6
+ extend T::Sig
7
+
8
+ attr_reader :url
9
+
10
+ sig { params(url: String).void }
11
+
12
+ def initialize(url)
13
+ @url = url
14
+ end
15
+
16
+ sig { params(method: Symbol, args: T.untyped, block: T.nilable(T.proc.void)).returns(T.self_type) }
17
+ def method_missing(method, *args, &block)
18
+ ApiGenerator::Url.new(File.join(url, method))
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module ApiGenerator
5
+ VERSION = '0.0.2'
6
+ end
@@ -0,0 +1,2 @@
1
+ --dir
2
+ .
@@ -0,0 +1,531 @@
1
+ # This file is autogenerated. Do not edit it by hand. Regenerate it with:
2
+ # srb rbi gems
3
+
4
+ # typed: true
5
+ #
6
+ # If you would like to make changes to this file, great! Please create the gem's shim here:
7
+ #
8
+ # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/faraday/all/faraday.rbi
9
+ #
10
+ # faraday-0.17.0
11
+ module Faraday
12
+ def self.const_missing(name); end
13
+ def self.default_adapter; end
14
+ def self.default_adapter=(adapter); end
15
+ def self.default_connection; end
16
+ def self.default_connection=(arg0); end
17
+ def self.default_connection_options; end
18
+ def self.default_connection_options=(options); end
19
+ def self.ignore_env_proxy; end
20
+ def self.ignore_env_proxy=(arg0); end
21
+ def self.lib_path; end
22
+ def self.lib_path=(arg0); end
23
+ def self.method_missing(name, *args, &block); end
24
+ def self.new(url = nil, options = nil); end
25
+ def self.require_lib(*libs); end
26
+ def self.require_libs(*libs); end
27
+ def self.respond_to?(symbol, include_private = nil); end
28
+ def self.root_path; end
29
+ def self.root_path=(arg0); end
30
+ end
31
+ module Faraday::Utils
32
+ def URI(url); end
33
+ def build_nested_query(params); end
34
+ def build_query(params); end
35
+ def deep_merge!(target, hash); end
36
+ def deep_merge(source, hash); end
37
+ def default_params_encoder; end
38
+ def default_uri_parser; end
39
+ def default_uri_parser=(parser); end
40
+ def escape(s); end
41
+ def normalize_params(params, name, v = nil); end
42
+ def normalize_path(url); end
43
+ def parse_nested_query(query); end
44
+ def parse_query(query); end
45
+ def self.default_params_encoder=(arg0); end
46
+ def sort_query_params(query); end
47
+ def unescape(s); end
48
+ extend Faraday::Utils
49
+ end
50
+ class Faraday::Utils::Headers < Hash
51
+ def [](k); end
52
+ def []=(k, v); end
53
+ def delete(k); end
54
+ def fetch(k, *args, &block); end
55
+ def has_key?(k); end
56
+ def include?(k); end
57
+ def initialize(hash = nil); end
58
+ def initialize_copy(other); end
59
+ def initialize_names; end
60
+ def key?(k); end
61
+ def member?(k); end
62
+ def merge!(other); end
63
+ def merge(other); end
64
+ def names; end
65
+ def parse(header_string); end
66
+ def replace(other); end
67
+ def self.allocate; end
68
+ def self.from(value); end
69
+ def to_hash; end
70
+ def update(other); end
71
+ end
72
+ class Faraday::Utils::ParamsHash < Hash
73
+ def [](key); end
74
+ def []=(key, value); end
75
+ def convert_key(key); end
76
+ def delete(key); end
77
+ def has_key?(key); end
78
+ def include?(key); end
79
+ def key?(key); end
80
+ def member?(key); end
81
+ def merge!(params); end
82
+ def merge(params); end
83
+ def merge_query(query, encoder = nil); end
84
+ def replace(other); end
85
+ def to_query(encoder = nil); end
86
+ def update(params); end
87
+ end
88
+ class Faraday::Options < Struct
89
+ def [](key); end
90
+ def clear; end
91
+ def deep_dup; end
92
+ def delete(key); end
93
+ def each; end
94
+ def each_key; end
95
+ def each_value; end
96
+ def empty?; end
97
+ def fetch(key, *args); end
98
+ def has_key?(key); end
99
+ def has_value?(value); end
100
+ def inspect; end
101
+ def key?(key); end
102
+ def keys; end
103
+ def merge!(other); end
104
+ def merge(other); end
105
+ def self.attribute_options; end
106
+ def self.fetch_error_class; end
107
+ def self.from(value); end
108
+ def self.inherited(subclass); end
109
+ def self.memoized(key); end
110
+ def self.memoized_attributes; end
111
+ def self.options(mapping); end
112
+ def self.options_for(key); end
113
+ def symbolized_key_set; end
114
+ def to_hash; end
115
+ def update(obj); end
116
+ def value?(value); end
117
+ def values_at(*keys); end
118
+ end
119
+ class Anonymous_Faraday_Options_1 < Faraday::Options
120
+ def bind; end
121
+ def bind=(_); end
122
+ def boundary; end
123
+ def boundary=(_); end
124
+ def context; end
125
+ def context=(_); end
126
+ def oauth; end
127
+ def oauth=(_); end
128
+ def open_timeout; end
129
+ def open_timeout=(_); end
130
+ def params_encoder; end
131
+ def params_encoder=(_); end
132
+ def proxy; end
133
+ def proxy=(_); end
134
+ def self.[](*arg0); end
135
+ def self.inspect; end
136
+ def self.members; end
137
+ def self.new(*arg0); end
138
+ def timeout; end
139
+ def timeout=(_); end
140
+ def write_timeout; end
141
+ def write_timeout=(_); end
142
+ end
143
+ class Faraday::RequestOptions < Anonymous_Faraday_Options_1
144
+ def []=(key, value); end
145
+ end
146
+ class Anonymous_Faraday_Options_2 < Faraday::Options
147
+ def ca_file; end
148
+ def ca_file=(_); end
149
+ def ca_path; end
150
+ def ca_path=(_); end
151
+ def cert_store; end
152
+ def cert_store=(_); end
153
+ def certificate; end
154
+ def certificate=(_); end
155
+ def client_cert; end
156
+ def client_cert=(_); end
157
+ def client_key; end
158
+ def client_key=(_); end
159
+ def max_version; end
160
+ def max_version=(_); end
161
+ def min_version; end
162
+ def min_version=(_); end
163
+ def private_key; end
164
+ def private_key=(_); end
165
+ def self.[](*arg0); end
166
+ def self.inspect; end
167
+ def self.members; end
168
+ def self.new(*arg0); end
169
+ def verify; end
170
+ def verify=(_); end
171
+ def verify_depth; end
172
+ def verify_depth=(_); end
173
+ def verify_mode; end
174
+ def verify_mode=(_); end
175
+ def version; end
176
+ def version=(_); end
177
+ end
178
+ class Faraday::SSLOptions < Anonymous_Faraday_Options_2
179
+ def disable?; end
180
+ def verify?; end
181
+ end
182
+ class Anonymous_Faraday_Options_3 < Faraday::Options
183
+ def password; end
184
+ def password=(_); end
185
+ def self.[](*arg0); end
186
+ def self.inspect; end
187
+ def self.members; end
188
+ def self.new(*arg0); end
189
+ def uri; end
190
+ def uri=(_); end
191
+ def user; end
192
+ def user=(_); end
193
+ end
194
+ class Faraday::ProxyOptions < Anonymous_Faraday_Options_3
195
+ def host(*args, &block); end
196
+ def host=(*args, &block); end
197
+ def password; end
198
+ def path(*args, &block); end
199
+ def path=(*args, &block); end
200
+ def port(*args, &block); end
201
+ def port=(*args, &block); end
202
+ def scheme(*args, &block); end
203
+ def scheme=(*args, &block); end
204
+ def self.from(value); end
205
+ def user; end
206
+ extend Forwardable
207
+ end
208
+ class Anonymous_Faraday_Options_4 < Faraday::Options
209
+ def builder; end
210
+ def builder=(_); end
211
+ def builder_class; end
212
+ def builder_class=(_); end
213
+ def headers; end
214
+ def headers=(_); end
215
+ def parallel_manager; end
216
+ def parallel_manager=(_); end
217
+ def params; end
218
+ def params=(_); end
219
+ def proxy; end
220
+ def proxy=(_); end
221
+ def request; end
222
+ def request=(_); end
223
+ def self.[](*arg0); end
224
+ def self.inspect; end
225
+ def self.members; end
226
+ def self.new(*arg0); end
227
+ def ssl; end
228
+ def ssl=(_); end
229
+ def url; end
230
+ def url=(_); end
231
+ end
232
+ class Faraday::ConnectionOptions < Anonymous_Faraday_Options_4
233
+ def builder_class; end
234
+ def new_builder(block); end
235
+ def request; end
236
+ def ssl; end
237
+ end
238
+ class Anonymous_Faraday_Options_5 < Faraday::Options
239
+ def body; end
240
+ def body=(_); end
241
+ def method; end
242
+ def method=(_); end
243
+ def parallel_manager; end
244
+ def parallel_manager=(_); end
245
+ def params; end
246
+ def params=(_); end
247
+ def reason_phrase; end
248
+ def reason_phrase=(_); end
249
+ def request; end
250
+ def request=(_); end
251
+ def request_headers; end
252
+ def request_headers=(_); end
253
+ def response; end
254
+ def response=(_); end
255
+ def response_headers; end
256
+ def response_headers=(_); end
257
+ def self.[](*arg0); end
258
+ def self.inspect; end
259
+ def self.members; end
260
+ def self.new(*arg0); end
261
+ def ssl; end
262
+ def ssl=(_); end
263
+ def status; end
264
+ def status=(_); end
265
+ def url; end
266
+ def url=(_); end
267
+ end
268
+ class Faraday::Env < Anonymous_Faraday_Options_5
269
+ def [](key); end
270
+ def []=(key, value); end
271
+ def clear_body; end
272
+ def custom_members; end
273
+ def in_member_set?(key); end
274
+ def inspect; end
275
+ def needs_body?; end
276
+ def parallel?; end
277
+ def params_encoder(*args, &block); end
278
+ def parse_body?; end
279
+ def self.from(value); end
280
+ def self.member_set; end
281
+ def success?; end
282
+ extend Forwardable
283
+ end
284
+ class Faraday::Connection
285
+ def adapter(*args, &block); end
286
+ def app(*args, &block); end
287
+ def authorization(type, token); end
288
+ def basic_auth(login, pass); end
289
+ def build(*args, &block); end
290
+ def build_exclusive_url(url = nil, params = nil, params_encoder = nil); end
291
+ def build_request(method); end
292
+ def build_url(url = nil, extra_params = nil); end
293
+ def builder; end
294
+ def default_parallel_manager; end
295
+ def default_parallel_manager=(arg0); end
296
+ def delete(url = nil, params = nil, headers = nil); end
297
+ def dup; end
298
+ def find_default_proxy; end
299
+ def get(url = nil, params = nil, headers = nil); end
300
+ def head(url = nil, params = nil, headers = nil); end
301
+ def headers; end
302
+ def headers=(hash); end
303
+ def host(*args, &block); end
304
+ def host=(*args, &block); end
305
+ def in_parallel(manager = nil); end
306
+ def in_parallel?; end
307
+ def initialize(url = nil, options = nil); end
308
+ def options; end
309
+ def parallel_manager; end
310
+ def params; end
311
+ def params=(hash); end
312
+ def patch(url = nil, body = nil, headers = nil, &block); end
313
+ def path_prefix(*args, &block); end
314
+ def path_prefix=(value); end
315
+ def port(*args, &block); end
316
+ def port=(*args, &block); end
317
+ def post(url = nil, body = nil, headers = nil, &block); end
318
+ def proxy(arg = nil); end
319
+ def proxy=(new_value); end
320
+ def proxy_for_request(url); end
321
+ def proxy_from_env(url); end
322
+ def put(url = nil, body = nil, headers = nil, &block); end
323
+ def request(*args, &block); end
324
+ def response(*args, &block); end
325
+ def run_request(method, url, body, headers); end
326
+ def scheme(*args, &block); end
327
+ def scheme=(*args, &block); end
328
+ def set_authorization_header(header_type, *args); end
329
+ def ssl; end
330
+ def token_auth(token, options = nil); end
331
+ def url_prefix; end
332
+ def url_prefix=(url, encoder = nil); end
333
+ def use(*args, &block); end
334
+ def with_uri_credentials(uri); end
335
+ extend Forwardable
336
+ end
337
+ class Faraday::RackBuilder
338
+ def ==(other); end
339
+ def [](idx); end
340
+ def adapter(key, *args, &block); end
341
+ def adapter_set?; end
342
+ def app; end
343
+ def assert_index(index); end
344
+ def build(options = nil); end
345
+ def build_env(connection, request); end
346
+ def build_response(connection, request); end
347
+ def delete(handler); end
348
+ def dup; end
349
+ def handlers; end
350
+ def handlers=(arg0); end
351
+ def initialize(handlers = nil); end
352
+ def insert(index, *args, &block); end
353
+ def insert_after(index, *args, &block); end
354
+ def insert_before(index, *args, &block); end
355
+ def inserting_after_adapter?(index); end
356
+ def is_adapter?(handler); end
357
+ def lock!; end
358
+ def locked?; end
359
+ def raise_if_locked; end
360
+ def request(key, *args, &block); end
361
+ def response(key, *args, &block); end
362
+ def swap(index, *args, &block); end
363
+ def to_app(inner_app); end
364
+ def use(klass, *args, &block); end
365
+ def use_symbol(mod, key, *args, &block); end
366
+ def warn_middleware_after_adapter; end
367
+ end
368
+ class Faraday::RackBuilder::StackLocked < RuntimeError
369
+ end
370
+ class Faraday::RackBuilder::Handler
371
+ def ==(other); end
372
+ def build(app); end
373
+ def initialize(klass, *args, &block); end
374
+ def inspect; end
375
+ def klass; end
376
+ def name; end
377
+ end
378
+ module Faraday::NestedParamsEncoder
379
+ def self.decode(query); end
380
+ def self.dehash(hash, depth); end
381
+ def self.encode(params); end
382
+ def self.escape(*args, &block); end
383
+ def self.unescape(*args, &block); end
384
+ end
385
+ module Faraday::FlatParamsEncoder
386
+ def self.decode(query); end
387
+ def self.encode(params); end
388
+ def self.escape(*args, &block); end
389
+ def self.unescape(*args, &block); end
390
+ end
391
+ class Faraday::Middleware
392
+ def initialize(app = nil); end
393
+ def self.dependency(lib = nil); end
394
+ def self.inherited(subclass); end
395
+ def self.load_error; end
396
+ def self.load_error=(arg0); end
397
+ def self.loaded?; end
398
+ def self.new(*arg0); end
399
+ extend Faraday::MiddlewareRegistry
400
+ end
401
+ class Faraday::Adapter < Faraday::Middleware
402
+ def call(env); end
403
+ def initialize(app = nil, opts = nil, &block); end
404
+ def save_response(env, status, body, headers = nil, reason_phrase = nil); end
405
+ extend Faraday::Adapter::Parallelism
406
+ extend Faraday::AutoloadHelper
407
+ end
408
+ module Faraday::Adapter::Parallelism
409
+ def inherited(subclass); end
410
+ def supports_parallel=(arg0); end
411
+ def supports_parallel?; end
412
+ end
413
+ class Anonymous_Struct_6 < Struct
414
+ def body; end
415
+ def body=(_); end
416
+ def headers; end
417
+ def headers=(_); end
418
+ def method; end
419
+ def method=(_); end
420
+ def options; end
421
+ def options=(_); end
422
+ def params; end
423
+ def params=(_); end
424
+ def path; end
425
+ def path=(_); end
426
+ def self.[](*arg0); end
427
+ def self.inspect; end
428
+ def self.members; end
429
+ def self.new(*arg0); end
430
+ end
431
+ class Faraday::Request < Anonymous_Struct_6
432
+ def [](key); end
433
+ def []=(key, value); end
434
+ def headers=(hash); end
435
+ def marshal_dump; end
436
+ def marshal_load(serialised); end
437
+ def params=(hash); end
438
+ def self.create(request_method); end
439
+ def to_env(connection); end
440
+ def url(path, params = nil); end
441
+ extend Faraday::AutoloadHelper
442
+ extend Faraday::MiddlewareRegistry
443
+ end
444
+ class Faraday::Response
445
+ def [](*args, &block); end
446
+ def apply_request(request_env); end
447
+ def body; end
448
+ def env; end
449
+ def finish(env); end
450
+ def finished?; end
451
+ def headers; end
452
+ def initialize(env = nil); end
453
+ def marshal_dump; end
454
+ def marshal_load(env); end
455
+ def on_complete; end
456
+ def reason_phrase; end
457
+ def status; end
458
+ def success?; end
459
+ def to_hash(*args, &block); end
460
+ extend Faraday::AutoloadHelper
461
+ extend Faraday::MiddlewareRegistry
462
+ extend Forwardable
463
+ end
464
+ class Faraday::Response::Middleware < Faraday::Middleware
465
+ def call(env); end
466
+ def on_complete(env); end
467
+ end
468
+ class Faraday::CompositeReadIO
469
+ def advance_io; end
470
+ def close; end
471
+ def current_io; end
472
+ def ensure_open_and_readable; end
473
+ def initialize(*parts); end
474
+ def length; end
475
+ def read(length = nil, outbuf = nil); end
476
+ def rewind; end
477
+ end
478
+ class Faraday::Error < StandardError
479
+ end
480
+ class Faraday::ClientError < Faraday::Error
481
+ def backtrace; end
482
+ def initialize(ex, response = nil); end
483
+ def inspect; end
484
+ def response; end
485
+ def wrapped_exception; end
486
+ end
487
+ class Faraday::ConnectionFailed < Faraday::ClientError
488
+ end
489
+ class Faraday::ResourceNotFound < Faraday::ClientError
490
+ end
491
+ class Faraday::ParsingError < Faraday::ClientError
492
+ end
493
+ class Faraday::TimeoutError < Faraday::ClientError
494
+ def initialize(ex = nil); end
495
+ end
496
+ class Faraday::SSLError < Faraday::ClientError
497
+ end
498
+ class Faraday::RetriableResponse < Faraday::ClientError
499
+ end
500
+ module Faraday::AutoloadHelper
501
+ def all_loaded_constants; end
502
+ def autoload_all(prefix, options); end
503
+ def load_autoloaded_constants; end
504
+ end
505
+ module Faraday::MiddlewareRegistry
506
+ def fetch_middleware(key); end
507
+ def load_middleware(key); end
508
+ def lookup_middleware(key); end
509
+ def middleware_mutex(&block); end
510
+ def register_middleware(autoload_path = nil, mapping = nil); end
511
+ end
512
+ class Faraday::Request::UrlEncoded < Faraday::Middleware
513
+ def call(env); end
514
+ def match_content_type(env); end
515
+ def process_request?(env); end
516
+ def request_type(env); end
517
+ def self.mime_type; end
518
+ def self.mime_type=(arg0); end
519
+ end
520
+ class Faraday::Request::Multipart < Faraday::Request::UrlEncoded
521
+ def call(env); end
522
+ def create_multipart(env, params); end
523
+ def has_multipart?(obj); end
524
+ def process_params(params, prefix = nil, pieces = nil, &block); end
525
+ def process_request?(env); end
526
+ def unique_boundary; end
527
+ end
528
+ class Faraday::Response::RaiseError < Faraday::Response::Middleware
529
+ def on_complete(env); end
530
+ def response_values(env); end
531
+ end