apimatic_core 0.3.10 → 0.3.12
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/README.md +1 -1
- data/lib/apimatic-core/utilities/api_helper.rb +67 -0
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 725370c3d94b9c6ad4c84dbbdf6a07329ed9ee9cb55d10fe8767e3bcbd5bd24a
|
4
|
+
data.tar.gz: 461891f68fd639ed4aa809ddab315200937e148fee10db8dee497175360d8c21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c1cebaf388c5ae815d6bc7a1aa00d06da6c3866734f5549d5bf3e8db537c21da51bb99a4bb54255bb8735e7c006b740823c0b1896ecb904929a33814ecdc352
|
7
|
+
data.tar.gz: de0ba972bc80fb202493a1d79ab62890dad7bda62b3f4f76f40e8b465aedf2866ebcfe22b80b41ca083b07b63a279b699d73263126251beb90ab34a41e2bee62
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Core library ruby does the job of congregating common and core functionality fro
|
|
12
12
|
|
13
13
|
|
14
14
|
## Installation
|
15
|
-
You will need `2.6 <= Ruby version <= 3.
|
15
|
+
You will need `2.6 <= Ruby version <= 3.3` to support this package.
|
16
16
|
|
17
17
|
Installation is quite simple, just execute the following command:
|
18
18
|
```
|
@@ -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.12
|
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-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apimatic_core_interfaces
|
@@ -30,20 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.13'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.
|
36
|
+
version: 1.13.10
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '1.
|
43
|
+
version: '1.13'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
46
|
+
version: 1.13.10
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: certifi
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,40 +84,40 @@ dependencies:
|
|
84
84
|
requirements:
|
85
85
|
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '2.
|
87
|
+
version: '2.8'
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 2.
|
90
|
+
version: 2.8.1
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '2.
|
97
|
+
version: '2.8'
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: 2.
|
100
|
+
version: 2.8.1
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
102
|
name: minitest
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
105
|
- - "~>"
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: '5.
|
107
|
+
version: '5.25'
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 5.
|
110
|
+
version: 5.25.4
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '5.
|
117
|
+
version: '5.25'
|
118
118
|
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: 5.
|
120
|
+
version: 5.25.4
|
121
121
|
- !ruby/object:Gem::Dependency
|
122
122
|
name: minitest-proveit
|
123
123
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,14 +138,14 @@ dependencies:
|
|
138
138
|
requirements:
|
139
139
|
- - "~>"
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: 0.
|
141
|
+
version: 0.22.0
|
142
142
|
type: :development
|
143
143
|
prerelease: false
|
144
144
|
version_requirements: !ruby/object:Gem::Requirement
|
145
145
|
requirements:
|
146
146
|
- - "~>"
|
147
147
|
- !ruby/object:Gem::Version
|
148
|
-
version: 0.
|
148
|
+
version: 0.22.0
|
149
149
|
description: The APIMatic Core libraries provide a stable runtime that powers all
|
150
150
|
the functionality of SDKs. This includes functionality like the ability to create
|
151
151
|
HTTP requests, handle responses, apply authentication schemes, convert API responses
|