zoho_hub 0.1.29 → 0.2.0

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +4 -0
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +5 -2
  7. data/README.md +91 -7
  8. data/bin/console +5 -6
  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 +0 -0
  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 +2 -4
  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 -14
  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 -7
  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 +20 -21
  36. data/zoho_hub.gemspec +21 -17
  37. metadata +104 -80
  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 -35
  43. data/lib/zoho_hub/records/quote.rb +0 -42
  44. data/lib/zoho_hub/records/vendor.rb +0 -34
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'zoho_hub/records/base_record'
4
-
5
- module ZohoHub
6
- class CreditScore < BaseRecord
7
- request_path 'Credit_Scores'
8
-
9
- attributes :id, :account_id, :credit_data_source, :credit_score_band
10
- attributes :score_description, :credit_score_number, :credit_limit, :currency
11
-
12
- attribute_translation(
13
- id: :id,
14
- credit_score_number: :Name
15
- )
16
-
17
- def initialize(params)
18
- attributes.each do |attr|
19
- zoho_key = attr_to_zoho_key(attr)
20
-
21
- send("#{attr}=", params[zoho_key] || params[attr])
22
- end
23
-
24
- # Setup values as they come from the Zoho API if needed
25
- @account_id ||= params.dig(:Account_Name, :id)
26
- end
27
-
28
- def to_params
29
- params = super
30
-
31
- params[:Account_Name] = { id: @account_id } if @account_id
32
-
33
- params
34
- end
35
- end
36
- end
@@ -1,35 +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
- puts Rainbow(params).magenta
15
-
16
- attributes.each do |attr|
17
- zoho_key = attr_to_zoho_key(attr)
18
-
19
- send("#{attr}=", params[zoho_key] || params[attr])
20
- end
21
-
22
- @owner_id ||= params.dig(:Owner, :id)
23
- @vendor_id ||= params.dig(:Vendor_Name, :id)
24
- end
25
-
26
- def to_params
27
- params = super
28
-
29
- params[:Owner] = { id: @owner_id } if @owner_id
30
- params[:Vendor_Name] = { id: @vendor_id } if @vendor_id
31
-
32
- params
33
- end
34
- end
35
- end
@@ -1,42 +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, :extra_info
8
-
9
- attribute_translation(
10
- id: :id,
11
- stage: :Quote_Stage
12
- )
13
-
14
- def initialize(params)
15
- attributes.each do |attr|
16
- zoho_key = attr_to_zoho_key(attr)
17
- send("#{attr}=", params[zoho_key] || params[attr])
18
- end
19
-
20
- @potential_id ||= params.dig(:Deal_Name, :id)
21
- @account_id ||= params.dig(:Account_Name, :id)
22
- @owner_id ||= params.dig(:Owner, :id)
23
-
24
- # The Quote has an array of products but we only care about one
25
- if params.dig(:Product_Details)
26
- product = params.dig(:Product_Details).first
27
- @product_id = product.dig(:id)
28
- end
29
- end
30
-
31
- def to_params
32
- params = super
33
-
34
- params[:Deal_Name] = { id: @potential_id } if @potential_id
35
- params[:Account_Name] = { id: @account_id } if @account_id
36
- params[:Owner] = { id: @owner_id } if @owner_id
37
- params[:Product_Details] = [{ product: { id: @product_id }, quantity: 1 }] if @product_id
38
-
39
- params
40
- end
41
- end
42
- 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
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