Sha256: d7ae444469d8a467fec8c174380814b39b8e7147127fa8b3d3df654f9053d49c

Contents?: true

Size: 900 Bytes

Versions: 5

Compression:

Stored size: 900 Bytes

Contents

module Rents
  class Status < Rents::Connection
    # Attrs
    attr_accessor :message # API response message
    attr_accessor :http_code # HTTP Code for the request
    attr_accessor :api_code # Internal system response code
    attr_accessor :response # the JSON retrieved

    # Constructor
    def initialize(params = {})
      super # call it super initialize
      self.path = "status"
      check_it
    end

    # Check it status and 'setup' it attrs
    def check_it
      self.path = 'status'
      resp = get_request
      hash_resp = JSON.parse(resp).it_keys_to_sym
      self.http_code = resp.code
      self.message = "EndPoint not response(connection error): #{self.url_requested}" if self.http_code != 200
      self.message = hash_resp[:message] if self.http_code == 200
      self.api_code = hash_resp[:api_code]
      self.response = hash_resp

      return self
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rents-1.0.8 lib/rents/status.rb
rents-1.0.7 lib/rents/status.rb
rents-1.0.6 lib/rents/status.rb
rents-1.0.5 lib/rents/status.rb
rents-1.0.4 lib/rents/status.rb