apimatic_core 0.3.9 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2e63e21797c24ebc97dd600ad78da020cda9ef430f54b3d33d4f98c29d6d26d
4
- data.tar.gz: dcd68bd2a3d9d54d1643120f85be3c6f7edd0299776600693316df9303dd65f8
3
+ metadata.gz: 9da404e8964a5bfdaf56941e9f4d9b924feb65b4bb63f2d1d114eb266f15c4c7
4
+ data.tar.gz: '09b6618e6680701197a2b00446979f4b551a1c0c9186a64c6489484636ff787d'
5
5
  SHA512:
6
- metadata.gz: 1c70fcb087fcb9e676e9bb8fe016e055c107e0a6cf08cffa2b36ca378a4221f5478f85b4bd79319976ef4feee078422b23418e2966f36a67b55b82097cf293c8
7
- data.tar.gz: 01313adab6e529022b84e4c45713800c0e20eb673ff106ea2e6293f055a728ecbac0aa0c955253a355a6c58d6aea86e5075b20b60363d1520bb8fcc37a9560ed
6
+ metadata.gz: e534a75ca905d49e0f7940184ac24bb9d77ef252de932ec82c95d78c123152acc01981f4f09b5fbda3975083021df599e81c188860b016156233da117c70e038
7
+ data.tar.gz: c294f2f478bac7ced004d3b6ff49a04e2c0c093cc00af17f12ae78e42e544fc587cbda6971b57fe67e8cdb281a4d19448366237d74ef3553006430bba0ed1165
@@ -161,7 +161,7 @@ module CoreLibrary
161
161
  # validating response if configured
162
162
  validate(response, global_errors)
163
163
 
164
- return if @is_response_void
164
+ return if @is_response_void && !@is_api_response
165
165
 
166
166
  # applying deserializer if configured
167
167
  deserialized_value = apply_deserializer(response, should_symbolize_hash)
@@ -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.9
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-07-09 00:00:00.000000000 Z
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