Class: CrisalidOdooClient::Client
- Inherits:
-
Object
- Object
- CrisalidOdooClient::Client
- Defined in:
- lib/crisalid_odoo_client/client.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
60
Instance Attribute Summary collapse
-
#odoo_db ⇒ Object
readonly
Returns the value of attribute odoo_db.
-
#odoo_pass ⇒ Object
readonly
Returns the value of attribute odoo_pass.
-
#odoo_url ⇒ Object
readonly
Returns the value of attribute odoo_url.
-
#odoo_user ⇒ Object
readonly
Returns the value of attribute odoo_user.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #connected? ⇒ Boolean
- #employee ⇒ Object
-
#initialize(odoo_url:, odoo_db:, odoo_user:, odoo_pass:, odoo_uid: nil, timeout: DEFAULT_TIMEOUT) ⇒ Client
constructor
A new instance of Client.
- #models ⇒ Object
- #product ⇒ Object
- #query ⇒ Object
- #uid ⇒ Object
Constructor Details
#initialize(odoo_url:, odoo_db:, odoo_user:, odoo_pass:, odoo_uid: nil, timeout: DEFAULT_TIMEOUT) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/crisalid_odoo_client/client.rb', line 14 def initialize(odoo_url:, odoo_db:, odoo_user:, odoo_pass:, odoo_uid: nil, timeout: DEFAULT_TIMEOUT) @odoo_url, @odoo_db, @timeout = odoo_url, odoo_db, timeout if @uid.nil? @odoo_user, @odoo_pass = odoo_user, odoo_pass @uid = connect end if @uid != false @models = XMLRPC::Client.new2("#{@odoo_url}/xmlrpc/2/object", nil, @timeout).proxy @query ||= CrisalidOdooClient::Query.new(self) # Client connected else # Client not connected end end |
Instance Attribute Details
#odoo_db ⇒ Object (readonly)
Returns the value of attribute odoo_db.
8 9 10 |
# File 'lib/crisalid_odoo_client/client.rb', line 8 def odoo_db @odoo_db end |
#odoo_pass ⇒ Object (readonly)
Returns the value of attribute odoo_pass.
10 11 12 |
# File 'lib/crisalid_odoo_client/client.rb', line 10 def odoo_pass @odoo_pass end |
#odoo_url ⇒ Object (readonly)
Returns the value of attribute odoo_url.
7 8 9 |
# File 'lib/crisalid_odoo_client/client.rb', line 7 def odoo_url @odoo_url end |
#odoo_user ⇒ Object (readonly)
Returns the value of attribute odoo_user.
9 10 11 |
# File 'lib/crisalid_odoo_client/client.rb', line 9 def odoo_user @odoo_user end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
12 13 14 |
# File 'lib/crisalid_odoo_client/client.rb', line 12 def timeout @timeout end |
Instance Method Details
#connected? ⇒ Boolean
51 52 53 |
# File 'lib/crisalid_odoo_client/client.rb', line 51 def connected? return (uid || false) != false end |
#employee ⇒ Object
47 48 49 |
# File 'lib/crisalid_odoo_client/client.rb', line 47 def employee @employee ||= CrisalidOdooClient::Resource::Employee.new(self) end |
#models ⇒ Object
35 36 37 |
# File 'lib/crisalid_odoo_client/client.rb', line 35 def models @models end |
#product ⇒ Object
43 44 45 |
# File 'lib/crisalid_odoo_client/client.rb', line 43 def product @product ||= CrisalidOdooClient::Resource::Product.new(self) end |
#query ⇒ Object
39 40 41 |
# File 'lib/crisalid_odoo_client/client.rb', line 39 def query @query end |
#uid ⇒ Object
31 32 33 |
# File 'lib/crisalid_odoo_client/client.rb', line 31 def uid @uid end |