Class: Wrappi::Request::Template

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

Direct Known Subclasses

Get, WithBody

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint) ⇒ Template

Returns a new instance of Template.



5
6
7
# File 'lib/wrappi/request/template.rb', line 5

def initialize(endpoint)
  @endpoint = endpoint
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



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

def endpoint
  @endpoint
end

Instance Method Details

#callObject

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/wrappi/request/template.rb', line 33

def call
  raise NotImplementedError
end

#clientObject



9
10
11
# File 'lib/wrappi/request/template.rb', line 9

def client
  endpoint.client
end

#httpObject



25
26
27
28
29
30
31
# File 'lib/wrappi/request/template.rb', line 25

def http
  h = HTTP.timeout(client.timeout)
          .headers(endpoint.headers)
  h = h.follow() if endpoint.follow_redirects # TODO: add strict mode
  h = h.basic_auth(endpoint.basic_auth) if endpoint.basic_auth
  h
end

#paramsObject



13
14
15
# File 'lib/wrappi/request/template.rb', line 13

def params
  endpoint.consummated_params
end

#urlObject



17
18
19
# File 'lib/wrappi/request/template.rb', line 17

def url
  endpoint.url
end

#verbObject



21
22
23
# File 'lib/wrappi/request/template.rb', line 21

def verb
  endpoint.verb
end