class Ravelin::Response

Attributes

action[R]
ato[R]
client_reviewed_status[R]
comment[R]
customer_id[R]
http_body[R]
http_status[R]
label[R]
score[R]
score_id[R]
source[R]
tag_names[R]
tags[R]
warnings[R]

Public Class Methods

new(faraday_response) click to toggle source
# File lib/ravelin/response.rb, line 18
def initialize(faraday_response)
  return if faraday_response.body.nil? || faraday_response.body.empty?
  response_body = faraday_response.body
  tag(response_body) if response_body.key?('tagNames')
  event(response_body) if response_body.key?('data')

  @http_status  = faraday_response.status
  @http_body    = faraday_response.body
end

Private Instance Methods

event(response_body) click to toggle source
# File lib/ravelin/response.rb, line 30
def event(response_body)
  data = response_body.fetch('data', {})

  @ato          = data['ato']
  @action       = data['action']
  @score        = data['score']
  @score_id     = data['scoreId']
  @source       = data['source']
  @comment      = data['comment']
  @customer_id  = data['customerId']
  @warnings     = data['warnings']
end
tag(response_body) click to toggle source
# File lib/ravelin/response.rb, line 43
def tag(response_body)
  @tag_names              = response_body['tagNames']
  @label                  = response_body['label'] if response_body.key?('label')
  @tags                   = response_body['tags'] if response_body.key?('tags')
  @client_reviewed_status = response_body['clientReviewedStatus'] if response_body.key?('clientReviewedStatus')
end