Class: FizzyApiClient::Request

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, params: {}, path_params: {}) ⇒ Request

Returns a new instance of Request.



7
8
9
10
11
# File 'lib/fizzy_api_client/request.rb', line 7

def initialize(path:, params: {}, path_params: {})
  @path = interpolate_path(path, path_params)
  @params = params
  @path_params = path_params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#path_paramsObject (readonly)

Returns the value of attribute path_params.



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

def path_params
  @path_params
end

Instance Method Details

#full_pathObject



13
14
15
16
17
18
# File 'lib/fizzy_api_client/request.rb', line 13

def full_path
  return path if params.empty?

  query_string = build_query_string(params)
  "#{path}?#{query_string}"
end

#wrap_payload(resource_name, data) ⇒ Object



20
21
22
# File 'lib/fizzy_api_client/request.rb', line 20

def wrap_payload(resource_name, data)
  { resource_name => data }
end