Method: Contentful::Management::Request#initialize

Defined in:
lib/contentful/management/request.rb

#initialize(client, endpoint, query = {}, id = nil, headers = {}) ⇒ Request

Returns a new instance of Request.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/contentful/management/request.rb', line 11

def initialize(client, endpoint, query = {}, id = nil, headers = {})
  @headers = headers
  @initial_id = id
  @client = client
  @client.version = headers[:version]
  @client.organization_id = headers[:organization_id]
  @client.content_type_id = headers[:content_type_id]
  @endpoint = endpoint

  case query
  when Hash
    @query = normalize_query(query) if query && !query.empty?
  else
    @query = query
  end

  if id
    @type = :single
    @id = URI.encode_www_form_component(id)
  else
    @type = :multi
    @id = nil
  end
end