whatsapp_sdk 0.3.2 → 0.4.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/.gitignore +1 -0
- data/.rubocop.yml +14 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +44 -0
- data/README.md +102 -28
- data/Rakefile +1 -0
- data/bin/tapioca +30 -0
- data/example.rb +31 -36
- data/lib/version.rb +2 -1
- data/lib/whatsapp_sdk/api/client.rb +14 -3
- data/lib/whatsapp_sdk/api/medias.rb +12 -3
- data/lib/whatsapp_sdk/api/messages.rb +72 -14
- data/lib/whatsapp_sdk/api/phone_numbers.rb +3 -0
- data/lib/whatsapp_sdk/api/request.rb +2 -2
- data/lib/whatsapp_sdk/api/response.rb +17 -1
- data/lib/whatsapp_sdk/api/responses/data_response.rb +10 -3
- data/lib/whatsapp_sdk/api/responses/error_response.rb +8 -1
- data/lib/whatsapp_sdk/api/responses/media_data_response.rb +26 -7
- data/lib/whatsapp_sdk/api/responses/message_data_response.rb +20 -3
- data/lib/whatsapp_sdk/api/responses/message_error_response.rb +26 -7
- data/lib/whatsapp_sdk/api/responses/phone_number_data_response.rb +18 -5
- data/lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb +9 -1
- data/lib/whatsapp_sdk/api/responses/read_message_data_response.rb +10 -3
- data/lib/whatsapp_sdk/api/responses/success_response.rb +5 -1
- data/lib/whatsapp_sdk/configuration.rb +7 -3
- data/lib/whatsapp_sdk/error.rb +1 -0
- data/lib/whatsapp_sdk/resource/address.rb +30 -6
- data/lib/whatsapp_sdk/resource/address_type.rb +15 -0
- data/lib/whatsapp_sdk/resource/button_parameter.rb +19 -23
- data/lib/whatsapp_sdk/resource/component.rb +45 -13
- data/lib/whatsapp_sdk/resource/contact.rb +30 -1
- data/lib/whatsapp_sdk/resource/contact_response.rb +9 -1
- data/lib/whatsapp_sdk/resource/currency.rb +9 -1
- data/lib/whatsapp_sdk/resource/date_time.rb +7 -1
- data/lib/whatsapp_sdk/resource/email.rb +9 -5
- data/lib/whatsapp_sdk/resource/media.rb +44 -15
- data/lib/whatsapp_sdk/resource/message.rb +5 -0
- data/lib/whatsapp_sdk/resource/name.rb +28 -1
- data/lib/whatsapp_sdk/resource/org.rb +13 -1
- data/lib/whatsapp_sdk/resource/parameter_object.rb +82 -39
- data/lib/whatsapp_sdk/resource/phone_number.rb +12 -5
- data/lib/whatsapp_sdk/resource/url.rb +9 -5
- data/lib/whatsapp_sdk.rb +7 -0
- data/sorbet/config +6 -0
- data/sorbet/rbi/annotations/faraday.rbi +17 -0
- data/sorbet/rbi/annotations/mocha.rbi +34 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/faraday-multipart@1.0.4.rbi +270 -0
- data/sorbet/rbi/gems/faraday-net_http@2.0.3.rbi +182 -0
- data/sorbet/rbi/gems/faraday@2.3.0.rbi +2494 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +272 -0
- data/sorbet/rbi/gems/minitest@5.16.1.rbi +1459 -0
- data/sorbet/rbi/gems/mocha@1.14.0.rbi +60 -0
- data/sorbet/rbi/gems/multipart-post@2.2.3.rbi +239 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +150 -0
- data/sorbet/rbi/gems/oj@3.13.14.rbi +589 -0
- data/sorbet/rbi/gems/zeitwerk@2.6.0.rbi +867 -0
- data/sorbet/rbi/todo.rbi +8 -0
- data/sorbet/shims/request.rbi +10 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +5 -0
- data/whatsapp_sdk.gemspec +4 -1
- metadata +50 -2
@@ -0,0 +1,589 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `oj` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem oj`.
|
6
|
+
|
7
|
+
# source://RUBY_ROOT/json/common.rb:35
|
8
|
+
JSON::Parser = JSON::Ext::Parser
|
9
|
+
|
10
|
+
# source://RUBY_ROOT/json/common.rb:73
|
11
|
+
JSON::State = JSON::Ext::Generator::State
|
12
|
+
|
13
|
+
# source://oj-3.13.14/lib/oj.rb:2
|
14
|
+
module Oj
|
15
|
+
private
|
16
|
+
|
17
|
+
def add_to_json(*_arg0); end
|
18
|
+
def compat_load(*_arg0); end
|
19
|
+
def debug_odd(_arg0); end
|
20
|
+
def default_options; end
|
21
|
+
def default_options=(_arg0); end
|
22
|
+
def dump(*_arg0); end
|
23
|
+
def fast_generate(*_arg0); end
|
24
|
+
def generate(*_arg0); end
|
25
|
+
def load(*_arg0); end
|
26
|
+
def load_file(*_arg0); end
|
27
|
+
def mimic_JSON(*_arg0); end
|
28
|
+
def object_load(*_arg0); end
|
29
|
+
def optimize_rails; end
|
30
|
+
def register_odd(*_arg0); end
|
31
|
+
def register_odd_raw(*_arg0); end
|
32
|
+
def remove_to_json(*_arg0); end
|
33
|
+
def safe_load(_arg0); end
|
34
|
+
def saj_parse(*_arg0); end
|
35
|
+
def sc_parse(*_arg0); end
|
36
|
+
def strict_load(*_arg0); end
|
37
|
+
def to_file(*_arg0); end
|
38
|
+
def to_json; end
|
39
|
+
def to_stream(*_arg0); end
|
40
|
+
def wab_load(*_arg0); end
|
41
|
+
|
42
|
+
class << self
|
43
|
+
def add_to_json(*_arg0); end
|
44
|
+
def compat_load(*_arg0); end
|
45
|
+
def debug_odd(_arg0); end
|
46
|
+
def default_options; end
|
47
|
+
def default_options=(_arg0); end
|
48
|
+
def dump(*_arg0); end
|
49
|
+
def fast_generate(*_arg0); end
|
50
|
+
def generate(*_arg0); end
|
51
|
+
def load(*_arg0); end
|
52
|
+
def load_file(*_arg0); end
|
53
|
+
def mimic_JSON(*_arg0); end
|
54
|
+
|
55
|
+
# Loads mimic-ed JSON paths. Used by Oj.mimic_JSON().
|
56
|
+
#
|
57
|
+
# @param mimic_paths [Array] additional paths to add to the Ruby loaded features.
|
58
|
+
#
|
59
|
+
# source://oj-3.13.14/lib/oj/mimic.rb:81
|
60
|
+
def mimic_loaded(mimic_paths = T.unsafe(nil)); end
|
61
|
+
|
62
|
+
def object_load(*_arg0); end
|
63
|
+
def optimize_rails; end
|
64
|
+
def register_odd(*_arg0); end
|
65
|
+
def register_odd_raw(*_arg0); end
|
66
|
+
def remove_to_json(*_arg0); end
|
67
|
+
def safe_load(_arg0); end
|
68
|
+
def saj_parse(*_arg0); end
|
69
|
+
def sc_parse(*_arg0); end
|
70
|
+
def strict_load(*_arg0); end
|
71
|
+
def to_file(*_arg0); end
|
72
|
+
def to_json; end
|
73
|
+
def to_stream(*_arg0); end
|
74
|
+
def wab_load(*_arg0); end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# A generic class that is used only for storing attributes. It is the base
|
79
|
+
# Class for auto-generated classes in the storage system. Instance variables
|
80
|
+
# are added using the instance_variable_set() method. All instance variables
|
81
|
+
# can be accessed using the variable name (without the @ prefix). No setters
|
82
|
+
# are provided as the Class is intended for reading only.
|
83
|
+
#
|
84
|
+
# source://oj-3.13.14/lib/oj/bag.rb:10
|
85
|
+
class Oj::Bag
|
86
|
+
# The initializer can take multiple arguments in the form of key values
|
87
|
+
# where the key is the variable name and the value is the variable
|
88
|
+
# value. This is intended for testing purposes only.
|
89
|
+
#
|
90
|
+
# @example Oj::Bag.new(:@x => 42, :@y => 57)
|
91
|
+
# @param args [Hash] instance variable symbols and their values
|
92
|
+
# @return [Bag] a new instance of Bag
|
93
|
+
#
|
94
|
+
# source://oj-3.13.14/lib/oj/bag.rb:17
|
95
|
+
def initialize(args = T.unsafe(nil)); end
|
96
|
+
|
97
|
+
# Replaces eql?() with something more reasonable for this Class.
|
98
|
+
#
|
99
|
+
# @param other [Object] Object to compare self to
|
100
|
+
# @return [Boolean] true if each variable and value are the same, otherwise false.
|
101
|
+
#
|
102
|
+
# source://oj-3.13.14/lib/oj/bag.rb:48
|
103
|
+
def ==(other); end
|
104
|
+
|
105
|
+
# Replaces eql?() with something more reasonable for this Class.
|
106
|
+
#
|
107
|
+
# @param other [Object] Object to compare self to
|
108
|
+
# @return [Boolean] true if each variable and value are the same, otherwise false.
|
109
|
+
#
|
110
|
+
# source://oj-3.13.14/lib/oj/bag.rb:48
|
111
|
+
def eql?(other); end
|
112
|
+
|
113
|
+
# Handles requests for variable values. Others cause an Exception to be
|
114
|
+
# raised.
|
115
|
+
#
|
116
|
+
# @param m [Symbol] method symbol
|
117
|
+
# @raise [ArgumentError] if an argument is given. Zero arguments expected.
|
118
|
+
# @raise [NoMethodError] if the instance variable is not defined.
|
119
|
+
# @return [Boolean] the value of the specified instance variable.
|
120
|
+
#
|
121
|
+
# source://oj-3.13.14/lib/oj/bag.rb:38
|
122
|
+
def method_missing(m, *args, &block); end
|
123
|
+
|
124
|
+
# Replaces the Object.respond_to?() method.
|
125
|
+
#
|
126
|
+
# @param m [Symbol] method symbol
|
127
|
+
# @return [Boolean] true for any method that matches an instance
|
128
|
+
# variable reader, otherwise false.
|
129
|
+
#
|
130
|
+
# source://oj-3.13.14/lib/oj/bag.rb:27
|
131
|
+
def respond_to?(m); end
|
132
|
+
|
133
|
+
class << self
|
134
|
+
# Define a new class based on the Oj::Bag class. This is used internally in
|
135
|
+
# the Oj module and is available to service wrappers that receive XML
|
136
|
+
# requests that include Objects of Classes not defined in the storage
|
137
|
+
# process.
|
138
|
+
#
|
139
|
+
# @param classname [String] Class name or symbol that includes Module names.
|
140
|
+
# @raise [NameError] if the classname is invalid.
|
141
|
+
# @return [Object] an instance of the specified Class.
|
142
|
+
#
|
143
|
+
# source://oj-3.13.14/lib/oj/bag.rb:64
|
144
|
+
def define_class(classname); end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
class Oj::CStack; end
|
149
|
+
|
150
|
+
# Custom mode can be used to emulate the compat mode with some minor
|
151
|
+
# differences. These are the options that setup the custom mode to be like
|
152
|
+
# the compat mode.
|
153
|
+
#
|
154
|
+
# source://oj-3.13.14/lib/oj/mimic.rb:15
|
155
|
+
Oj::CUSTOM_MIMIC_JSON_OPTIONS = T.let(T.unsafe(nil), Hash)
|
156
|
+
|
157
|
+
class Oj::Cache; end
|
158
|
+
|
159
|
+
# An Exception that is raised as a result of a path being too deep.
|
160
|
+
#
|
161
|
+
# source://oj-3.13.14/lib/oj/error.rb:14
|
162
|
+
class Oj::DepthError < ::Oj::Error; end
|
163
|
+
|
164
|
+
class Oj::Doc
|
165
|
+
def clone; end
|
166
|
+
def close; end
|
167
|
+
def dump(*_arg0); end
|
168
|
+
def dup; end
|
169
|
+
def each_child(*_arg0); end
|
170
|
+
def each_leaf(*_arg0); end
|
171
|
+
def each_value(*_arg0); end
|
172
|
+
def exists?(_arg0); end
|
173
|
+
def fetch(*_arg0); end
|
174
|
+
def home; end
|
175
|
+
def local_key; end
|
176
|
+
def move(_arg0); end
|
177
|
+
def path; end
|
178
|
+
def size; end
|
179
|
+
def type(*_arg0); end
|
180
|
+
def where; end
|
181
|
+
def where?; end
|
182
|
+
|
183
|
+
class << self
|
184
|
+
def open(_arg0); end
|
185
|
+
def open_file(_arg0); end
|
186
|
+
def parse(_arg0); end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# A Hash subclass that normalizes the hash keys to allow lookup by the
|
191
|
+
# key.to_s or key.to_sym. It also supports looking up hash values by methods
|
192
|
+
# that match the keys.
|
193
|
+
#
|
194
|
+
# source://oj-3.13.14/lib/oj/easy_hash.rb:7
|
195
|
+
class Oj::EasyHash < ::Hash
|
196
|
+
# Initializes the instance to an empty Hash.
|
197
|
+
#
|
198
|
+
# @return [EasyHash] a new instance of EasyHash
|
199
|
+
#
|
200
|
+
# source://oj-3.13.14/lib/oj/easy_hash.rb:10
|
201
|
+
def initialize; end
|
202
|
+
|
203
|
+
# source://oj-3.13.14/lib/oj/easy_hash.rb:25
|
204
|
+
def [](key); end
|
205
|
+
|
206
|
+
# Handles requests for Hash values. Others cause an Exception to be raised.
|
207
|
+
#
|
208
|
+
# @param m [Symbol|String] method symbol
|
209
|
+
# @raise [ArgumentError] if an argument is given. Zero arguments expected.
|
210
|
+
# @raise [NoMethodError] if the instance variable is not defined.
|
211
|
+
# @return [Boolean] the value of the specified instance variable.
|
212
|
+
#
|
213
|
+
# source://oj-3.13.14/lib/oj/easy_hash.rb:36
|
214
|
+
def method_missing(m, *args, &block); end
|
215
|
+
|
216
|
+
# Replaces the Object.respond_to?() method.
|
217
|
+
#
|
218
|
+
# @param m [Symbol] method symbol
|
219
|
+
# @param include_all [Boolean] whether to include private and protected methods in the search
|
220
|
+
# @return [Boolean] true for any method that matches an instance
|
221
|
+
# variable reader, otherwise false.
|
222
|
+
#
|
223
|
+
# source://oj-3.13.14/lib/oj/easy_hash.rb:18
|
224
|
+
def respond_to?(m, include_all = T.unsafe(nil)); end
|
225
|
+
end
|
226
|
+
|
227
|
+
# Inherit Error class from StandardError.
|
228
|
+
#
|
229
|
+
# source://oj-3.13.14/lib/oj/error.rb:5
|
230
|
+
class Oj::Error < ::StandardError; end
|
231
|
+
|
232
|
+
# An Exception that is raised if a file fails to load.
|
233
|
+
#
|
234
|
+
# source://oj-3.13.14/lib/oj/error.rb:17
|
235
|
+
class Oj::LoadError < ::Oj::Error; end
|
236
|
+
|
237
|
+
# A bit hack-ish but does the trick. The JSON.dump_default_options is a Hash
|
238
|
+
# but in mimic we use a C struct to store defaults. This class creates a view
|
239
|
+
# onto that struct.
|
240
|
+
#
|
241
|
+
# source://oj-3.13.14/lib/oj/mimic.rb:60
|
242
|
+
class Oj::MimicDumpOption < ::Hash
|
243
|
+
# @return [MimicDumpOption] a new instance of MimicDumpOption
|
244
|
+
#
|
245
|
+
# source://oj-3.13.14/lib/oj/mimic.rb:61
|
246
|
+
def initialize; end
|
247
|
+
|
248
|
+
# source://oj-3.13.14/lib/oj/mimic.rb:69
|
249
|
+
def []=(key, value); end
|
250
|
+
end
|
251
|
+
|
252
|
+
# An Exception that is raised if there is a conflict with mimicking JSON
|
253
|
+
#
|
254
|
+
# source://oj-3.13.14/lib/oj/error.rb:20
|
255
|
+
class Oj::MimicError < ::Oj::Error; end
|
256
|
+
|
257
|
+
# An Exception that is raised as a result of a parse error while parsing a JSON document.
|
258
|
+
#
|
259
|
+
# source://oj-3.13.14/lib/oj/error.rb:11
|
260
|
+
class Oj::ParseError < ::Oj::Error; end
|
261
|
+
|
262
|
+
class Oj::Parser
|
263
|
+
def file(_arg0); end
|
264
|
+
def just_one; end
|
265
|
+
def just_one=(_arg0); end
|
266
|
+
def load(_arg0); end
|
267
|
+
def method_missing(*_arg0); end
|
268
|
+
def parse(_arg0); end
|
269
|
+
|
270
|
+
private
|
271
|
+
|
272
|
+
def new(*_arg0); end
|
273
|
+
def saj; end
|
274
|
+
def usual; end
|
275
|
+
def validate; end
|
276
|
+
|
277
|
+
class << self
|
278
|
+
def new(*_arg0); end
|
279
|
+
def saj; end
|
280
|
+
def usual; end
|
281
|
+
def validate; end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
module Oj::Rails
|
286
|
+
private
|
287
|
+
|
288
|
+
def deoptimize(*_arg0); end
|
289
|
+
def encode(*_arg0); end
|
290
|
+
def mimic_JSON; end
|
291
|
+
def optimize(*_arg0); end
|
292
|
+
def optimized?(_arg0); end
|
293
|
+
def set_decoder; end
|
294
|
+
def set_encoder; end
|
295
|
+
|
296
|
+
class << self
|
297
|
+
def deoptimize(*_arg0); end
|
298
|
+
def encode(*_arg0); end
|
299
|
+
def mimic_JSON; end
|
300
|
+
def optimize(*_arg0); end
|
301
|
+
def optimized?(_arg0); end
|
302
|
+
def set_decoder; end
|
303
|
+
def set_encoder; end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
class Oj::Rails::Encoder
|
308
|
+
def deoptimize(*_arg0); end
|
309
|
+
def encode(_arg0); end
|
310
|
+
def optimize(*_arg0); end
|
311
|
+
def optimized?(_arg0); end
|
312
|
+
|
313
|
+
private
|
314
|
+
|
315
|
+
def new(*_arg0); end
|
316
|
+
|
317
|
+
class << self
|
318
|
+
def new(*_arg0); end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
# A SAX style parse handler for JSON hence the acronym SAJ for Simple API for
|
323
|
+
# JSON. The Oj::Saj handler class should be subclassed and then used with the
|
324
|
+
# Oj::Saj key_parse() method. The Saj methods will then be called as the file
|
325
|
+
# is parsed.
|
326
|
+
#
|
327
|
+
# To make the desired methods active while parsing the desired method should
|
328
|
+
# be made public in the subclasses. If the methods remain private they will
|
329
|
+
# not be called during parsing.
|
330
|
+
#
|
331
|
+
# def hash_start(key); end
|
332
|
+
# def hash_end(key); end
|
333
|
+
# def array_start(key); end
|
334
|
+
# def array_end(key); end
|
335
|
+
# def add_value(value, key); end
|
336
|
+
# def error(message, line, column); end
|
337
|
+
#
|
338
|
+
# @example
|
339
|
+
#
|
340
|
+
# require 'oj'
|
341
|
+
#
|
342
|
+
# class MySaj < ::Oj::Saj
|
343
|
+
# def initialize()
|
344
|
+
# @hash_cnt = 0
|
345
|
+
# end
|
346
|
+
#
|
347
|
+
# def hash_start(key)
|
348
|
+
# @hash_cnt += 1
|
349
|
+
# end
|
350
|
+
# end
|
351
|
+
#
|
352
|
+
# cnt = MySaj.new()
|
353
|
+
# File.open('any.json', 'r') do |f|
|
354
|
+
# Oj.saj_parse(cnt, f)
|
355
|
+
# end
|
356
|
+
#
|
357
|
+
# source://oj-3.13.14/lib/oj/saj.rb:37
|
358
|
+
class Oj::Saj
|
359
|
+
# Create a new instance of the Saj handler class.
|
360
|
+
#
|
361
|
+
# @return [Saj] a new instance of Saj
|
362
|
+
#
|
363
|
+
# source://oj-3.13.14/lib/oj/saj.rb:39
|
364
|
+
def initialize; end
|
365
|
+
|
366
|
+
private
|
367
|
+
|
368
|
+
# source://oj-3.13.14/lib/oj/saj.rb:59
|
369
|
+
def add_value(value, key); end
|
370
|
+
|
371
|
+
# source://oj-3.13.14/lib/oj/saj.rb:56
|
372
|
+
def array_end(key); end
|
373
|
+
|
374
|
+
# source://oj-3.13.14/lib/oj/saj.rb:53
|
375
|
+
def array_start(key); end
|
376
|
+
|
377
|
+
# source://oj-3.13.14/lib/oj/saj.rb:62
|
378
|
+
def error(message, line, column); end
|
379
|
+
|
380
|
+
# source://oj-3.13.14/lib/oj/saj.rb:50
|
381
|
+
def hash_end(key); end
|
382
|
+
|
383
|
+
# source://oj-3.13.14/lib/oj/saj.rb:47
|
384
|
+
def hash_start(key); end
|
385
|
+
end
|
386
|
+
|
387
|
+
# A Simple Callback Parser (SCP) for JSON. The Oj::ScHandler class should be
|
388
|
+
# subclassed and then used with the Oj.sc_parse() method. The Scp methods will
|
389
|
+
# then be called as the file is parsed. The handler does not have to be a
|
390
|
+
# subclass of the ScHandler class as long as it responds to the desired
|
391
|
+
# methods.
|
392
|
+
#
|
393
|
+
# To make the desired methods active while parsing the desired method should
|
394
|
+
# be made public in the subclasses. If the methods remain private they will
|
395
|
+
# not be called during parsing.
|
396
|
+
#
|
397
|
+
# def hash_start(); end
|
398
|
+
# def hash_end(); end
|
399
|
+
# def hash_key(key); end
|
400
|
+
# def hash_set(h, key, value); end
|
401
|
+
# def array_start(); end
|
402
|
+
# def array_end(); end
|
403
|
+
# def array_append(a, value); end
|
404
|
+
# def add_value(value); end
|
405
|
+
#
|
406
|
+
# As certain elements of a JSON document are reached during parsing the
|
407
|
+
# callbacks are called. The parser helps by keeping track of objects created
|
408
|
+
# by the callbacks but does not create those objects itself.
|
409
|
+
#
|
410
|
+
# hash_start
|
411
|
+
#
|
412
|
+
# When a JSON object element starts the hash_start() callback is called if
|
413
|
+
# public. It should return what ever Ruby Object is to be used as the element
|
414
|
+
# that will later be included in the hash_set() callback.
|
415
|
+
#
|
416
|
+
# hash_end
|
417
|
+
#
|
418
|
+
# When a hash key is encountered the hash_key method is called with the parsed
|
419
|
+
# hash value key. The return value from the call is then used as the key in
|
420
|
+
# the key-value pair that follows.
|
421
|
+
#
|
422
|
+
# hash_key
|
423
|
+
#
|
424
|
+
# At the end of a JSON object element the hash_end() callback is called if public.
|
425
|
+
#
|
426
|
+
# hash_set
|
427
|
+
#
|
428
|
+
# When a key value pair is encountered during parsing the hash_set() callback
|
429
|
+
# is called if public. The first element will be the object returned from the
|
430
|
+
# enclosing hash_start() callback. The second argument is the key and the last
|
431
|
+
# is the value.
|
432
|
+
#
|
433
|
+
# array_start
|
434
|
+
#
|
435
|
+
# When a JSON array element is started the array_start() callback is called if
|
436
|
+
# public. It should return what ever Ruby Object is to be used as the element
|
437
|
+
# that will later be included in the array_append() callback.
|
438
|
+
#
|
439
|
+
# array_end
|
440
|
+
#
|
441
|
+
# At the end of a JSON array element the array_end() callback is called if public.
|
442
|
+
#
|
443
|
+
# array_append
|
444
|
+
#
|
445
|
+
# When a element is encountered that is an element of an array the
|
446
|
+
# array_append() callback is called if public. The first argument to the
|
447
|
+
# callback is the Ruby object returned from the enclosing array_start()
|
448
|
+
# callback.
|
449
|
+
#
|
450
|
+
# add_value
|
451
|
+
#
|
452
|
+
# The handler is expected to handle multiple JSON elements in one stream,
|
453
|
+
# file, or string. When a top level JSON has been read completely the
|
454
|
+
# add_value() callback is called. Even if only one element was ready this
|
455
|
+
# callback returns the Ruby object that was constructed during the parsing.
|
456
|
+
#
|
457
|
+
# @example
|
458
|
+
#
|
459
|
+
# require 'oj'
|
460
|
+
#
|
461
|
+
# class MyHandler < ::Oj::ScHandler
|
462
|
+
# def hash_start
|
463
|
+
# {}
|
464
|
+
# end
|
465
|
+
#
|
466
|
+
# def hash_set(h,k,v)
|
467
|
+
# h[k] = v
|
468
|
+
# end
|
469
|
+
#
|
470
|
+
# def array_start
|
471
|
+
# []
|
472
|
+
# end
|
473
|
+
#
|
474
|
+
# def array_append(a,v)
|
475
|
+
# a << v
|
476
|
+
# end
|
477
|
+
#
|
478
|
+
# def add_value(v)
|
479
|
+
# p v
|
480
|
+
# end
|
481
|
+
#
|
482
|
+
# def error(message, line, column)
|
483
|
+
# p "ERROR: #{message}"
|
484
|
+
# end
|
485
|
+
# end
|
486
|
+
#
|
487
|
+
# File.open('any.json', 'r') do |f|
|
488
|
+
# Oj.sc_parse(MyHandler.new, f)
|
489
|
+
# end
|
490
|
+
#
|
491
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:106
|
492
|
+
class Oj::ScHandler
|
493
|
+
# Create a new instance of the ScHandler class.
|
494
|
+
#
|
495
|
+
# @return [ScHandler] a new instance of ScHandler
|
496
|
+
#
|
497
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:108
|
498
|
+
def initialize; end
|
499
|
+
|
500
|
+
private
|
501
|
+
|
502
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:135
|
503
|
+
def add_value(value); end
|
504
|
+
|
505
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:138
|
506
|
+
def array_append(a, value); end
|
507
|
+
|
508
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:132
|
509
|
+
def array_end; end
|
510
|
+
|
511
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:129
|
512
|
+
def array_start; end
|
513
|
+
|
514
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:119
|
515
|
+
def hash_end; end
|
516
|
+
|
517
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:122
|
518
|
+
def hash_key(key); end
|
519
|
+
|
520
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:126
|
521
|
+
def hash_set(h, key, value); end
|
522
|
+
|
523
|
+
# source://oj-3.13.14/lib/oj/schandler.rb:116
|
524
|
+
def hash_start; end
|
525
|
+
end
|
526
|
+
|
527
|
+
class Oj::StreamWriter
|
528
|
+
def flush; end
|
529
|
+
def pop; end
|
530
|
+
def pop_all; end
|
531
|
+
def push_array(*_arg0); end
|
532
|
+
def push_json(*_arg0); end
|
533
|
+
def push_key(_arg0); end
|
534
|
+
def push_object(*_arg0); end
|
535
|
+
def push_value(*_arg0); end
|
536
|
+
|
537
|
+
private
|
538
|
+
|
539
|
+
def new(*_arg0); end
|
540
|
+
|
541
|
+
class << self
|
542
|
+
def new(*_arg0); end
|
543
|
+
end
|
544
|
+
end
|
545
|
+
|
546
|
+
class Oj::StringWriter
|
547
|
+
def as_json; end
|
548
|
+
def pop; end
|
549
|
+
def pop_all; end
|
550
|
+
def push_array(*_arg0); end
|
551
|
+
def push_json(*_arg0); end
|
552
|
+
def push_key(_arg0); end
|
553
|
+
def push_object(*_arg0); end
|
554
|
+
def push_value(*_arg0); end
|
555
|
+
def raw_json; end
|
556
|
+
def reset; end
|
557
|
+
def to_s; end
|
558
|
+
|
559
|
+
private
|
560
|
+
|
561
|
+
def new(*_arg0); end
|
562
|
+
|
563
|
+
class << self
|
564
|
+
def new(*_arg0); end
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
# Current version of the module.
|
569
|
+
#
|
570
|
+
# source://oj-3.13.14/lib/oj/version.rb:4
|
571
|
+
Oj::VERSION = T.let(T.unsafe(nil), String)
|
572
|
+
|
573
|
+
# More monkey patches.
|
574
|
+
#
|
575
|
+
# source://oj-3.13.14/lib/oj/mimic.rb:282
|
576
|
+
class String
|
577
|
+
include ::Comparable
|
578
|
+
|
579
|
+
# source://oj-3.13.14/lib/oj/mimic.rb:289
|
580
|
+
def to_json_raw(*_arg0); end
|
581
|
+
|
582
|
+
# source://oj-3.13.14/lib/oj/mimic.rb:283
|
583
|
+
def to_json_raw_object; end
|
584
|
+
|
585
|
+
class << self
|
586
|
+
# source://oj-3.13.14/lib/oj/mimic.rb:292
|
587
|
+
def json_create(obj); end
|
588
|
+
end
|
589
|
+
end
|