zoho_hub 0.1.16 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b84e9021f341ee250d6c2b052cd7fe7fc486389f93df87f5b5b1eb0304653b5
4
- data.tar.gz: 6bd9c2dd8a6668eee36f9aedc026c5d4ec712665e25384988085fb4e10d45507
3
+ metadata.gz: cf4a7d2f509467db7f812178010051778b79d1039a55a8f96898ae9e073489b1
4
+ data.tar.gz: 1fcc4e9ee9ae2d1c7fad3c2bebc80a541928d42062f3e701a495b59f56d09ae7
5
5
  SHA512:
6
- metadata.gz: f121964d6da6548e91ea44dd1be7e7c8f0a024766ecac3034021664863ce02d51ad64c33c5a6099f8ac4a49ba070db6b04d9b0fa9a91556f91c546818c662ac2
7
- data.tar.gz: c5e10c5a76a2d5834ffa6ce642585c4a8bde0cdfd09d2d124cbc0fac5587351268c31f14720fbdb9d79d28c78a20ee21438111c7909c234895513013269e311a
6
+ metadata.gz: 915784445d0975cbe42975e2879edac513e0a84cc9ed8da053afd21a85566aa56b77e010b9f336933feea5f5bce4b474e88df8ad49d003b38c12b6e2e6385d8b
7
+ data.tar.gz: f45f8e724fb663cf9b4b8c7a15b9738b824a8fd771558b151e761bd00366e0bef8ec654bd3677d78f5b23c3dc50c92ceb482ce084dfe8a49f47bd823dad33335
@@ -131,7 +131,12 @@ module ZohoHub
131
131
 
132
132
  response = build_response(body)
133
133
 
134
- response.data.dig(:details, :id)
134
+ id = response.data.dig(:details, :id)
135
+
136
+ return id if id
137
+
138
+ # Invalid errors
139
+ response.data
135
140
  end
136
141
 
137
142
  def new_record?
@@ -4,7 +4,7 @@ require 'zoho_hub/records/base_record'
4
4
 
5
5
  module ZohoHub
6
6
  class Quote < BaseRecord
7
- attributes :id, :stage, :subject, :potential_id, :owner_id, :product_id
7
+ attributes :id, :stage, :subject, :potential_id, :owner_id, :product_id, :account_id
8
8
 
9
9
  attribute_translation(
10
10
  id: :id,
@@ -12,15 +12,13 @@ module ZohoHub
12
12
  )
13
13
 
14
14
  def initialize(params)
15
- puts Rainbow(params).bright.red
16
15
  attributes.each do |attr|
17
16
  zoho_key = attr_to_zoho_key(attr)
18
- puts "Sending #{attr}=, zoho_key: #{zoho_key}"
19
17
  send("#{attr}=", params[zoho_key] || params[attr])
20
18
  end
21
19
 
22
20
  @potential_id ||= params.dig(:Deal_Name, :id)
23
- @lender_organisation_id ||= params.dig(:Account_Name, :id)
21
+ @account_id ||= params.dig(:Account_Name, :id)
24
22
  @owner_id ||= params.dig(:Owner, :id)
25
23
 
26
24
  # The Quote has an array of products but we only care about one
@@ -34,9 +32,11 @@ module ZohoHub
34
32
  params = super
35
33
 
36
34
  params[:Deal_Name] = { id: @potential_id } if @potential_id
37
- params[:Account_Name] = { id: @lender_organisation_id } if @lender_organisation_id
35
+ params[:Account_Name] = { id: @account_id } if @account_id
38
36
  params[:Owner] = { id: @owner_id } if @owner_id
39
- params[:Product_Details] = [{ id: @product_id }] if @product_id
37
+ params[:Product_Details] = [{ product: { id: @product_id }, quantity: 1 }] if @product_id
38
+
39
+ params
40
40
  end
41
41
  end
42
42
  end
@@ -7,7 +7,9 @@ module ZohoHub
7
7
  end
8
8
 
9
9
  def invalid_data?
10
- return false if data.is_a?(Array)
10
+ if data.is_a?(Array)
11
+ return data.first[:code] == 'MANDATORY_NOT_FOUND'
12
+ end
11
13
 
12
14
  data[:code] == 'INVALID_DATA'
13
15
  end
@@ -41,6 +43,10 @@ module ZohoHub
41
43
  def msg
42
44
  msg = data[:message]
43
45
 
46
+ if data.dig(:code) == 'INVALID_DATA'
47
+ msg << ", error in #{data.dig(:details, :api_name)}"
48
+ end
49
+
44
50
  if data.dig(:details, :expected_data_type)
45
51
  expected = data.dig(:details, :expected_data_type)
46
52
  field = data.dig(:details, :api_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZohoHub
4
- VERSION = '0.1.16'
4
+ VERSION = '0.1.17'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoho_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-24 00:00:00.000000000 Z
11
+ date: 2019-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport