Class: SptyAPI::HTTP::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/spty_api/http/client.rb

Constant Summary collapse

DEFAULT_API =
'https://api.spotify.com/v1/'
CONTENT_TYPE =
'application/json'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_method:, token_type:, access_token: nil, endpoint:) ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
20
# File 'lib/spty_api/http/client.rb', line 15

def initialize(http_method:, token_type:, access_token: nil, endpoint:)
  self.http_method  = http_method
  self.token_type   = token_type
  self.access_token = access_token
  self.endpoint     = endpoint
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



8
9
10
# File 'lib/spty_api/http/client.rb', line 8

def access_token
  @access_token
end

#api_overwriteObject

Returns the value of attribute api_overwrite.



8
9
10
# File 'lib/spty_api/http/client.rb', line 8

def api_overwrite
  @api_overwrite
end

#body_parameterObject

Returns the value of attribute body_parameter.



8
9
10
# File 'lib/spty_api/http/client.rb', line 8

def body_parameter
  @body_parameter
end

#content_type_overwriteObject

Returns the value of attribute content_type_overwrite.



8
9
10
# File 'lib/spty_api/http/client.rb', line 8

def content_type_overwrite
  @content_type_overwrite
end

#endpointObject

Returns the value of attribute endpoint.



8
9
10
# File 'lib/spty_api/http/client.rb', line 8

def endpoint
  @endpoint
end

#http_methodObject

Returns the value of attribute http_method.



8
9
10
# File 'lib/spty_api/http/client.rb', line 8

def http_method
  @http_method
end

#path_parameterObject

Returns the value of attribute path_parameter.



8
9
10
# File 'lib/spty_api/http/client.rb', line 8

def path_parameter
  @path_parameter
end

#query_parameterObject

Returns the value of attribute query_parameter.



8
9
10
# File 'lib/spty_api/http/client.rb', line 8

def query_parameter
  @query_parameter
end

#token_typeObject

Returns the value of attribute token_type.



8
9
10
# File 'lib/spty_api/http/client.rb', line 8

def token_type
  @token_type
end

Instance Method Details

#requestObject



22
23
24
25
26
# File 'lib/spty_api/http/client.rb', line 22

def request
  uri = prepare_uri
  http = prepare_http(uri)
  http.request(prepare_request(uri))
end