Skip to content

Commit c9dbcbd

Browse files
algolia-botsbellone
andcommitted
fix(specs): Ingestion API - update destination payload (generated)
algolia/api-clients-automation#6320 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Sylvain Bellone <sylvain.bellone@algolia.com>
1 parent c5a9e62 commit c9dbcbd

2 files changed

Lines changed: 230 additions & 11 deletions

File tree

lib/algolia/models/ingestion/destination_update.rb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ module Algolia
99
module Ingestion
1010
# API request body for updating a destination.
1111
class DestinationUpdate
12-
attr_accessor :type
13-
1412
# Descriptive name for the resource.
1513
attr_accessor :name
1614

@@ -24,7 +22,6 @@ class DestinationUpdate
2422
# Attribute mapping from ruby-style variable name to JSON key.
2523
def self.attribute_map
2624
{
27-
:type => :type,
2825
:name => :name,
2926
:input => :input,
3027
:authentication_id => :authenticationID,
@@ -35,9 +32,8 @@ def self.attribute_map
3532
# Attribute type mapping.
3633
def self.types_mapping
3734
{
38-
:type => :"DestinationType",
3935
:name => :"String",
40-
:input => :"DestinationInput",
36+
:input => :"DestinationUpdateInput",
4137
:authentication_id => :"String",
4238
:transformation_ids => :"Array<String>"
4339
}
@@ -73,10 +69,6 @@ def initialize(attributes = {})
7369
h[k.to_sym] = v
7470
}
7571

76-
if attributes.key?(:type)
77-
self.type = attributes[:type]
78-
end
79-
8072
if attributes.key?(:name)
8173
self.name = attributes[:name]
8274
end
@@ -101,7 +93,6 @@ def initialize(attributes = {})
10193
def ==(other)
10294
return true if self.equal?(other)
10395
self.class == other.class &&
104-
type == other.type &&
10596
name == other.name &&
10697
input == other.input &&
10798
authentication_id == other.authentication_id &&
@@ -117,7 +108,7 @@ def eql?(other)
117108
# Calculates hash code according to all attributes.
118109
# @return [Integer] Hash code
119110
def hash
120-
[type, name, input, authentication_id, transformation_ids].hash
111+
[name, input, authentication_id, transformation_ids].hash
121112
end
122113

123114
# Builds the object from hash
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# frozen_string_literal: true
2+
3+
# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4+
5+
require "date"
6+
require "time"
7+
8+
module Algolia
9+
module Ingestion
10+
class DestinationUpdateInput
11+
# Algolia index name (case-sensitive).
12+
attr_accessor :index_name
13+
14+
attr_accessor :record_type
15+
16+
# Attributes from your source to exclude from Algolia records. Not all your data attributes will be useful for searching. Keeping your Algolia records small increases indexing and search performance. - Exclude nested attributes with `.` notation. For example, `foo.bar` indexes the `foo` attribute and all its children **except** the `bar` attribute. - Exclude attributes from arrays with `[i]`, where `i` is the index of the array element. For example, `foo.[0].bar` only excludes the `bar` attribute from the first element of the `foo` array, but indexes the complete `foo` attribute for all other elements. Use `*` as wildcard: `foo.[*].bar` excludes `bar` from all elements of the `foo` array.
17+
attr_accessor :attributes_to_exclude
18+
19+
# Attribute mapping from ruby-style variable name to JSON key.
20+
def self.attribute_map
21+
{
22+
:index_name => :indexName,
23+
:record_type => :recordType,
24+
:attributes_to_exclude => :attributesToExclude
25+
}
26+
end
27+
28+
# Attribute type mapping.
29+
def self.types_mapping
30+
{
31+
:index_name => :"String",
32+
:record_type => :"RecordType",
33+
:attributes_to_exclude => :"Array<String>"
34+
}
35+
end
36+
37+
# List of attributes with nullable: true
38+
def self.openapi_nullable
39+
Set.new(
40+
[]
41+
)
42+
end
43+
44+
# Initializes the object
45+
# @param [Hash] attributes Model attributes in the form of hash
46+
def initialize(attributes = {})
47+
if (!attributes.is_a?(Hash))
48+
raise(
49+
ArgumentError,
50+
"The input argument (attributes) must be a hash in `Algolia::DestinationUpdateInput` initialize method"
51+
)
52+
end
53+
54+
# check to see if the attribute exists and convert string to symbol for hash key
55+
attributes = attributes.each_with_object({}) { |(k, v), h|
56+
if (!self.class.attribute_map.key?(k.to_sym))
57+
raise(
58+
ArgumentError,
59+
"`#{k}` is not a valid attribute in `Algolia::DestinationUpdateInput`. Please check the name to make sure it's valid. List of attributes: " +
60+
self.class.attribute_map.keys.inspect
61+
)
62+
end
63+
64+
h[k.to_sym] = v
65+
}
66+
67+
if attributes.key?(:index_name)
68+
self.index_name = attributes[:index_name]
69+
end
70+
71+
if attributes.key?(:record_type)
72+
self.record_type = attributes[:record_type]
73+
end
74+
75+
if attributes.key?(:attributes_to_exclude)
76+
if (value = attributes[:attributes_to_exclude]).is_a?(Array)
77+
self.attributes_to_exclude = value
78+
end
79+
end
80+
end
81+
82+
# Checks equality by comparing each attribute.
83+
# @param [Object] Object to be compared
84+
def ==(other)
85+
return true if self.equal?(other)
86+
self.class == other.class &&
87+
index_name == other.index_name &&
88+
record_type == other.record_type &&
89+
attributes_to_exclude == other.attributes_to_exclude
90+
end
91+
92+
# @see the `==` method
93+
# @param [Object] Object to be compared
94+
def eql?(other)
95+
self == other
96+
end
97+
98+
# Calculates hash code according to all attributes.
99+
# @return [Integer] Hash code
100+
def hash
101+
[index_name, record_type, attributes_to_exclude].hash
102+
end
103+
104+
# Builds the object from hash
105+
# @param [Hash] attributes Model attributes in the form of hash
106+
# @return [Object] Returns the model itself
107+
def self.build_from_hash(attributes)
108+
return nil unless attributes.is_a?(Hash)
109+
attributes = attributes.transform_keys(&:to_sym)
110+
transformed_hash = {}
111+
types_mapping.each_pair do |key, type|
112+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
113+
transformed_hash[key.to_sym] = nil
114+
elsif type =~ /\AArray<(.*)>/i
115+
# check to ensure the input is an array given that the attribute
116+
# is documented as an array but the input is not
117+
if attributes[attribute_map[key]].is_a?(Array)
118+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
119+
_deserialize(::Regexp.last_match(1), v)
120+
}
121+
end
122+
elsif !attributes[attribute_map[key]].nil?
123+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
124+
end
125+
end
126+
127+
new(transformed_hash)
128+
end
129+
130+
# Deserializes the data based on type
131+
# @param string type Data type
132+
# @param string value Value to be deserialized
133+
# @return [Object] Deserialized data
134+
def self._deserialize(type, value)
135+
case type.to_sym
136+
when :Time
137+
Time.parse(value)
138+
when :Date
139+
Date.parse(value)
140+
when :String
141+
value.to_s
142+
when :Integer
143+
value.to_i
144+
when :Float
145+
value.to_f
146+
when :Boolean
147+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148+
true
149+
else
150+
false
151+
end
152+
153+
when :Object
154+
# generic object (usually a Hash), return directly
155+
value
156+
when /\AArray<(?<inner_type>.+)>\z/
157+
inner_type = Regexp.last_match[:inner_type]
158+
value.map { |v| _deserialize(inner_type, v) }
159+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
160+
k_type = Regexp.last_match[:k_type]
161+
v_type = Regexp.last_match[:v_type]
162+
{}.tap do |hash|
163+
value.each do |k, v|
164+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165+
end
166+
end
167+
# model
168+
else
169+
# models (e.g. Pet) or oneOf
170+
klass = Algolia::Ingestion.const_get(type)
171+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
172+
.build_from_hash(value)
173+
end
174+
end
175+
176+
# Returns the string representation of the object
177+
# @return [String] String presentation of the object
178+
def to_s
179+
to_hash.to_s
180+
end
181+
182+
# to_body is an alias to to_hash (backward compatibility)
183+
# @return [Hash] Returns the object in the form of hash
184+
def to_body
185+
to_hash
186+
end
187+
188+
def to_json(*_args)
189+
to_hash.to_json
190+
end
191+
192+
# Returns the object in the form of hash
193+
# @return [Hash] Returns the object in the form of hash
194+
def to_hash
195+
hash = {}
196+
self.class.attribute_map.each_pair do |attr, param|
197+
value = send(attr)
198+
if value.nil?
199+
is_nullable = self.class.openapi_nullable.include?(attr)
200+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
201+
end
202+
203+
hash[param] = _to_hash(value)
204+
end
205+
206+
hash
207+
end
208+
209+
# Outputs non-array value in the form of hash
210+
# For object, use to_hash. Otherwise, just return the value
211+
# @param [Object] value Any valid value
212+
# @return [Hash] Returns the value in the form of hash
213+
def _to_hash(value)
214+
if value.is_a?(Array)
215+
value.compact.map { |v| _to_hash(v) }
216+
elsif value.is_a?(Hash)
217+
{}.tap do |hash|
218+
value.each { |k, v| hash[k] = _to_hash(v) }
219+
end
220+
elsif value.respond_to?(:to_hash)
221+
value.to_hash
222+
else
223+
value
224+
end
225+
end
226+
end
227+
end
228+
end

0 commit comments

Comments
 (0)