Class: Harvest::HTTP::ApiCall

Inherits:
Object
  • Object
show all
Defined in:
lib/harvest/httpclient.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, payload: {}, http_method: 'get', headers: {}, params: {}) ⇒ ApiCall

Returns a new instance of ApiCall.



148
149
150
151
152
153
154
# File 'lib/harvest/httpclient.rb', line 148

def initialize(path:, payload: {}, http_method: 'get', headers: {}, params: {})
  @path = path
  @http_method = http_method
  @payload = payload
  @headers = headers
  param(params)
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



146
147
148
# File 'lib/harvest/httpclient.rb', line 146

def headers
  @headers
end

#http_methodObject

Returns the value of attribute http_method.



146
147
148
# File 'lib/harvest/httpclient.rb', line 146

def http_method
  @http_method
end

#pathObject

Returns the value of attribute path.



146
147
148
# File 'lib/harvest/httpclient.rb', line 146

def path
  @path
end

#payloadObject

Returns the value of attribute payload.



146
147
148
# File 'lib/harvest/httpclient.rb', line 146

def payload
  @payload
end

Instance Method Details

#param(params = NoOptionProvided) ⇒ Object



156
157
158
159
160
161
162
# File 'lib/harvest/httpclient.rb', line 156

def param(params = NoOptionProvided)
  if params == NoOptionProvided
    @headers['params']
  else
    @headers['params'] = params
  end
end

#param=(params) ⇒ Object



164
165
166
167
# File 'lib/harvest/httpclient.rb', line 164

def param=(params)
  param(params)
  self
end