Class: Flexibee::Client
- Inherits:
-
Object
- Object
- Flexibee::Client
- Defined in:
- lib/flexibee/client.rb
Instance Method Summary collapse
- #base_response ⇒ Object
- #base_url ⇒ Object
-
#company ⇒ Object
flexibee obejcts.
-
#get(route = '', params = {}, filter = nil) ⇒ Object
flexibee base call methods.
-
#initialize(user_id, login, password, company_id) ⇒ Client
constructor
working with base response from flexibee.
- #invoice_types ⇒ Object
- #order_types ⇒ Object
- #product_list ⇒ Object
-
#tree ⇒ Object
By default called with { detail: ‘full’ }, normal response does not have any usefull information in it Also to get whole list of categories default passes { limit: 0 } to get default pass { limit: 20 }.
Constructor Details
#initialize(user_id, login, password, company_id) ⇒ Client
working with base response from flexibee
{
"companies" => {
"company" => {
"createDt" => "2015-10-17T18:26:39.692+02:00",
"dbNazev" => "esperia_test",
"id" => "1",
"licenseGroup" => "04fc91491a9647d451649736ad8127e2",
"nazev" => "esperia-test",
"show" => "true",
"stavEnum" => "ESTABLISHED",
"watchingChanges" => "false"
}
}
}
24 25 26 27 28 29 |
# File 'lib/flexibee/client.rb', line 24 def initialize(user_id, login, password, company_id) @user_id = user_id @login = login @password = password @company_id = company_id end |
Instance Method Details
#base_response ⇒ Object
35 36 37 |
# File 'lib/flexibee/client.rb', line 35 def base_response get end |
#base_url ⇒ Object
31 32 33 |
# File 'lib/flexibee/client.rb', line 31 def base_url "https://#{@login}:#{@password}@#{@user_id}.flexibee.eu:5434/c/#{@company_id}" end |
#company ⇒ Object
flexibee obejcts
42 43 44 |
# File 'lib/flexibee/client.rb', line 42 def company @company ||= Company.new(base_response) end |
#get(route = '', params = {}, filter = nil) ⇒ Object
flexibee base call methods
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/flexibee/client.rb', line 69 def get(route='', params = {}, filter = nil) url = base_url + route unless filter.nil? url << '/' + "(#{ERB::Util.url_encode(filter)})" end url << '.json' begin JSON.parse(RestClient.get(url, params: params)) rescue RestClient::ResourceNotFound => e Object.new end end |
#invoice_types ⇒ Object
46 47 48 |
# File 'lib/flexibee/client.rb', line 46 def invoice_types @invoice_types = InvoiceTypes.new(self).invoice_types end |
#order_types ⇒ Object
50 51 52 |
# File 'lib/flexibee/client.rb', line 50 def order_types @order_types = OrderTypes.new(self).order_types end |
#product_list ⇒ Object
54 55 56 |
# File 'lib/flexibee/client.rb', line 54 def product_list @products = ProductList.new(self) end |
#tree ⇒ Object
By default called with { detail: ‘full’ }, normal response does not have any usefull information in it Also to get whole list of categories default passes { limit: 0 } to get default pass { limit: 20 }
62 63 64 |
# File 'lib/flexibee/client.rb', line 62 def tree @tree = Tree.new(self) end |