Class: GetStatusResponse

Inherits:
Struct
  • Object
show all
Defined in:
lib/dto/status/get_status_response.rb

Overview

Class GetStatusResponse represents server response on get_status Status API request. Server response is sent to from_array method which creates objects attributes exists, externalID, source, history accessible via getters:

  • exists

  • externalID

  • source

  • history

Example:

response = GetStatusResponse.from_array(...)    # => Array

Defined Under Namespace

Classes: Attr, Status

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Struct

from_hash

Instance Attribute Details

#existsObject

Returns the value of attribute exists

Returns:

  • (Object)

    the current value of exists



13
14
15
# File 'lib/dto/status/get_status_response.rb', line 13

def exists
  @exists
end

#externalIDObject

Returns the value of attribute externalID

Returns:

  • (Object)

    the current value of externalID



13
14
15
# File 'lib/dto/status/get_status_response.rb', line 13

def externalID
  @externalID
end

#historyObject

Returns the value of attribute history

Returns:

  • (Object)

    the current value of history



13
14
15
# File 'lib/dto/status/get_status_response.rb', line 13

def history
  @history
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



13
14
15
# File 'lib/dto/status/get_status_response.rb', line 13

def source
  @source
end

Class Method Details

.from_array(json) ⇒ Object

Method from_array creates GetStatusResponse object



33
34
35
36
37
38
39
40
41
42
# File 'lib/dto/status/get_status_response.rb', line 33

def self.from_array(json)
   json.each do |hash|
    hash.each do |key, value|
      self.new("#{key}=".to_sym, key == 'history' ?  value.collect {
        |key, items| Status.new(:field => key, :attrs => items.collect {|item| 
         Attr.new(:timestamp => item["timestamp"], :errors => item["errors"], :attributes => item["attributes"]) }
        )} : value )
    end
  end
end