Class: MyApiClient::Params::Request

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

Overview

Description of Params

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, uri, headers, body) ⇒ Request

Description of #initialize

Parameters:

  • method (Symbol)

    describe_method_here

  • uri (URI)

    describe_uri_here

  • headers (Hash, nil)

    describe_headers_here

  • body (Hash, nil)

    describe_body_here



15
16
17
18
19
20
# File 'lib/my_api_client/params/request.rb', line 15

def initialize(method, uri, headers, body)
  @method = method
  @uri = uri
  @headers = headers
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/my_api_client/params/request.rb', line 7

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



7
8
9
# File 'lib/my_api_client/params/request.rb', line 7

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/my_api_client/params/request.rb', line 7

def method
  @method
end

#uriObject (readonly)

Returns the value of attribute uri.



7
8
9
# File 'lib/my_api_client/params/request.rb', line 7

def uri
  @uri
end

Instance Method Details

#inspectString

Returns contents as string for to be readable for human

Returns:

  • (String)

    Contents as string



45
46
47
# File 'lib/my_api_client/params/request.rb', line 45

def inspect
  { method: method, uri: uri.to_s, headers: headers, body: body }.inspect
end

#metadataHash Also known as: to_bugsnag

Generate metadata for bugsnag. Blank parameter will be omitted.

Returns:

  • (Hash)

    Metadata for bugsnag



33
34
35
36
37
38
39
# File 'lib/my_api_client/params/request.rb', line 33

def 
  {
    line: "#{method.upcase} #{uri}",
    headers: headers,
    body: body,
  }.compact
end

#to_sawyer_argsArray<Object>

Description of #to_sawyer_args

Returns:

  • (Array<Object>)

    Arguments for Sawyer::Agent#call



25
26
27
# File 'lib/my_api_client/params/request.rb', line 25

def to_sawyer_args
  [method, uri.to_s, body, { headers: headers }]
end