GiphyClient 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +69 -0
  4. data/GiphyClient.gemspec +44 -0
  5. data/README.md +152 -0
  6. data/Rakefile +7 -0
  7. data/config.json +18 -0
  8. data/docs/BaseChannelModel.md +36 -0
  9. data/docs/BaseChannelModelGifs.md +9 -0
  10. data/docs/Breadcrumb.md +10 -0
  11. data/docs/Category.md +11 -0
  12. data/docs/ChannelWithChildrenModel.md +37 -0
  13. data/docs/ChannelWithChildrenModelChildren.md +9 -0
  14. data/docs/DefaultApi.md +731 -0
  15. data/docs/Gif.md +36 -0
  16. data/docs/GifImages.md +27 -0
  17. data/docs/GifImagesDownsized.md +11 -0
  18. data/docs/GifImagesDownsizedLarge.md +11 -0
  19. data/docs/GifImagesDownsizedMedium.md +11 -0
  20. data/docs/GifImagesDownsizedSmall.md +11 -0
  21. data/docs/GifImagesDownsizedStill.md +10 -0
  22. data/docs/GifImagesFixedHeight.md +15 -0
  23. data/docs/GifImagesFixedHeightDownsampled.md +13 -0
  24. data/docs/GifImagesFixedHeightSmall.md +15 -0
  25. data/docs/GifImagesFixedHeightSmallStill.md +10 -0
  26. data/docs/GifImagesFixedHeightStill.md +10 -0
  27. data/docs/GifImagesFixedWidth.md +15 -0
  28. data/docs/GifImagesFixedWidthDownsampled.md +13 -0
  29. data/docs/GifImagesFixedWidthSmall.md +15 -0
  30. data/docs/GifImagesFixedWidthSmallStill.md +10 -0
  31. data/docs/GifImagesFixedWidthStill.md +10 -0
  32. data/docs/GifImagesLooping.md +8 -0
  33. data/docs/GifImagesOriginal.md +16 -0
  34. data/docs/GifImagesOriginalStill.md +10 -0
  35. data/docs/GifImagesPreview.md +11 -0
  36. data/docs/GifImagesPreviewGif.md +11 -0
  37. data/docs/InlineResponse200.md +10 -0
  38. data/docs/InlineResponse2001.md +9 -0
  39. data/docs/InlineResponse2002.md +9 -0
  40. data/docs/InlineResponse2003.md +10 -0
  41. data/docs/InlineResponse2004.md +10 -0
  42. data/docs/InlineResponse2005.md +10 -0
  43. data/docs/InlineResponse400.md +8 -0
  44. data/docs/LastChildModel.md +37 -0
  45. data/docs/LastChildModelChildren.md +9 -0
  46. data/docs/MetaContent.md +10 -0
  47. data/docs/MetaObject.md +8 -0
  48. data/docs/Pagination.md +10 -0
  49. data/docs/RandomGif.md +30 -0
  50. data/docs/ShallowTag.md +9 -0
  51. data/docs/Tag.md +9 -0
  52. data/docs/TrendingTag.md +10 -0
  53. data/docs/User.md +13 -0
  54. data/generate.sh +12 -0
  55. data/git_push.sh +55 -0
  56. data/lib/GiphyClient.rb +84 -0
  57. data/lib/GiphyClient/api/default_api.rb +952 -0
  58. data/lib/GiphyClient/api_client.rb +375 -0
  59. data/lib/GiphyClient/api_error.rb +37 -0
  60. data/lib/GiphyClient/configuration.rb +195 -0
  61. data/lib/GiphyClient/models/base_channel_model.rb +464 -0
  62. data/lib/GiphyClient/models/base_channel_model_gifs.rb +198 -0
  63. data/lib/GiphyClient/models/breadcrumb.rb +205 -0
  64. data/lib/GiphyClient/models/category.rb +220 -0
  65. data/lib/GiphyClient/models/channel_with_children_model.rb +473 -0
  66. data/lib/GiphyClient/models/channel_with_children_model_children.rb +198 -0
  67. data/lib/GiphyClient/models/gif.rb +473 -0
  68. data/lib/GiphyClient/models/gif_images.rb +358 -0
  69. data/lib/GiphyClient/models/gif_images_downsized.rb +218 -0
  70. data/lib/GiphyClient/models/gif_images_downsized_large.rb +218 -0
  71. data/lib/GiphyClient/models/gif_images_downsized_medium.rb +218 -0
  72. data/lib/GiphyClient/models/gif_images_downsized_small.rb +218 -0
  73. data/lib/GiphyClient/models/gif_images_downsized_still.rb +208 -0
  74. data/lib/GiphyClient/models/gif_images_fixed_height.rb +258 -0
  75. data/lib/GiphyClient/models/gif_images_fixed_height_downsampled.rb +238 -0
  76. data/lib/GiphyClient/models/gif_images_fixed_height_small.rb +258 -0
  77. data/lib/GiphyClient/models/gif_images_fixed_height_small_still.rb +208 -0
  78. data/lib/GiphyClient/models/gif_images_fixed_height_still.rb +208 -0
  79. data/lib/GiphyClient/models/gif_images_fixed_width.rb +258 -0
  80. data/lib/GiphyClient/models/gif_images_fixed_width_downsampled.rb +238 -0
  81. data/lib/GiphyClient/models/gif_images_fixed_width_small.rb +258 -0
  82. data/lib/GiphyClient/models/gif_images_fixed_width_small_still.rb +208 -0
  83. data/lib/GiphyClient/models/gif_images_fixed_width_still.rb +208 -0
  84. data/lib/GiphyClient/models/gif_images_looping.rb +188 -0
  85. data/lib/GiphyClient/models/gif_images_original.rb +268 -0
  86. data/lib/GiphyClient/models/gif_images_original_still.rb +208 -0
  87. data/lib/GiphyClient/models/gif_images_preview.rb +218 -0
  88. data/lib/GiphyClient/models/gif_images_preview_gif.rb +218 -0
  89. data/lib/GiphyClient/models/inline_response_200.rb +209 -0
  90. data/lib/GiphyClient/models/inline_response_200_1.rb +197 -0
  91. data/lib/GiphyClient/models/inline_response_200_2.rb +197 -0
  92. data/lib/GiphyClient/models/inline_response_200_3.rb +207 -0
  93. data/lib/GiphyClient/models/inline_response_200_4.rb +207 -0
  94. data/lib/GiphyClient/models/inline_response_200_5.rb +207 -0
  95. data/lib/GiphyClient/models/inline_response_400.rb +187 -0
  96. data/lib/GiphyClient/models/last_child_model.rb +473 -0
  97. data/lib/GiphyClient/models/last_child_model_children.rb +198 -0
  98. data/lib/GiphyClient/models/meta_content.rb +218 -0
  99. data/lib/GiphyClient/models/meta_object.rb +187 -0
  100. data/lib/GiphyClient/models/pagination.rb +208 -0
  101. data/lib/GiphyClient/models/random_gif.rb +401 -0
  102. data/lib/GiphyClient/models/shallow_tag.rb +198 -0
  103. data/lib/GiphyClient/models/tag.rb +198 -0
  104. data/lib/GiphyClient/models/trending_tag.rb +205 -0
  105. data/lib/GiphyClient/models/user.rb +238 -0
  106. data/lib/GiphyClient/version.rb +14 -0
  107. data/public.yaml +1638 -0
  108. data/spec/api/default_api_spec.rb +260 -0
  109. data/spec/api_client_spec.rb +225 -0
  110. data/spec/configuration_spec.rb +41 -0
  111. data/spec/models/base_channel_model_gifs_spec.rb +47 -0
  112. data/spec/models/base_channel_model_spec.rb +209 -0
  113. data/spec/models/breadcrumb_spec.rb +53 -0
  114. data/spec/models/category_spec.rb +59 -0
  115. data/spec/models/channel_with_children_model_children_spec.rb +47 -0
  116. data/spec/models/channel_with_children_model_spec.rb +215 -0
  117. data/spec/models/gif_images_downsized_large_spec.rb +59 -0
  118. data/spec/models/gif_images_downsized_medium_spec.rb +59 -0
  119. data/spec/models/gif_images_downsized_small_spec.rb +59 -0
  120. data/spec/models/gif_images_downsized_spec.rb +59 -0
  121. data/spec/models/gif_images_downsized_still_spec.rb +53 -0
  122. data/spec/models/gif_images_fixed_height_downsampled_spec.rb +71 -0
  123. data/spec/models/gif_images_fixed_height_small_spec.rb +83 -0
  124. data/spec/models/gif_images_fixed_height_small_still_spec.rb +53 -0
  125. data/spec/models/gif_images_fixed_height_spec.rb +83 -0
  126. data/spec/models/gif_images_fixed_height_still_spec.rb +53 -0
  127. data/spec/models/gif_images_fixed_width_downsampled_spec.rb +71 -0
  128. data/spec/models/gif_images_fixed_width_small_spec.rb +83 -0
  129. data/spec/models/gif_images_fixed_width_small_still_spec.rb +53 -0
  130. data/spec/models/gif_images_fixed_width_spec.rb +83 -0
  131. data/spec/models/gif_images_fixed_width_still_spec.rb +53 -0
  132. data/spec/models/gif_images_looping_spec.rb +41 -0
  133. data/spec/models/gif_images_original_spec.rb +89 -0
  134. data/spec/models/gif_images_original_still_spec.rb +53 -0
  135. data/spec/models/gif_images_preview_gif_spec.rb +59 -0
  136. data/spec/models/gif_images_preview_spec.rb +59 -0
  137. data/spec/models/gif_images_spec.rb +155 -0
  138. data/spec/models/gif_spec.rb +209 -0
  139. data/spec/models/inline_response_200_1_spec.rb +47 -0
  140. data/spec/models/inline_response_200_2_spec.rb +47 -0
  141. data/spec/models/inline_response_200_3_spec.rb +53 -0
  142. data/spec/models/inline_response_200_4_spec.rb +53 -0
  143. data/spec/models/inline_response_200_5_spec.rb +53 -0
  144. data/spec/models/inline_response_200_spec.rb +53 -0
  145. data/spec/models/inline_response_400_spec.rb +41 -0
  146. data/spec/models/last_child_model_children_spec.rb +47 -0
  147. data/spec/models/last_child_model_spec.rb +215 -0
  148. data/spec/models/meta_content_spec.rb +53 -0
  149. data/spec/models/meta_object_spec.rb +41 -0
  150. data/spec/models/pagination_spec.rb +53 -0
  151. data/spec/models/random_gif_spec.rb +173 -0
  152. data/spec/models/shallow_tag_spec.rb +47 -0
  153. data/spec/models/tag_spec.rb +47 -0
  154. data/spec/models/trending_tag_spec.rb +53 -0
  155. data/spec/models/user_spec.rb +71 -0
  156. data/spec/spec_helper.rb +110 -0
  157. metadata +428 -0
@@ -0,0 +1,198 @@
1
+ =begin
2
+ #giphy-api
3
+
4
+ #Giphy's public api.
5
+
6
+ OpenAPI spec version: 0.9.3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module GiphyClient
15
+
16
+ class ShallowTag
17
+ # Category name
18
+ attr_accessor :name
19
+
20
+ # Category name, with dashes instead of spaces.
21
+ attr_accessor :name_encoded
22
+
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'name' => :'name',
28
+ :'name_encoded' => :'name_encoded'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'name' => :'String',
36
+ :'name_encoded' => :'String'
37
+ }
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ return unless attributes.is_a?(Hash)
44
+
45
+ # convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
47
+
48
+ if attributes.has_key?(:'name')
49
+ self.name = attributes[:'name']
50
+ end
51
+
52
+ if attributes.has_key?(:'name_encoded')
53
+ self.name_encoded = attributes[:'name_encoded']
54
+ end
55
+
56
+ end
57
+
58
+ # Show invalid properties with the reasons. Usually used together with valid?
59
+ # @return Array for valid properies with the reasons
60
+ def list_invalid_properties
61
+ invalid_properties = Array.new
62
+ return invalid_properties
63
+ end
64
+
65
+ # Check to see if the all the properties in the model are valid
66
+ # @return true if the model is valid
67
+ def valid?
68
+ return true
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ # @param [Object] Object to be compared
73
+ def ==(o)
74
+ return true if self.equal?(o)
75
+ self.class == o.class &&
76
+ name == o.name &&
77
+ name_encoded == o.name_encoded
78
+ end
79
+
80
+ # @see the `==` method
81
+ # @param [Object] Object to be compared
82
+ def eql?(o)
83
+ self == o
84
+ end
85
+
86
+ # Calculates hash code according to all attributes.
87
+ # @return [Fixnum] Hash code
88
+ def hash
89
+ [name, name_encoded].hash
90
+ end
91
+
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
95
+ def build_from_hash(attributes)
96
+ return nil unless attributes.is_a?(Hash)
97
+ self.class.swagger_types.each_pair do |key, type|
98
+ if type =~ /\AArray<(.*)>/i
99
+ # check to ensure the input is an array given that the the attribute
100
+ # is documented as an array but the input is not
101
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
102
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
103
+ end
104
+ elsif !attributes[self.class.attribute_map[key]].nil?
105
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
106
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
107
+ end
108
+
109
+ self
110
+ end
111
+
112
+ # Deserializes the data based on type
113
+ # @param string type Data type
114
+ # @param string value Value to be deserialized
115
+ # @return [Object] Deserialized data
116
+ def _deserialize(type, value)
117
+ case type.to_sym
118
+ when :DateTime
119
+ DateTime.parse(value)
120
+ when :Date
121
+ Date.parse(value)
122
+ when :String
123
+ value.to_s
124
+ when :Integer
125
+ value.to_i
126
+ when :Float
127
+ value.to_f
128
+ when :BOOLEAN
129
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
130
+ true
131
+ else
132
+ false
133
+ end
134
+ when :Object
135
+ # generic object (usually a Hash), return directly
136
+ value
137
+ when /\AArray<(?<inner_type>.+)>\z/
138
+ inner_type = Regexp.last_match[:inner_type]
139
+ value.map { |v| _deserialize(inner_type, v) }
140
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
141
+ k_type = Regexp.last_match[:k_type]
142
+ v_type = Regexp.last_match[:v_type]
143
+ {}.tap do |hash|
144
+ value.each do |k, v|
145
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
146
+ end
147
+ end
148
+ else # model
149
+ temp_model = GiphyClient.const_get(type).new
150
+ temp_model.build_from_hash(value)
151
+ end
152
+ end
153
+
154
+ # Returns the string representation of the object
155
+ # @return [String] String presentation of the object
156
+ def to_s
157
+ to_hash.to_s
158
+ end
159
+
160
+ # to_body is an alias to to_hash (backward compatibility)
161
+ # @return [Hash] Returns the object in the form of hash
162
+ def to_body
163
+ to_hash
164
+ end
165
+
166
+ # Returns the object in the form of hash
167
+ # @return [Hash] Returns the object in the form of hash
168
+ def to_hash
169
+ hash = {}
170
+ self.class.attribute_map.each_pair do |attr, param|
171
+ value = self.send(attr)
172
+ next if value.nil?
173
+ hash[param] = _to_hash(value)
174
+ end
175
+ hash
176
+ end
177
+
178
+ # Outputs non-array value in the form of hash
179
+ # For object, use to_hash. Otherwise, just return the value
180
+ # @param [Object] value Any valid value
181
+ # @return [Hash] Returns the value in the form of hash
182
+ def _to_hash(value)
183
+ if value.is_a?(Array)
184
+ value.compact.map{ |v| _to_hash(v) }
185
+ elsif value.is_a?(Hash)
186
+ {}.tap do |hash|
187
+ value.each { |k, v| hash[k] = _to_hash(v) }
188
+ end
189
+ elsif value.respond_to? :to_hash
190
+ value.to_hash
191
+ else
192
+ value
193
+ end
194
+ end
195
+
196
+ end
197
+
198
+ end
@@ -0,0 +1,198 @@
1
+ =begin
2
+ #giphy-api
3
+
4
+ #Giphy's public api.
5
+
6
+ OpenAPI spec version: 0.9.3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module GiphyClient
15
+
16
+ class Tag
17
+ # Category name
18
+ attr_accessor :name
19
+
20
+ # A gif which can be used as the icon for this category.
21
+ attr_accessor :gif
22
+
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'name' => :'name',
28
+ :'gif' => :'gif'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'name' => :'String',
36
+ :'gif' => :'Gif'
37
+ }
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ return unless attributes.is_a?(Hash)
44
+
45
+ # convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
47
+
48
+ if attributes.has_key?(:'name')
49
+ self.name = attributes[:'name']
50
+ end
51
+
52
+ if attributes.has_key?(:'gif')
53
+ self.gif = attributes[:'gif']
54
+ end
55
+
56
+ end
57
+
58
+ # Show invalid properties with the reasons. Usually used together with valid?
59
+ # @return Array for valid properies with the reasons
60
+ def list_invalid_properties
61
+ invalid_properties = Array.new
62
+ return invalid_properties
63
+ end
64
+
65
+ # Check to see if the all the properties in the model are valid
66
+ # @return true if the model is valid
67
+ def valid?
68
+ return true
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ # @param [Object] Object to be compared
73
+ def ==(o)
74
+ return true if self.equal?(o)
75
+ self.class == o.class &&
76
+ name == o.name &&
77
+ gif == o.gif
78
+ end
79
+
80
+ # @see the `==` method
81
+ # @param [Object] Object to be compared
82
+ def eql?(o)
83
+ self == o
84
+ end
85
+
86
+ # Calculates hash code according to all attributes.
87
+ # @return [Fixnum] Hash code
88
+ def hash
89
+ [name, gif].hash
90
+ end
91
+
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
95
+ def build_from_hash(attributes)
96
+ return nil unless attributes.is_a?(Hash)
97
+ self.class.swagger_types.each_pair do |key, type|
98
+ if type =~ /\AArray<(.*)>/i
99
+ # check to ensure the input is an array given that the the attribute
100
+ # is documented as an array but the input is not
101
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
102
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
103
+ end
104
+ elsif !attributes[self.class.attribute_map[key]].nil?
105
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
106
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
107
+ end
108
+
109
+ self
110
+ end
111
+
112
+ # Deserializes the data based on type
113
+ # @param string type Data type
114
+ # @param string value Value to be deserialized
115
+ # @return [Object] Deserialized data
116
+ def _deserialize(type, value)
117
+ case type.to_sym
118
+ when :DateTime
119
+ DateTime.parse(value)
120
+ when :Date
121
+ Date.parse(value)
122
+ when :String
123
+ value.to_s
124
+ when :Integer
125
+ value.to_i
126
+ when :Float
127
+ value.to_f
128
+ when :BOOLEAN
129
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
130
+ true
131
+ else
132
+ false
133
+ end
134
+ when :Object
135
+ # generic object (usually a Hash), return directly
136
+ value
137
+ when /\AArray<(?<inner_type>.+)>\z/
138
+ inner_type = Regexp.last_match[:inner_type]
139
+ value.map { |v| _deserialize(inner_type, v) }
140
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
141
+ k_type = Regexp.last_match[:k_type]
142
+ v_type = Regexp.last_match[:v_type]
143
+ {}.tap do |hash|
144
+ value.each do |k, v|
145
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
146
+ end
147
+ end
148
+ else # model
149
+ temp_model = GiphyClient.const_get(type).new
150
+ temp_model.build_from_hash(value)
151
+ end
152
+ end
153
+
154
+ # Returns the string representation of the object
155
+ # @return [String] String presentation of the object
156
+ def to_s
157
+ to_hash.to_s
158
+ end
159
+
160
+ # to_body is an alias to to_hash (backward compatibility)
161
+ # @return [Hash] Returns the object in the form of hash
162
+ def to_body
163
+ to_hash
164
+ end
165
+
166
+ # Returns the object in the form of hash
167
+ # @return [Hash] Returns the object in the form of hash
168
+ def to_hash
169
+ hash = {}
170
+ self.class.attribute_map.each_pair do |attr, param|
171
+ value = self.send(attr)
172
+ next if value.nil?
173
+ hash[param] = _to_hash(value)
174
+ end
175
+ hash
176
+ end
177
+
178
+ # Outputs non-array value in the form of hash
179
+ # For object, use to_hash. Otherwise, just return the value
180
+ # @param [Object] value Any valid value
181
+ # @return [Hash] Returns the value in the form of hash
182
+ def _to_hash(value)
183
+ if value.is_a?(Array)
184
+ value.compact.map{ |v| _to_hash(v) }
185
+ elsif value.is_a?(Hash)
186
+ {}.tap do |hash|
187
+ value.each { |k, v| hash[k] = _to_hash(v) }
188
+ end
189
+ elsif value.respond_to? :to_hash
190
+ value.to_hash
191
+ else
192
+ value
193
+ end
194
+ end
195
+
196
+ end
197
+
198
+ end
@@ -0,0 +1,205 @@
1
+ =begin
2
+ #giphy-api
3
+
4
+ #Giphy's public api.
5
+
6
+ OpenAPI spec version: 0.9.3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module GiphyClient
15
+
16
+ class TrendingTag
17
+ attr_accessor :id
18
+
19
+ attr_accessor :name_encoded
20
+
21
+ attr_accessor :name
22
+
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'id' => :'id',
28
+ :'name_encoded' => :'name_encoded',
29
+ :'name' => :'name'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'id' => :'Integer',
37
+ :'name_encoded' => :'String',
38
+ :'name' => :'String'
39
+ }
40
+ end
41
+
42
+ # Initializes the object
43
+ # @param [Hash] attributes Model attributes in the form of hash
44
+ def initialize(attributes = {})
45
+ return unless attributes.is_a?(Hash)
46
+
47
+ # convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
49
+
50
+ if attributes.has_key?(:'id')
51
+ self.id = attributes[:'id']
52
+ end
53
+
54
+ if attributes.has_key?(:'name_encoded')
55
+ self.name_encoded = attributes[:'name_encoded']
56
+ end
57
+
58
+ if attributes.has_key?(:'name')
59
+ self.name = attributes[:'name']
60
+ end
61
+
62
+ end
63
+
64
+ # Show invalid properties with the reasons. Usually used together with valid?
65
+ # @return Array for valid properies with the reasons
66
+ def list_invalid_properties
67
+ invalid_properties = Array.new
68
+ return invalid_properties
69
+ end
70
+
71
+ # Check to see if the all the properties in the model are valid
72
+ # @return true if the model is valid
73
+ def valid?
74
+ return true
75
+ end
76
+
77
+ # Checks equality by comparing each attribute.
78
+ # @param [Object] Object to be compared
79
+ def ==(o)
80
+ return true if self.equal?(o)
81
+ self.class == o.class &&
82
+ id == o.id &&
83
+ name_encoded == o.name_encoded &&
84
+ name == o.name
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Fixnum] Hash code
95
+ def hash
96
+ [id, name_encoded, name].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def build_from_hash(attributes)
103
+ return nil unless attributes.is_a?(Hash)
104
+ self.class.swagger_types.each_pair do |key, type|
105
+ if type =~ /\AArray<(.*)>/i
106
+ # check to ensure the input is an array given that the the attribute
107
+ # is documented as an array but the input is not
108
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
109
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
110
+ end
111
+ elsif !attributes[self.class.attribute_map[key]].nil?
112
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
113
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
114
+ end
115
+
116
+ self
117
+ end
118
+
119
+ # Deserializes the data based on type
120
+ # @param string type Data type
121
+ # @param string value Value to be deserialized
122
+ # @return [Object] Deserialized data
123
+ def _deserialize(type, value)
124
+ case type.to_sym
125
+ when :DateTime
126
+ DateTime.parse(value)
127
+ when :Date
128
+ Date.parse(value)
129
+ when :String
130
+ value.to_s
131
+ when :Integer
132
+ value.to_i
133
+ when :Float
134
+ value.to_f
135
+ when :BOOLEAN
136
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
137
+ true
138
+ else
139
+ false
140
+ end
141
+ when :Object
142
+ # generic object (usually a Hash), return directly
143
+ value
144
+ when /\AArray<(?<inner_type>.+)>\z/
145
+ inner_type = Regexp.last_match[:inner_type]
146
+ value.map { |v| _deserialize(inner_type, v) }
147
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
148
+ k_type = Regexp.last_match[:k_type]
149
+ v_type = Regexp.last_match[:v_type]
150
+ {}.tap do |hash|
151
+ value.each do |k, v|
152
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
153
+ end
154
+ end
155
+ else # model
156
+ temp_model = GiphyClient.const_get(type).new
157
+ temp_model.build_from_hash(value)
158
+ end
159
+ end
160
+
161
+ # Returns the string representation of the object
162
+ # @return [String] String presentation of the object
163
+ def to_s
164
+ to_hash.to_s
165
+ end
166
+
167
+ # to_body is an alias to to_hash (backward compatibility)
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_body
170
+ to_hash
171
+ end
172
+
173
+ # Returns the object in the form of hash
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_hash
176
+ hash = {}
177
+ self.class.attribute_map.each_pair do |attr, param|
178
+ value = self.send(attr)
179
+ next if value.nil?
180
+ hash[param] = _to_hash(value)
181
+ end
182
+ hash
183
+ end
184
+
185
+ # Outputs non-array value in the form of hash
186
+ # For object, use to_hash. Otherwise, just return the value
187
+ # @param [Object] value Any valid value
188
+ # @return [Hash] Returns the value in the form of hash
189
+ def _to_hash(value)
190
+ if value.is_a?(Array)
191
+ value.compact.map{ |v| _to_hash(v) }
192
+ elsif value.is_a?(Hash)
193
+ {}.tap do |hash|
194
+ value.each { |k, v| hash[k] = _to_hash(v) }
195
+ end
196
+ elsif value.respond_to? :to_hash
197
+ value.to_hash
198
+ else
199
+ value
200
+ end
201
+ end
202
+
203
+ end
204
+
205
+ end