Sha256: 4999cdf172f4f2056977c0cc31e553e141f1a95ed13ddbaef085df7f5ee95854

Contents?: true

Size: 1.59 KB

Versions: 16

Compression:

Stored size: 1.59 KB

Contents

# 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
#
class GetStatusResponse < Struct.new(:exists, :externalID, :source, :history)
  # Class Status represents elements of server response on +get_status+ Status API
  # request. Server response is sent to initializer which creates object
  # with attributes +field+, +attrs+ accessible via getters:
  #
  #  status = Status.new(...)
  #  status.field     # => Array
  #  status.attrs     # => Array of Attr
  #
  class Status < Struct.new(:field, :attrs)
  end
  # Class Attr represents elements of server response on +get_status+ Status API
  # request. Server response is sent to initializer which creates object
  # with attributes +timestamp+, +errors+, +attributes+ accessible via getters:
  #
  #  attr = Attr.new(...)
  #
  class Attr < Struct.new(:timestamp, :errors, :attributes)
  end
  # Method +from_array+ creates GetStatusResponse object
  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
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
threetaps-client-1.0.14 lib/dto/status/get_status_response.rb
threetaps-client-1.0.13 lib/dto/status/get_status_response.rb
threetaps-client-1.0.12 lib/dto/status/get_status_response.rb
threetaps-client-1.0.11 lib/dto/status/get_status_response.rb
threetaps-client-1.0.10 lib/dto/status/get_status_response.rb
threetaps-client-1.0.9 lib/dto/status/get_status_response.rb
threetaps-client-1.0.8 lib/dto/status/get_status_response.rb
threetaps-client-1.0.7 lib/dto/status/get_status_response.rb
threetaps-client-1.0.6 lib/dto/status/get_status_response.rb
threetaps-client-1.0.5 lib/dto/status/get_status_response.rb
threetaps-client-1.0.4 lib/dto/status/get_status_response.rb
threetaps-client-1.0.3 lib/dto/status/get_status_response.rb
threetaps-client-1.0.2 lib/dto/status/get_status_response.rb
threetaps-client-1.0.1 lib/dto/status/get_status_response.rb
threetaps-client-1.0.0 lib/dto/status/get_status_response.rb
threetaps-client-0.5.1 lib/dto/status/get_status_response.rb