package-test-ruby 1.0.3

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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +174 -0
  4. data/bin/console +15 -0
  5. data/lib/swagger_petstore_open_api30/api_helper.rb +10 -0
  6. data/lib/swagger_petstore_open_api30/client.rb +90 -0
  7. data/lib/swagger_petstore_open_api30/configuration.rb +173 -0
  8. data/lib/swagger_petstore_open_api30/controllers/base_controller.rb +60 -0
  9. data/lib/swagger_petstore_open_api30/controllers/pet_controller.rb +271 -0
  10. data/lib/swagger_petstore_open_api30/controllers/store_controller.rb +125 -0
  11. data/lib/swagger_petstore_open_api30/controllers/user_controller.rb +223 -0
  12. data/lib/swagger_petstore_open_api30/exceptions/api_exception.rb +21 -0
  13. data/lib/swagger_petstore_open_api30/exceptions/o_auth_provider_exception.rb +64 -0
  14. data/lib/swagger_petstore_open_api30/http/auth/api_key.rb +52 -0
  15. data/lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb +113 -0
  16. data/lib/swagger_petstore_open_api30/http/http_call_back.rb +10 -0
  17. data/lib/swagger_petstore_open_api30/http/http_method_enum.rb +10 -0
  18. data/lib/swagger_petstore_open_api30/http/http_request.rb +10 -0
  19. data/lib/swagger_petstore_open_api30/http/http_response.rb +10 -0
  20. data/lib/swagger_petstore_open_api30/http/proxy_settings.rb +22 -0
  21. data/lib/swagger_petstore_open_api30/models/api_response.rb +101 -0
  22. data/lib/swagger_petstore_open_api30/models/base_model.rb +110 -0
  23. data/lib/swagger_petstore_open_api30/models/category.rb +88 -0
  24. data/lib/swagger_petstore_open_api30/models/o_auth_provider_error_enum.rb +62 -0
  25. data/lib/swagger_petstore_open_api30/models/o_auth_scope_petstore_auth_enum.rb +36 -0
  26. data/lib/swagger_petstore_open_api30/models/o_auth_token.rb +125 -0
  27. data/lib/swagger_petstore_open_api30/models/order.rb +151 -0
  28. data/lib/swagger_petstore_open_api30/models/pet.rb +151 -0
  29. data/lib/swagger_petstore_open_api30/models/status1_enum.rb +40 -0
  30. data/lib/swagger_petstore_open_api30/models/status2_enum.rb +40 -0
  31. data/lib/swagger_petstore_open_api30/models/status_enum.rb +40 -0
  32. data/lib/swagger_petstore_open_api30/models/tag.rb +88 -0
  33. data/lib/swagger_petstore_open_api30/models/user.rb +167 -0
  34. data/lib/swagger_petstore_open_api30/utilities/date_time_helper.rb +11 -0
  35. data/lib/swagger_petstore_open_api30/utilities/file_wrapper.rb +28 -0
  36. data/lib/swagger_petstore_open_api30/utilities/xml_utilities.rb +12 -0
  37. data/lib/swagger_petstore_open_api30.rb +59 -0
  38. data/test/controllers/controller_test_base.rb +28 -0
  39. data/test/controllers/test_pet_controller.rb +50 -0
  40. data/test/controllers/test_store_controller.rb +55 -0
  41. data/test/controllers/test_user_controller.rb +156 -0
  42. data/test/http_response_catcher.rb +19 -0
  43. metadata +153 -0
@@ -0,0 +1,36 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # OAuth 2 scopes supported by the API
8
+ class OAuthScopePetstoreAuthEnum
9
+ O_AUTH_SCOPE_PETSTORE_AUTH_ENUM = [
10
+ # modify pets in your account
11
+ WRITEPETS = 'write:pets'.freeze,
12
+
13
+ # read your pets
14
+ READPETS = 'read:pets'.freeze
15
+ ].freeze
16
+
17
+ def self.validate(value)
18
+ return false if value.nil?
19
+
20
+ O_AUTH_SCOPE_PETSTORE_AUTH_ENUM.include?(value)
21
+ end
22
+
23
+ def self.from_value(value, default_value = WRITEPETS)
24
+ return default_value if value.nil?
25
+
26
+ str = value.to_s.strip
27
+
28
+ case str.downcase
29
+ when 'writepets' then WRITEPETS
30
+ when 'readpets' then READPETS
31
+ else
32
+ default_value
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,125 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # OAuth 2 Authorization endpoint response
8
+ class OAuthToken < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Access token
13
+ # @return [String]
14
+ attr_accessor :access_token
15
+
16
+ # Type of access token
17
+ # @return [String]
18
+ attr_accessor :token_type
19
+
20
+ # Time in seconds before the access token expires
21
+ # @return [Integer]
22
+ attr_accessor :expires_in
23
+
24
+ # List of scopes granted
25
+ # This is a space-delimited list of strings.
26
+ # @return [String]
27
+ attr_accessor :scope
28
+
29
+ # Time of token expiry as unix timestamp (UTC)
30
+ # @return [Integer]
31
+ attr_accessor :expiry
32
+
33
+ # Refresh token
34
+ # Used to get a new access token when it expires.
35
+ # @return [String]
36
+ attr_accessor :refresh_token
37
+
38
+ # A mapping from model property names to API property names.
39
+ def self.names
40
+ @_hash = {} if @_hash.nil?
41
+ @_hash['access_token'] = 'access_token'
42
+ @_hash['token_type'] = 'token_type'
43
+ @_hash['expires_in'] = 'expires_in'
44
+ @_hash['scope'] = 'scope'
45
+ @_hash['expiry'] = 'expiry'
46
+ @_hash['refresh_token'] = 'refresh_token'
47
+ @_hash
48
+ end
49
+
50
+ # An array for optional fields
51
+ def self.optionals
52
+ %w[
53
+ expires_in
54
+ scope
55
+ expiry
56
+ refresh_token
57
+ ]
58
+ end
59
+
60
+ # An array for nullable fields
61
+ def self.nullables
62
+ []
63
+ end
64
+
65
+ def initialize(access_token = nil, token_type = nil, expires_in = SKIP,
66
+ scope = SKIP, expiry = SKIP, refresh_token = SKIP)
67
+ @access_token = access_token
68
+ @token_type = token_type
69
+ @expires_in = expires_in unless expires_in == SKIP
70
+ @scope = scope unless scope == SKIP
71
+ @expiry = expiry unless expiry == SKIP
72
+ @refresh_token = refresh_token unless refresh_token == SKIP
73
+ end
74
+
75
+ # Creates an instance of the object from a hash.
76
+ def self.from_hash(hash)
77
+ return nil unless hash
78
+
79
+ # Extract variables from the hash.
80
+ access_token = hash.key?('access_token') ? hash['access_token'] : nil
81
+ token_type = hash.key?('token_type') ? hash['token_type'] : nil
82
+ expires_in = hash.key?('expires_in') ? hash['expires_in'] : SKIP
83
+ scope = hash.key?('scope') ? hash['scope'] : SKIP
84
+ expiry = hash.key?('expiry') ? hash['expiry'] : SKIP
85
+ refresh_token = hash.key?('refresh_token') ? hash['refresh_token'] : SKIP
86
+
87
+ # Create object from extracted values.
88
+ OAuthToken.new(access_token,
89
+ token_type,
90
+ expires_in,
91
+ scope,
92
+ expiry,
93
+ refresh_token)
94
+ end
95
+
96
+ def self.from_element(root)
97
+ access_token = XmlUtilities.from_element(root, 'access_token', String)
98
+ token_type = XmlUtilities.from_element(root, 'token_type', String)
99
+ expires_in = XmlUtilities.from_element(root, 'expires_in', Integer)
100
+ scope = XmlUtilities.from_element(root, 'scope', String)
101
+ expiry = XmlUtilities.from_element(root, 'expiry', Integer)
102
+ refresh_token = XmlUtilities.from_element(root, 'refresh_token', String)
103
+
104
+ new(access_token,
105
+ token_type,
106
+ expires_in,
107
+ scope,
108
+ expiry,
109
+ refresh_token)
110
+ end
111
+
112
+ def to_xml_element(doc, root_name)
113
+ root = doc.create_element(root_name)
114
+
115
+ XmlUtilities.add_as_subelement(doc, root, 'access_token', access_token)
116
+ XmlUtilities.add_as_subelement(doc, root, 'token_type', token_type)
117
+ XmlUtilities.add_as_subelement(doc, root, 'expires_in', expires_in)
118
+ XmlUtilities.add_as_subelement(doc, root, 'scope', scope)
119
+ XmlUtilities.add_as_subelement(doc, root, 'expiry', expiry)
120
+ XmlUtilities.add_as_subelement(doc, root, 'refresh_token', refresh_token)
121
+
122
+ root
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,151 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module SwaggerPetstoreOpenApi30
8
+ # Order Model.
9
+ class Order < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # TODO: Write general description for this method
14
+ # @return [Integer]
15
+ attr_accessor :id
16
+
17
+ # TODO: Write general description for this method
18
+ # @return [Integer]
19
+ attr_accessor :pet_id
20
+
21
+ # TODO: Write general description for this method
22
+ # @return [Integer]
23
+ attr_accessor :quantity
24
+
25
+ # TODO: Write general description for this method
26
+ # @return [DateTime]
27
+ attr_accessor :ship_date
28
+
29
+ # Order Status
30
+ # @return [StatusEnum]
31
+ attr_accessor :status
32
+
33
+ # Order Status
34
+ # @return [TrueClass | FalseClass]
35
+ attr_accessor :complete
36
+
37
+ # A mapping from model property names to API property names.
38
+ def self.names
39
+ @_hash = {} if @_hash.nil?
40
+ @_hash['id'] = 'id'
41
+ @_hash['pet_id'] = 'petId'
42
+ @_hash['quantity'] = 'quantity'
43
+ @_hash['ship_date'] = 'shipDate'
44
+ @_hash['status'] = 'status'
45
+ @_hash['complete'] = 'complete'
46
+ @_hash
47
+ end
48
+
49
+ # An array for optional fields
50
+ def self.optionals
51
+ %w[
52
+ id
53
+ pet_id
54
+ quantity
55
+ ship_date
56
+ status
57
+ complete
58
+ ]
59
+ end
60
+
61
+ # An array for nullable fields
62
+ def self.nullables
63
+ []
64
+ end
65
+
66
+ def initialize(id = SKIP, pet_id = SKIP, quantity = SKIP, ship_date = SKIP,
67
+ status = SKIP, complete = SKIP)
68
+ @id = id unless id == SKIP
69
+ @pet_id = pet_id unless pet_id == SKIP
70
+ @quantity = quantity unless quantity == SKIP
71
+ @ship_date = ship_date unless ship_date == SKIP
72
+ @status = status unless status == SKIP
73
+ @complete = complete unless complete == SKIP
74
+ end
75
+
76
+ # Creates an instance of the object from a hash.
77
+ def self.from_hash(hash)
78
+ return nil unless hash
79
+
80
+ # Extract variables from the hash.
81
+ id = hash.key?('id') ? hash['id'] : SKIP
82
+ pet_id = hash.key?('petId') ? hash['petId'] : SKIP
83
+ quantity = hash.key?('quantity') ? hash['quantity'] : SKIP
84
+ ship_date = if hash.key?('shipDate')
85
+ (DateTimeHelper.from_rfc3339(hash['shipDate']) if hash['shipDate'])
86
+ else
87
+ SKIP
88
+ end
89
+ status = hash.key?('status') ? hash['status'] : SKIP
90
+ complete = hash.key?('complete') ? hash['complete'] : SKIP
91
+
92
+ # Create object from extracted values.
93
+ Order.new(id,
94
+ pet_id,
95
+ quantity,
96
+ ship_date,
97
+ status,
98
+ complete)
99
+ end
100
+
101
+ def to_custom_ship_date
102
+ DateTimeHelper.to_rfc3339(ship_date)
103
+ end
104
+
105
+ def self.from_element(root)
106
+ id = XmlUtilities.from_element(root, 'id', Integer)
107
+ pet_id = XmlUtilities.from_element(root, 'petId', Integer)
108
+ quantity = XmlUtilities.from_element(root, 'quantity', Integer)
109
+ ship_date = XmlUtilities.from_element(root, 'shipDate', String,
110
+ datetime_format: 'rfc3339')
111
+ status = XmlUtilities.from_element(root, 'status', String)
112
+ complete = XmlUtilities.from_element(root, 'complete', TrueClass)
113
+
114
+ new(id,
115
+ pet_id,
116
+ quantity,
117
+ ship_date,
118
+ status,
119
+ complete)
120
+ end
121
+
122
+ def to_xml_element(doc, root_name)
123
+ root = doc.create_element(root_name)
124
+
125
+ XmlUtilities.add_as_subelement(doc, root, 'id', id)
126
+ XmlUtilities.add_as_subelement(doc, root, 'petId', pet_id)
127
+ XmlUtilities.add_as_subelement(doc, root, 'quantity', quantity)
128
+ XmlUtilities.add_as_subelement(doc, root, 'shipDate', ship_date,
129
+ datetime_format: 'rfc3339')
130
+ XmlUtilities.add_as_subelement(doc, root, 'status', status)
131
+ XmlUtilities.add_as_subelement(doc, root, 'complete', complete)
132
+
133
+ root
134
+ end
135
+
136
+ # Provides a human-readable string representation of the object.
137
+ def to_s
138
+ class_name = self.class.name.split('::').last
139
+ "<#{class_name} id: #{@id}, pet_id: #{@pet_id}, quantity: #{@quantity}, ship_date:"\
140
+ " #{@ship_date}, status: #{@status}, complete: #{@complete}>"
141
+ end
142
+
143
+ # Provides a debugging-friendly string with detailed object information.
144
+ def inspect
145
+ class_name = self.class.name.split('::').last
146
+ "<#{class_name} id: #{@id.inspect}, pet_id: #{@pet_id.inspect}, quantity:"\
147
+ " #{@quantity.inspect}, ship_date: #{@ship_date.inspect}, status: #{@status.inspect},"\
148
+ " complete: #{@complete.inspect}>"
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,151 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # Pet Model.
8
+ class Pet < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Integer]
14
+ attr_accessor :id
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [String]
18
+ attr_accessor :name
19
+
20
+ # TODO: Write general description for this method
21
+ # @return [Category]
22
+ attr_accessor :category
23
+
24
+ # TODO: Write general description for this method
25
+ # @return [Array[String]]
26
+ attr_accessor :photo_urls
27
+
28
+ # TODO: Write general description for this method
29
+ # @return [Array[Tag]]
30
+ attr_accessor :tags
31
+
32
+ # pet status in the store
33
+ # @return [Status1Enum]
34
+ attr_accessor :status
35
+
36
+ # A mapping from model property names to API property names.
37
+ def self.names
38
+ @_hash = {} if @_hash.nil?
39
+ @_hash['id'] = 'id'
40
+ @_hash['name'] = 'name'
41
+ @_hash['category'] = 'category'
42
+ @_hash['photo_urls'] = 'photoUrls'
43
+ @_hash['tags'] = 'tags'
44
+ @_hash['status'] = 'status'
45
+ @_hash
46
+ end
47
+
48
+ # An array for optional fields
49
+ def self.optionals
50
+ %w[
51
+ id
52
+ category
53
+ tags
54
+ status
55
+ ]
56
+ end
57
+
58
+ # An array for nullable fields
59
+ def self.nullables
60
+ []
61
+ end
62
+
63
+ def initialize(name = nil, photo_urls = nil, id = SKIP, category = SKIP,
64
+ tags = SKIP, status = SKIP)
65
+ @id = id unless id == SKIP
66
+ @name = name
67
+ @category = category unless category == SKIP
68
+ @photo_urls = photo_urls
69
+ @tags = tags unless tags == SKIP
70
+ @status = status unless status == SKIP
71
+ end
72
+
73
+ # Creates an instance of the object from a hash.
74
+ def self.from_hash(hash)
75
+ return nil unless hash
76
+
77
+ # Extract variables from the hash.
78
+ name = hash.key?('name') ? hash['name'] : nil
79
+ photo_urls = hash.key?('photoUrls') ? hash['photoUrls'] : nil
80
+ id = hash.key?('id') ? hash['id'] : SKIP
81
+ category = Category.from_hash(hash['category']) if hash['category']
82
+ # Parameter is an array, so we need to iterate through it
83
+ tags = nil
84
+ unless hash['tags'].nil?
85
+ tags = []
86
+ hash['tags'].each do |structure|
87
+ tags << (Tag.from_hash(structure) if structure)
88
+ end
89
+ end
90
+
91
+ tags = SKIP unless hash.key?('tags')
92
+ status = hash.key?('status') ? hash['status'] : SKIP
93
+
94
+ # Create object from extracted values.
95
+ Pet.new(name,
96
+ photo_urls,
97
+ id,
98
+ category,
99
+ tags,
100
+ status)
101
+ end
102
+
103
+ def self.from_element(root)
104
+ name = XmlUtilities.from_element(root, 'name', String)
105
+ photo_urls = XmlUtilities.from_element_to_array(
106
+ root, 'photoUrl', String, wrapping_element_name: 'photoUrls'
107
+ )
108
+ id = XmlUtilities.from_element(root, 'id', Integer)
109
+ category = XmlUtilities.from_element(root, 'category', Category)
110
+ tags = XmlUtilities.from_element_to_array(root, 'tag', Tag,
111
+ wrapping_element_name: 'tags')
112
+ status = XmlUtilities.from_element(root, 'status', String)
113
+
114
+ new(name,
115
+ photo_urls,
116
+ id,
117
+ category,
118
+ tags,
119
+ status)
120
+ end
121
+
122
+ def to_xml_element(doc, root_name)
123
+ root = doc.create_element(root_name)
124
+
125
+ XmlUtilities.add_as_subelement(doc, root, 'name', name)
126
+ XmlUtilities.add_array_as_subelement(doc, root, 'photoUrl', photo_urls,
127
+ wrapping_element_name: 'photoUrls')
128
+ XmlUtilities.add_as_subelement(doc, root, 'id', id)
129
+ XmlUtilities.add_as_subelement(doc, root, 'category', category)
130
+ XmlUtilities.add_array_as_subelement(doc, root, 'tag', tags,
131
+ wrapping_element_name: 'tags')
132
+ XmlUtilities.add_as_subelement(doc, root, 'status', status)
133
+
134
+ root
135
+ end
136
+
137
+ # Provides a human-readable string representation of the object.
138
+ def to_s
139
+ class_name = self.class.name.split('::').last
140
+ "<#{class_name} id: #{@id}, name: #{@name}, category: #{@category}, photo_urls:"\
141
+ " #{@photo_urls}, tags: #{@tags}, status: #{@status}>"
142
+ end
143
+
144
+ # Provides a debugging-friendly string with detailed object information.
145
+ def inspect
146
+ class_name = self.class.name.split('::').last
147
+ "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, category: #{@category.inspect},"\
148
+ " photo_urls: #{@photo_urls.inspect}, tags: #{@tags.inspect}, status: #{@status.inspect}>"
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,40 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # pet status in the store
8
+ class Status1Enum
9
+ STATUS1_ENUM = [
10
+ # TODO: Write general description for AVAILABLE
11
+ AVAILABLE = 'available'.freeze,
12
+
13
+ # TODO: Write general description for PENDING
14
+ PENDING = 'pending'.freeze,
15
+
16
+ # TODO: Write general description for SOLD
17
+ SOLD = 'sold'.freeze
18
+ ].freeze
19
+
20
+ def self.validate(value)
21
+ return false if value.nil?
22
+
23
+ STATUS1_ENUM.include?(value)
24
+ end
25
+
26
+ def self.from_value(value, default_value = AVAILABLE)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'available' then AVAILABLE
33
+ when 'pending' then PENDING
34
+ when 'sold' then SOLD
35
+ else
36
+ default_value
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # status2.
8
+ class Status2Enum
9
+ STATUS2_ENUM = [
10
+ # TODO: Write general description for AVAILABLE
11
+ AVAILABLE = 'available'.freeze,
12
+
13
+ # TODO: Write general description for PENDING
14
+ PENDING = 'pending'.freeze,
15
+
16
+ # TODO: Write general description for SOLD
17
+ SOLD = 'sold'.freeze
18
+ ].freeze
19
+
20
+ def self.validate(value)
21
+ return false if value.nil?
22
+
23
+ STATUS2_ENUM.include?(value)
24
+ end
25
+
26
+ def self.from_value(value, default_value = AVAILABLE)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'available' then AVAILABLE
33
+ when 'pending' then PENDING
34
+ when 'sold' then SOLD
35
+ else
36
+ default_value
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # Order Status
8
+ class StatusEnum
9
+ STATUS_ENUM = [
10
+ # TODO: Write general description for PLACED
11
+ PLACED = 'placed'.freeze,
12
+
13
+ # TODO: Write general description for APPROVED
14
+ APPROVED = 'approved'.freeze,
15
+
16
+ # TODO: Write general description for DELIVERED
17
+ DELIVERED = 'delivered'.freeze
18
+ ].freeze
19
+
20
+ def self.validate(value)
21
+ return false if value.nil?
22
+
23
+ STATUS_ENUM.include?(value)
24
+ end
25
+
26
+ def self.from_value(value, default_value = PLACED)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'placed' then PLACED
33
+ when 'approved' then APPROVED
34
+ when 'delivered' then DELIVERED
35
+ else
36
+ default_value
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,88 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # Tag Model.
8
+ class Tag < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Integer]
14
+ attr_accessor :id
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [String]
18
+ attr_accessor :name
19
+
20
+ # A mapping from model property names to API property names.
21
+ def self.names
22
+ @_hash = {} if @_hash.nil?
23
+ @_hash['id'] = 'id'
24
+ @_hash['name'] = 'name'
25
+ @_hash
26
+ end
27
+
28
+ # An array for optional fields
29
+ def self.optionals
30
+ %w[
31
+ id
32
+ name
33
+ ]
34
+ end
35
+
36
+ # An array for nullable fields
37
+ def self.nullables
38
+ []
39
+ end
40
+
41
+ def initialize(id = SKIP, name = SKIP)
42
+ @id = id unless id == SKIP
43
+ @name = name unless name == SKIP
44
+ end
45
+
46
+ # Creates an instance of the object from a hash.
47
+ def self.from_hash(hash)
48
+ return nil unless hash
49
+
50
+ # Extract variables from the hash.
51
+ id = hash.key?('id') ? hash['id'] : SKIP
52
+ name = hash.key?('name') ? hash['name'] : SKIP
53
+
54
+ # Create object from extracted values.
55
+ Tag.new(id,
56
+ name)
57
+ end
58
+
59
+ def self.from_element(root)
60
+ id = XmlUtilities.from_element(root, 'id', Integer)
61
+ name = XmlUtilities.from_element(root, 'name', String)
62
+
63
+ new(id,
64
+ name)
65
+ end
66
+
67
+ def to_xml_element(doc, root_name)
68
+ root = doc.create_element(root_name)
69
+
70
+ XmlUtilities.add_as_subelement(doc, root, 'id', id)
71
+ XmlUtilities.add_as_subelement(doc, root, 'name', name)
72
+
73
+ root
74
+ end
75
+
76
+ # Provides a human-readable string representation of the object.
77
+ def to_s
78
+ class_name = self.class.name.split('::').last
79
+ "<#{class_name} id: #{@id}, name: #{@name}>"
80
+ end
81
+
82
+ # Provides a debugging-friendly string with detailed object information.
83
+ def inspect
84
+ class_name = self.class.name.split('::').last
85
+ "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}>"
86
+ end
87
+ end
88
+ end