Class: ZohoHub::Quote
- Inherits:
-
BaseRecord
- Object
- BaseRecord
- ZohoHub::Quote
- Defined in:
- lib/zoho_hub/records/quote.rb
Instance Method Summary collapse
-
#initialize(params) ⇒ Quote
constructor
A new instance of Quote.
- #to_params ⇒ Object
Methods inherited from BaseRecord
all, attribute_translation, attributes, #attributes, #build_response, build_response, create, exists?, find, find_by, #get, get, #new_record?, post, #post, put, #put, request_path, #save, #to_input, where, zoho_key_translation
Constructor Details
#initialize(params) ⇒ Quote
Returns a new instance of Quote.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/zoho_hub/records/quote.rb', line 14 def initialize(params) attributes.each do |attr| zoho_key = attr_to_zoho_key(attr) send("#{attr}=", params[zoho_key] || params[attr]) end @potential_id ||= params.dig(:Deal_Name, :id) @account_id ||= params.dig(:Account_Name, :id) @owner_id ||= params.dig(:Owner, :id) # The Quote has an array of products but we only care about one if params.dig(:Product_Details) product = params.dig(:Product_Details).first @product_id = product.dig(:id) end end |
Instance Method Details
#to_params ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/zoho_hub/records/quote.rb', line 31 def to_params params = super params[:Deal_Name] = { id: @potential_id } if @potential_id params[:Account_Name] = { id: @account_id } if @account_id params[:Owner] = { id: @owner_id } if @owner_id params[:Product_Details] = [{ product: { id: @product_id }, quantity: 1 }] if @product_id params end |