Class: Teamsupport::Headers

Inherits:
Object
  • Object
show all
Defined in:
lib/teamsupport/headers.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, request_method, url, options = {}) ⇒ Teamsupport::Headers

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes a new Headers object

Parameters:

  • client (Teamsupport::Client)
  • request_method (String)
  • url (String)
  • options (Hash) (defaults to: {})


16
17
18
19
20
21
# File 'lib/teamsupport/headers.rb', line 16

def initialize(client, request_method, url, options = {})
  @client = client
  @request_method = request_method.to_sym
  @uri = Addressable::URI.parse(url)
  @options = options
end

Instance Method Details

#request_headersHash

Returns HTTP request headers for the client

Examples:

teamsupport_client = Teamsupport::Client.new(api_key: 'AK', api_secret: 'AS')
teamsupport_headers = Teamsupport::Headers.new(teamsupport_client, :get, 'https://app.teamsupport.com')
teamsupport_headers.request_headers

Returns:

  • (Hash)


33
34
35
36
37
38
# File 'lib/teamsupport/headers.rb', line 33

def request_headers
  headers = {'Content-Type' => 'application/json'}
  headers[:user_agent] = @client.user_agent
  headers[:authorization] = auth_header
  headers
end