Class: SuggestGrid::BulkPostResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/suggestgrid/models/bulk_post_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(message = nil, errors = nil) ⇒ BulkPostResponse

Returns a new instance of BulkPostResponse.



23
24
25
26
27
# File 'lib/suggestgrid/models/bulk_post_response.rb', line 23

def initialize(message = nil,
               errors = nil)
  @message = message
  @errors = errors
end

Instance Attribute Details

#errorsList of BulkPostError

Message of the response.

Returns:



11
12
13
# File 'lib/suggestgrid/models/bulk_post_response.rb', line 11

def errors
  @errors
end

#messageString

Message of the response.

Returns:



7
8
9
# File 'lib/suggestgrid/models/bulk_post_response.rb', line 7

def message
  @message
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/suggestgrid/models/bulk_post_response.rb', line 30

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash
  message = 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

  # Create object from extracted values
  BulkPostResponse.new(message,
                       errors)
end

.namesObject

A mapping from model property names to API property names



14
15
16
17
18
19
20
21
# File 'lib/suggestgrid/models/bulk_post_response.rb', line 14

def self.names
  if @_hash.nil?
    @_hash = {}
    @_hash["message"] = "message"
    @_hash["errors"] = "errors"
  end
  @_hash
end