Class: SuggestGrid::BulkPostResponse
- Defined in:
- lib/suggest_grid/models/bulk_post_response.rb
Instance Attribute Summary collapse
-
#errors ⇒ List of BulkPostError
Message of the response.
-
#message ⇒ String
Message of the response.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(message = nil, errors = nil, additional_properties = {}) ⇒ BulkPostResponse
constructor
A new instance of BulkPostResponse.
Methods inherited from BaseModel
#method_missing, #respond_to?, #to_hash, #to_json
Constructor Details
#initialize(message = nil, errors = nil, additional_properties = {}) ⇒ BulkPostResponse
23 24 25 26 27 28 29 30 31 |
# File 'lib/suggest_grid/models/bulk_post_response.rb', line 23 def initialize( = nil, errors = nil, additional_properties = {}) = @errors = errors # Add additional model properties to the instance additional_properties.each {|name, value| instance_variable_set("@#{name}", value)} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SuggestGrid::BaseModel
Instance Attribute Details
#errors ⇒ List of BulkPostError
Message of the response.
11 12 13 |
# File 'lib/suggest_grid/models/bulk_post_response.rb', line 11 def errors @errors end |
#message ⇒ String
Message of the response.
7 8 9 |
# File 'lib/suggest_grid/models/bulk_post_response.rb', line 7 def end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/suggest_grid/models/bulk_post_response.rb', line 34 def self.from_hash(hash) if hash == nil nil else # Extract variables from the hash = hash["message"] # Parameter is an array, so we need to iterate through it errors = nil if hash["errors"] != nil errors = Array.new hash["errors"].each{|structure| errors << (BulkPostError.from_hash(structure) if structure)} end # Clean out expected properties from Hash names.values.each {|k| hash.delete(k)} # Create object from extracted values BulkPostResponse.new(, errors, hash) end end |
.names ⇒ Object
A mapping from model property names to API property names
14 15 16 17 18 19 20 21 |
# File 'lib/suggest_grid/models/bulk_post_response.rb', line 14 def self.names if @hash.nil? @hash = {} @hash["message"] = "message" @hash["errors"] = "errors" end @hash end |