Class: Acumatica::Client
- Inherits:
-
Object
- Object
- Acumatica::Client
- Includes:
- Singleton
- Defined in:
- lib/acumatica/client.rb
Constant Summary collapse
- API_VERSION =
"6.00.001".freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/acumatica/client.rb', line 7 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/acumatica/client.rb', line 7 def password @password end |
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/acumatica/client.rb', line 7 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/acumatica/client.rb', line 7 def url @url end |
Class Method Details
.configure {|instance| ... } ⇒ Object
9 10 11 12 |
# File 'lib/acumatica/client.rb', line 9 def self.configure yield(instance) instance end |
Instance Method Details
#connection ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/acumatica/client.rb', line 14 def connection @connection ||= Faraday.new do |conn| conn.request :json if token.present? conn.request :oauth2, token else conn.use :cookie_jar end conn.response :json conn.adapter Faraday.default_adapter end end |
#login ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/acumatica/client.rb', line 29 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 |
#logout ⇒ Object
37 38 39 |
# File 'lib/acumatica/client.rb', line 37 def logout connection.post(URI.join(@url, "/entity/auth/logout")).success? end |