Skip to content

Commit 1ea884e

Browse files
committed
Add invite_statement.rb.
1 parent e7a7369 commit 1ea884e

File tree

1 file changed

+222
-0
lines changed

1 file changed

+222
-0
lines changed
+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
=begin
2+
3+
=end
4+
5+
require 'date'
6+
7+
module AuthressSdk
8+
class InviteStatement
9+
attr_accessor :roles
10+
11+
attr_accessor :resources
12+
13+
# Attribute mapping from ruby-style variable name to JSON key.
14+
def self.attribute_map
15+
{
16+
:'roles' => :'roles',
17+
:'resources' => :'resources'
18+
}
19+
end
20+
21+
# Attribute type mapping.
22+
def self.openapi_types
23+
{
24+
:'roles' => :'Object',
25+
:'resources' => :'Object'
26+
}
27+
end
28+
29+
# List of attributes with nullable: true
30+
def self.openapi_nullable
31+
Set.new([
32+
])
33+
end
34+
35+
# Initializes the object
36+
# @param [Hash] attributes Model attributes in the form of hash
37+
def initialize(attributes = {})
38+
if (!attributes.is_a?(Hash))
39+
fail ArgumentError, "The input argument (attributes) must be a hash in `AuthressSdk::InviteStatement` initialize method"
40+
end
41+
42+
# check to see if the attribute exists and convert string to symbol for hash key
43+
attributes = attributes.each_with_object({}) { |(k, v), h|
44+
if (!self.class.attribute_map.key?(k.to_sym))
45+
fail ArgumentError, "`#{k}` is not a valid attribute in `AuthressSdk::InviteStatement`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
46+
end
47+
h[k.to_sym] = v
48+
}
49+
50+
if attributes.key?(:'roles')
51+
if (value = attributes[:'roles']).is_a?(Array)
52+
self.roles = value
53+
end
54+
end
55+
56+
if attributes.key?(:'resources')
57+
if (value = attributes[:'resources']).is_a?(Array)
58+
self.resources = value
59+
end
60+
end
61+
end
62+
63+
# Show invalid properties with the reasons. Usually used together with valid?
64+
# @return Array for valid properties with the reasons
65+
def list_invalid_properties
66+
invalid_properties = Array.new
67+
if @roles.nil?
68+
invalid_properties.push('invalid value for "roles", roles cannot be nil.')
69+
end
70+
71+
if @resources.nil?
72+
invalid_properties.push('invalid value for "resources", resources cannot be nil.')
73+
end
74+
75+
invalid_properties
76+
end
77+
78+
# Check to see if the all the properties in the model are valid
79+
# @return true if the model is valid
80+
def valid?
81+
return false if @roles.nil?
82+
return false if @resources.nil?
83+
true
84+
end
85+
86+
# Checks equality by comparing each attribute.
87+
# @param [Object] Object to be compared
88+
def ==(o)
89+
return true if self.equal?(o)
90+
self.class == o.class &&
91+
roles == o.roles &&
92+
resources == o.resources
93+
end
94+
95+
# @see the `==` method
96+
# @param [Object] Object to be compared
97+
def eql?(o)
98+
self == o
99+
end
100+
101+
# Calculates hash code according to all attributes.
102+
# @return [Integer] Hash code
103+
def hash
104+
[roles, resources].hash
105+
end
106+
107+
# Builds the object from hash
108+
# @param [Hash] attributes Model attributes in the form of hash
109+
# @return [Object] Returns the model itself
110+
def self.build_from_hash(attributes)
111+
new.build_from_hash(attributes)
112+
end
113+
114+
# Builds the object from hash
115+
# @param [Hash] attributes Model attributes in the form of hash
116+
# @return [Object] Returns the model itself
117+
def build_from_hash(attributes)
118+
return nil unless attributes.is_a?(Hash)
119+
self.class.openapi_types.each_pair do |key, type|
120+
if type =~ /\AArray<(.*)>/i
121+
# check to ensure the input is an array given that the attribute
122+
# is documented as an array but the input is not
123+
if attributes[self.class.attribute_map[key]].is_a?(Array)
124+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
125+
end
126+
elsif !attributes[self.class.attribute_map[key]].nil?
127+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
128+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
129+
self.send("#{key}=", nil)
130+
end
131+
end
132+
133+
self
134+
end
135+
136+
# Deserializes the data based on type
137+
# @param string type Data type
138+
# @param string value Value to be deserialized
139+
# @return [Object] Deserialized data
140+
def _deserialize(type, value)
141+
case type.to_sym
142+
when :DateTime
143+
DateTime.parse(value)
144+
when :Date
145+
Date.parse(value)
146+
when :String
147+
value.to_s
148+
when :Integer
149+
value.to_i
150+
when :Float
151+
value.to_f
152+
when :Boolean
153+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
154+
true
155+
else
156+
false
157+
end
158+
when :Object
159+
# generic object (usually a Hash), return directly
160+
value
161+
when /\AArray<(?<inner_type>.+)>\z/
162+
inner_type = Regexp.last_match[:inner_type]
163+
value.map { |v| _deserialize(inner_type, v) }
164+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
165+
k_type = Regexp.last_match[:k_type]
166+
v_type = Regexp.last_match[:v_type]
167+
{}.tap do |hash|
168+
value.each do |k, v|
169+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
170+
end
171+
end
172+
else # model
173+
AuthressSdk.const_get(type).build_from_hash(value)
174+
end
175+
end
176+
177+
# Returns the string representation of the object
178+
# @return [String] String presentation of the object
179+
def to_s
180+
to_hash.to_s
181+
end
182+
183+
# to_body is an alias to to_hash (backward compatibility)
184+
# @return [Hash] Returns the object in the form of hash
185+
def to_body
186+
to_hash
187+
end
188+
189+
# Returns the object in the form of hash
190+
# @return [Hash] Returns the object in the form of hash
191+
def to_hash
192+
hash = {}
193+
self.class.attribute_map.each_pair do |attr, param|
194+
value = self.send(attr)
195+
if value.nil?
196+
is_nullable = self.class.openapi_nullable.include?(attr)
197+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198+
end
199+
200+
hash[param] = _to_hash(value)
201+
end
202+
hash
203+
end
204+
205+
# Outputs non-array value in the form of hash
206+
# For object, use to_hash. Otherwise, just return the value
207+
# @param [Object] value Any valid value
208+
# @return [Hash] Returns the value in the form of hash
209+
def _to_hash(value)
210+
if value.is_a?(Array)
211+
value.compact.map { |v| _to_hash(v) }
212+
elsif value.is_a?(Hash)
213+
{}.tap do |hash|
214+
value.each { |k, v| hash[k] = _to_hash(v) }
215+
end
216+
elsif value.respond_to? :to_hash
217+
value.to_hash
218+
else
219+
value
220+
end
221+
end end
222+
end

0 commit comments

Comments
 (0)