Class: SyncwiseApi::Client

Inherits:
Object show all
Defined in:
lib/syncwise_api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ Client

Returns a new instance of Client.



4
5
6
7
8
# File 'lib/syncwise_api/client.rb', line 4

def initialize(username, password)
  @username = username
  @password = password
  
end

Instance Method Details

#make_request(action_code, params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/syncwise_api/client.rb', line 10

def make_request(action_code, params)
  if action_code == :user_login
    puts 'Login is done automatically when a new Client is created. Ignoring this call.'
  else
    action_code = action_code.camelize
    if SyncwiseApi::Requests::V1_0.const_defined?(action_code)
      params[:'Action Code'] = action_code
      params[:'API Key'] = @username
      params[:secretKey] = @secret_key
      params[:accountId] = @account_id
      request_class = SyncwiseApi::Requests::V1_0.const_get(action_code)
      request = request_class.new(params)
      response = request.send_request
    else
      puts 'Sorry, that\'s not a valid request type.'
    end
  end
end