Class: QNE::Customers
- Includes:
- QueryBuilder
- Defined in:
- lib/customers.rb
Constant Summary
Constants included from QueryBuilder
Instance Attribute Summary collapse
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#id ⇒ Object
Returns the value of attribute id.
Attributes inherited from Base
Instance Method Summary collapse
- #all(params = {}) ⇒ Object
- #create(request_body) ⇒ Object
- #find(id) ⇒ Object
- #find_by(params) ⇒ Object
- #show(id) ⇒ Object
- #update(request_body) ⇒ Object
Methods included from QueryBuilder
#eq_query, #multi_query, #uri_query, #where
Methods inherited from Base
#initialize, #parse_to_json, #success?
Constructor Details
This class inherits a constructor from QNE::Base
Instance Attribute Details
#customer ⇒ Object
Returns the value of attribute customer.
12 13 14 |
# File 'lib/customers.rb', line 12 def customer @customer end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/customers.rb', line 12 def id @id end |
Instance Method Details
#all(params = {}) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/customers.rb', line 29 def all(params = {}) @response = QNE::Customer::All.new( conn, params: uri_query(params) ).call parse_to_json(@response.body) end |
#create(request_body) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/customers.rb', line 47 def create(request_body) @response = QNE::Customer::Create.new( conn, request_body: request_body ).call parse_to_json(@response.body) end |
#find(id) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/customers.rb', line 16 def find(id) @id = id finder = QNE::Customer::Find.new(conn, id: id).call return unless finder.success? define_singleton_method 'show' do parse_to_json(finder.body) end self end |
#find_by(params) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/customers.rb', line 37 def find_by(params) @response = QNE::Customer::FindBy.new( conn, params: eq_query(params) ).call body = parse_to_json(@response.body) @response.success? ? body.first : body end |