apimatic_core 0.3.10 → 0.3.11
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/lib/apimatic-core/utilities/api_helper.rb +67 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9da404e8964a5bfdaf56941e9f4d9b924feb65b4bb63f2d1d114eb266f15c4c7
|
4
|
+
data.tar.gz: '09b6618e6680701197a2b00446979f4b551a1c0c9186a64c6489484636ff787d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e534a75ca905d49e0f7940184ac24bb9d77ef252de932ec82c95d78c123152acc01981f4f09b5fbda3975083021df599e81c188860b016156233da117c70e038
|
7
|
+
data.tar.gz: c294f2f478bac7ced004d3b6ff49a04e2c0c093cc00af17f12ae78e42e544fc587cbda6971b57fe67e8cdb281a4d19448366237d74ef3553006430bba0ed1165
|
@@ -442,6 +442,73 @@ module CoreLibrary
|
|
442
442
|
val
|
443
443
|
end
|
444
444
|
|
445
|
+
# Apply unboxing_function to additional properties from hash.
|
446
|
+
# @param [Hash] hash The hash to extract additional properties from.
|
447
|
+
# @param [Proc] unboxing_function The deserializer to apply to each item in the hash.
|
448
|
+
# @return [Hash] A hash containing the additional properties and their values.
|
449
|
+
def self.get_additional_properties(hash, unboxing_function, is_array: false, is_dict: false, is_array_of_map: false,
|
450
|
+
is_map_of_array: false, dimension_count: 1)
|
451
|
+
additional_properties = {}
|
452
|
+
|
453
|
+
# Iterate over each key-value pair in the input hash
|
454
|
+
hash.each do |key, value|
|
455
|
+
# Prepare arguments for apply_unboxing_function
|
456
|
+
args = {
|
457
|
+
is_array: is_array,
|
458
|
+
is_dict: is_dict,
|
459
|
+
is_array_of_map: is_array_of_map,
|
460
|
+
is_map_of_array: is_map_of_array,
|
461
|
+
dimension_count: dimension_count
|
462
|
+
}
|
463
|
+
|
464
|
+
# If the value is a complex structure (Hash or Array), apply apply_unboxing_function
|
465
|
+
additional_properties[key] = if is_array || is_dict
|
466
|
+
apply_unboxing_function(value, unboxing_function, **args)
|
467
|
+
else
|
468
|
+
# Apply the unboxing function directly for simple values
|
469
|
+
unboxing_function.call(value)
|
470
|
+
end
|
471
|
+
rescue StandardError
|
472
|
+
# Ignore the exception and continue processing
|
473
|
+
end
|
474
|
+
|
475
|
+
additional_properties
|
476
|
+
end
|
477
|
+
|
478
|
+
def self.apply_unboxing_function(obj, unboxing_function, is_array: false, is_dict: false, is_array_of_map: false,
|
479
|
+
is_map_of_array: false, dimension_count: 1)
|
480
|
+
if is_dict
|
481
|
+
if is_map_of_array
|
482
|
+
# Handle case where the object is a map of arrays (Hash with array values)
|
483
|
+
obj.transform_values do |v|
|
484
|
+
apply_unboxing_function(v, unboxing_function, is_array: true, dimension_count: dimension_count)
|
485
|
+
end
|
486
|
+
else
|
487
|
+
# Handle regular Hash (map) case
|
488
|
+
obj.transform_values { |v| unboxing_function.call(v) }
|
489
|
+
end
|
490
|
+
elsif is_array
|
491
|
+
if is_array_of_map
|
492
|
+
# Handle case where the object is an array of maps (Array of Hashes)
|
493
|
+
obj.map do |element|
|
494
|
+
apply_unboxing_function(element, unboxing_function, is_dict: true, dimension_count: dimension_count)
|
495
|
+
end
|
496
|
+
elsif dimension_count > 1
|
497
|
+
# Handle multi-dimensional array
|
498
|
+
obj.map do |element|
|
499
|
+
apply_unboxing_function(element, unboxing_function, is_array: true,
|
500
|
+
dimension_count: dimension_count - 1)
|
501
|
+
end
|
502
|
+
else
|
503
|
+
# Handle regular Array case
|
504
|
+
obj.map { |element| unboxing_function.call(element) }
|
505
|
+
end
|
506
|
+
else
|
507
|
+
# Handle base case where the object is neither Array nor Hash
|
508
|
+
unboxing_function.call(obj)
|
509
|
+
end
|
510
|
+
end
|
511
|
+
|
445
512
|
# Get content-type depending on the value
|
446
513
|
# @param [Object] value The value for which the content-type is resolved.
|
447
514
|
def self.get_content_type(value)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apimatic_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- APIMatic Ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apimatic_core_interfaces
|