Class: ApraService::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/apralib/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponse

Returns a new instance of Response.



7
8
9
# File 'lib/apralib/response.rb', line 7

def initialize
  @failed_notifications = []
end

Instance Attribute Details

#failed_notificationsObject

Returns the value of attribute failed_notifications.



5
6
7
# File 'lib/apralib/response.rb', line 5

def failed_notifications
  @failed_notifications
end

Class Method Details

.from_hash(hash) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/apralib/response.rb', line 12

def self.from_hash(hash)
  puts hash.inspect
  response = Response.new
  raw_response = hash[:lisaa_apurahat_response]
  failures = raw_response[:epaonnistuneet_ilmoitukset]
  if failures
    failures = [failures] unless failures.is_a? Array
    response.failed_notifications = failures.map {|notification| NotificationResponse.from_hash(notification) }
  end
  response
end