Class: CommandTower::Clients::Transport::Request

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

Constant Summary collapse

SUPPORTED_METHODS =
%i[get post put patch delete].freeze

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/request.rb', line 6

def body
  @body
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/request.rb', line 6

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



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

def method
  @method
end

#queryObject (readonly)

Returns the value of attribute query

Returns:

  • (Object)

    the current value of query



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

def query
  @query
end

#timeoutObject (readonly)

Returns the value of attribute timeout

Returns:

  • (Object)

    the current value of timeout



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

def timeout
  @timeout
end

#urlObject (readonly)

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



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

def url
  @url
end

Class Method Details

.build(method:, url:, headers: {}, body: nil, query: {}, timeout: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'app/services/command_tower/clients/transport/request.rb', line 9

def self.build(method:, url:, headers: {}, body: nil, query: {}, timeout: nil)
  new(
    method: normalize_and_validate_method(method),
    url: url.to_s,
    headers: normalize_headers(headers),
    body: body,
    query: normalize_query(query),
    timeout: timeout
  )
end

.validate_method!(method) ⇒ Object



20
21
22
# File 'app/services/command_tower/clients/transport/request.rb', line 20

def self.validate_method!(method)
  normalize_and_validate_method(method)
end

Instance Method Details

#merge_headers(extra) ⇒ Object



44
45
46
# File 'app/services/command_tower/clients/transport/request.rb', line 44

def merge_headers(extra)
  with(headers: headers.merge(self.class.send(:normalize_headers, extra)))
end