Hangman/hangman.rb
def post(payload)
      begin
        raw_response = RestClient.post @request_url, payload.to_json, HEADERS
        if raw_response.code > 200
          [nil, "Unhandled Exception!"]
        else
          res = JSON.parse raw_response.body
          [res, nil]
        end
      rescue RestClient::Exception => ex
        if ERROR_HTTP_STATUS_CODES.include? ex.http_code
          res = JSON.parse ex.http_body
          message = res['message']
        else
          message = ex.message
        end
        [nil, message]
      end
    end
# Returns a tuple [response, message].
#
# The 1st element `response` represent a response message with a `hash` object.
#
# The 2nd element `message` represents a error message,
# and `nil` value indicates it exited normally, otherwise there was an error.
Returns a tuple [response, message].
The 1st element `response` represent a response message with a `hash` object.

The 2nd element `message` represents a error message,
and `nil` value indicates it exited normally, otherwise there was an error.
Returns a tuple [ response message ] . The 1st element ` response ` represent a response message with a ` hash ` object . The 2nd element ` message ` represents a error message and ` nil ` value indicates it exited normally otherwise there was an error .
def post(payload)
      begin
        raw_response = RestClient.post @request_url, payload.to_json, HEADERS
        if raw_response.code > 200
          [nil, "Unhandled Exception!"]
        else
          res = JSON.parse raw_response.body
          [res, nil]
        end
      rescue RestClient::Exception => ex
        if ERROR_HTTP_STATUS_CODES.include? ex.http_code
          res = JSON.parse ex.http_body
          message = res['message']
        else
          message = ex.message
        end
        [nil, message]
      end
    end
def post ( payload ) begin raw_response = RestClient . post @request_url , payload . to_json , HEADERS if raw_response . code > 200 [ nil , "Unhandled Exception!" ] else res = JSON . parse raw_response . body [ res , nil ] end rescue RestClient :: Exception => ex if ERROR_HTTP_STATUS_CODES . include? ex . http_code res = JSON . parse ex . http_body message = res [ 'message' ] else message = ex . message end [ nil , message ] end end
Returns a tuple [response, message].
Returns a tuple [ response message ] .
payload