Class: Reggora::Product
- Inherits:
-
Object
- Object
- Reggora::Product
- Defined in:
- lib/reggora/Entity/Lender/product.rb
Instance Method Summary collapse
-
#all(params = {}) ⇒ Object
retrieves all products.
-
#create(product_params) ⇒ Object
creates a product and returns the ID of the created product.
-
#delete(id) ⇒ Object
deletes a specific product.
-
#edit(id, product_params) ⇒ Object
edits a product and returns the ID of the edited product.
-
#find(id) ⇒ Object
retrieves a specific product by id.
-
#initialize(client) ⇒ Product
constructor
A new instance of Product.
- #sample_data ⇒ Object
Constructor Details
#initialize(client) ⇒ Product
Returns a new instance of Product.
3 4 5 6 |
# File 'lib/reggora/Entity/Lender/product.rb', line 3 def initialize(client) @model = 'product' @client = client end |
Instance Method Details
#all(params = {}) ⇒ Object
retrieves all products.
8 9 10 |
# File 'lib/reggora/Entity/Lender/product.rb', line 8 def all(params = {}) @client.get("/#{@model}s", params) end |
#create(product_params) ⇒ Object
creates a product and returns the ID of the created product.
18 19 20 |
# File 'lib/reggora/Entity/Lender/product.rb', line 18 def create(product_params) @client.post("/#{@model}", product_params) end |
#delete(id) ⇒ Object
deletes a specific product. If an order or a loan is associated with this product the reference will not be broken.
27 28 29 |
# File 'lib/reggora/Entity/Lender/product.rb', line 27 def delete(id) @client.delete("/#{@model}/#{id}") end |
#edit(id, product_params) ⇒ Object
edits a product and returns the ID of the edited product.
23 24 25 |
# File 'lib/reggora/Entity/Lender/product.rb', line 23 def edit(id, product_params) @client.put("/#{@model}/#{id}", product_params) end |
#find(id) ⇒ Object
retrieves a specific product by id.
13 14 15 |
# File 'lib/reggora/Entity/Lender/product.rb', line 13 def find(id) @client.get("/#{@model}/#{id}") end |
#sample_data ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/reggora/Entity/Lender/product.rb', line 31 def sample_data s = (0...50).map { ('a'..'z').to_a[rand(26)] }.join { 'product_name': "Product_#{s[1...5]}", 'amount': '100.00', 'inspection_type': 'interior', 'requested_forms': '1004MC, BPO' } end |