zoho_hub 0.1.48 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +5 -2
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +5 -2
  7. data/README.md +91 -7
  8. data/bin/console +6 -7
  9. data/bin/read +44 -0
  10. data/bin/setup +0 -2
  11. data/bin/zoho_hub +62 -0
  12. data/cache/.git_keep +0 -0
  13. data/lib/zoho_hub/auth.rb +37 -47
  14. data/lib/zoho_hub/base_record.rb +122 -0
  15. data/lib/zoho_hub/configuration.rb +3 -4
  16. data/lib/zoho_hub/connection.rb +10 -17
  17. data/lib/zoho_hub/{records → deprecated_and_only_for_reference_records}/account.rb +1 -1
  18. data/lib/zoho_hub/{records → deprecated_and_only_for_reference_records}/campaign.rb +0 -0
  19. data/lib/zoho_hub/{records → deprecated_and_only_for_reference_records}/contact.rb +3 -9
  20. data/lib/zoho_hub/deprecated_and_only_for_reference_records/funder.rb +9 -0
  21. data/lib/zoho_hub/{records → deprecated_and_only_for_reference_records}/potential.rb +1 -21
  22. data/lib/zoho_hub/deprecated_and_only_for_reference_records/product.rb +9 -0
  23. data/lib/zoho_hub/deprecated_and_only_for_reference_records/quote.rb +34 -0
  24. data/lib/zoho_hub/errors.rb +0 -3
  25. data/lib/zoho_hub/module_builder.rb +61 -0
  26. data/lib/zoho_hub/oauth_callback_server.rb +26 -0
  27. data/lib/zoho_hub/response.rb +1 -4
  28. data/lib/zoho_hub/settings/field.rb +33 -0
  29. data/lib/zoho_hub/settings/module.rb +49 -0
  30. data/lib/zoho_hub/string_utils.rb +34 -0
  31. data/lib/zoho_hub/version.rb +1 -1
  32. data/lib/zoho_hub/views/variables.erb +72 -0
  33. data/lib/zoho_hub/with_attributes.rb +74 -0
  34. data/lib/zoho_hub/with_connection.rb +36 -0
  35. data/lib/zoho_hub.rb +21 -23
  36. data/zoho_hub.gemspec +14 -10
  37. metadata +80 -57
  38. data/lib/zoho_hub/records/adverse_criteria.rb +0 -43
  39. data/lib/zoho_hub/records/attachment.rb +0 -104
  40. data/lib/zoho_hub/records/base_record.rb +0 -189
  41. data/lib/zoho_hub/records/credit_score.rb +0 -36
  42. data/lib/zoho_hub/records/product.rb +0 -33
  43. data/lib/zoho_hub/records/quote.rb +0 -44
  44. data/lib/zoho_hub/records/sms_message.rb +0 -32
  45. data/lib/zoho_hub/records/vendor.rb +0 -34
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ZohoHub
4
- class Product < BaseRecord
5
- attributes :id, :description, :vendor_id, :owner_id, :active, :name
6
-
7
- attribute_translation(
8
- id: :id,
9
- active: :Product_Active,
10
- name: :Product_Name
11
- )
12
-
13
- def initialize(params)
14
- attributes.each do |attr|
15
- zoho_key = attr_to_zoho_key(attr)
16
-
17
- send("#{attr}=", params[zoho_key] || params[attr])
18
- end
19
-
20
- @owner_id ||= params.dig(:Owner, :id)
21
- @vendor_id ||= params.dig(:Vendor_Name, :id)
22
- end
23
-
24
- def to_params
25
- params = super
26
-
27
- params[:Owner] = { id: @owner_id } if @owner_id
28
- params[:Vendor_Name] = { id: @vendor_id } if @vendor_id
29
-
30
- params
31
- end
32
- end
33
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'zoho_hub/records/base_record'
4
-
5
- module ZohoHub
6
- class Quote < BaseRecord
7
- attributes :id, :stage, :subject, :potential_id, :owner_id, :product_id, :account_id
8
- attributes :funding_amount, :financed_on, :extra_info
9
-
10
- attribute_translation(
11
- id: :id,
12
- stage: :Quote_Stage,
13
- financed_on: :Financed_on
14
- )
15
-
16
- def initialize(params)
17
- attributes.each do |attr|
18
- zoho_key = attr_to_zoho_key(attr)
19
- send("#{attr}=", params[zoho_key] || params[attr])
20
- end
21
-
22
- @potential_id ||= params.dig(:Deal_Name, :id)
23
- @account_id ||= params.dig(:Account_Name, :id)
24
- @owner_id ||= params.dig(:Owner, :id)
25
-
26
- # The Quote has an array of products but we only care about one
27
- if params.dig(:Product_Details)
28
- product = params.dig(:Product_Details).first
29
- @product_id = product[:id]
30
- end
31
- end
32
-
33
- def to_params
34
- params = super
35
-
36
- params[:Deal_Name] = { id: @potential_id } if @potential_id
37
- params[:Account_Name] = { id: @account_id } if @account_id
38
- params[:Owner] = { id: @owner_id } if @owner_id
39
- params[:Product_Details] = [{ product: { id: @product_id }, quantity: 1 }] if @product_id
40
-
41
- params
42
- end
43
- end
44
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'zoho_hub/records/base_record'
4
-
5
- module ZohoHub
6
- class SMSMessage < BaseRecord
7
- attributes :id, :template, :state, :text, :contact_id, :potential_id, :name, :sent_by
8
-
9
- attribute_translation id: :id
10
-
11
- def initialize(params)
12
- attributes.each do |attr|
13
- zoho_key = attr_to_zoho_key(attr)
14
-
15
- send("#{attr}=", params[zoho_key] || params[attr])
16
- end
17
-
18
- # Setup values as they come from the Zoho API if needed
19
- @contact_id ||= params.dig(:Contact, :id)
20
- @potential_id ||= params.dig(:Potential, :id)
21
- end
22
-
23
- def to_params
24
- params = super
25
-
26
- params[:Contact] = { id: @contact_id } if @contact_id
27
- params[:Potential] = { id: @potential_id } if @potential_id
28
-
29
- params
30
- end
31
- end
32
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ZohoHub
4
- class Vendor < BaseRecord
5
- attributes :id, :email, :description, :vendor_name, :website, :owner_id, :phone, :currency
6
- attributes :company_reg_no, :created_time, :modified_time, :lender_status
7
-
8
- attribute_translation(
9
- id: :id
10
- )
11
-
12
- DEFAULTS = {
13
- currency: 'GBP'
14
- }.freeze
15
-
16
- def initialize(params)
17
- attributes.each do |attr|
18
- zoho_key = attr_to_zoho_key(attr)
19
-
20
- send("#{attr}=", params[zoho_key] || params[attr] || DEFAULTS[attr])
21
- end
22
-
23
- @owner_id ||= params.dig(:Owner, :id)
24
- end
25
-
26
- def to_params
27
- params = super
28
-
29
- params[:Owner] = { id: @owner_id } if @owner_id
30
-
31
- params
32
- end
33
- end
34
- end