class DellinInfo::API::Client

Public Class Methods

new() click to toggle source
# File lib/dellininfo/client.rb, line 28
def initialize()
  raise "No app key given" unless config['app_key']
  @app_key = config['app_key']
end

Public Instance Methods

auth(options = {}) click to toggle source

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

# 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 = {}) click to toggle source
# 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