Class: Pingboard::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/pingboard/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, http_verb:, path:, headers:, body:, params: {}) ⇒ Request

Returns a new instance of Request.



6
7
8
9
10
11
12
13
# File 'lib/pingboard/request.rb', line 6

def initialize(client:, http_verb:, path:, headers:, body:, params: {})
  @client = client
  @http_verb = http_verb
  @path = path
  @headers = headers
  @body = body
  @params = params
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/pingboard/request.rb', line 4

def body
  @body
end

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/pingboard/request.rb', line 4

def client
  @client
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/pingboard/request.rb', line 4

def headers
  @headers
end

#http_verbObject

Returns the value of attribute http_verb.



4
5
6
# File 'lib/pingboard/request.rb', line 4

def http_verb
  @http_verb
end

#paramsObject

Returns the value of attribute params.



4
5
6
# File 'lib/pingboard/request.rb', line 4

def params
  @params
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/pingboard/request.rb', line 4

def path
  @path
end

Instance Method Details

#doObject



15
16
17
18
19
20
21
22
# File 'lib/pingboard/request.rb', line 15

def do
  @client.connection.public_send(@http_verb) do |request|
    request.url "#{@path}"
    set_headers!(request) if headers
    set_body!(request) if body
    set_params!(request) if params
  end
end