Sha256: a15f9aade81e9a26c06c148fdc80ecf0627c3c32e6d63fbd6cee1dc5e7434992
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true require "faraday" require "faraday_middleware" require "faraday-cookie_jar" require "singleton" module Acumatica class Client include Singleton API_VERSION = "6.00.001" attr_accessor :url, :name, :password, :token, :debug def self.configure yield(instance) instance end def base_url @base_url ||= URI.join(url, "entity/Default/#{API_VERSION}/") end def connection @connection ||= Faraday.new do |conn| conn.request :json if token conn.request :oauth2, token else conn.use :cookie_jar end conn.use Acumatica::ErrorHandler conn.response :json conn.response :logger, nil, bodies: true if debug conn.adapter Faraday.default_adapter end end def session login result = yield logout result end def login response = connection.post do |req| req.url URI.join(@url, "/entity/auth/login") req.body = { name: @name, password: @password } end response.success? end def logout connection.post(URI.join(@url, "/entity/auth/logout")).success? end def customers Acumatica::Customer end def sales_orders Acumatica::SalesOrder end def stock_items Acumatica::StockItem end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acumatica-0.5.0 | lib/acumatica/client.rb |