Class: DellinInfo::API::Client

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/dellininfo/client.rb

Instance Method Summary collapse

Instance Method Details

#auth(options = {}) ⇒ Object

в проекте используется только публичные API, поэтому данный метод в годе больше не затронут, но оставлен для возможности расширить функционал



10
11
12
13
14
15
16
# File 'lib/dellininfo/client.rb', line 10

def auth(options = {})       
  response = HTTParty.post('https://api.dellin.ru/v1/customers/login.json', 
    :body => {:login => options[:username], :password => options[:password], :appKey => @app_key}.to_json,
    :headers => {'Content-Type' => 'application/json'})
  print response
  response['sessionID']
end

#request(op, params = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/dellininfo/client.rb', line 18

def request(op, params = {})
  params[:appKey] = @app_key
  response = HTTParty.post("https://api.dellin.ru/v1/#{op}.json",
    :body => params.to_json,
    :headers => {'Content-Type' => 'application/json'})
  response
end