Class: CommandTower::Clients::Transport::Response

Inherits:
Data
  • Object
show all
Defined in:
app/services/command_tower/clients/transport/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



6
7
8
# File 'app/services/command_tower/clients/transport/response.rb', line 6

def body
  @body
end

#duration_msObject (readonly)

Returns the value of attribute duration_ms

Returns:

  • (Object)

    the current value of duration_ms



6
7
8
# File 'app/services/command_tower/clients/transport/response.rb', line 6

def duration_ms
  @duration_ms
end

#headersObject (readonly)

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



6
7
8
# File 'app/services/command_tower/clients/transport/response.rb', line 6

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



6
7
8
# File 'app/services/command_tower/clients/transport/response.rb', line 6

def status
  @status
end

Class Method Details

.build(status:, headers: {}, body: nil, duration_ms: nil) ⇒ Object



7
8
9
10
11
12
13
14
# File 'app/services/command_tower/clients/transport/response.rb', line 7

def self.build(status:, headers: {}, body: nil, duration_ms: nil)
  new(
    status: Integer(status),
    headers: headers.to_h.transform_keys(&:to_s),
    body: body,
    duration_ms: duration_ms
  )
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/services/command_tower/clients/transport/response.rb', line 16

def success?
  status >= 200 && status < 300
end