Class: KlickmailApi::Connector

Inherits:
Object
  • Object
show all
Defined in:
lib/klickmail_api/connector.rb

Constant Summary collapse

DEFAULT_SERVICE =
'http://www.klickmail.com.br/api'

Instance Method Summary collapse

Constructor Details

#initialize(service = DEFAULT_SERVICE) ⇒ Connector

Returns a new instance of Connector.



7
8
9
# File 'lib/klickmail_api/connector.rb', line 7

def initialize(service = DEFAULT_SERVICE)
  @service = service
end

Instance Method Details

#login(username, password) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/klickmail_api/connector.rb', line 11

def (username, password)
  data = { username: username, password: password }

  result = request('account/login', :post, data)
  set_session(result)

  result
end

#request(path, method = :get, data = {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/klickmail_api/connector.rb', line 20

def request(path, method = :get, data = {})
  headers = {}
  headers = request_header if @sessid

  http_request(path, method, data, headers).parsed_response
end