Class: Readiness::Salesforce::Contacts
- Defined in:
- lib/support_readiness/salesforce/contacts.rb
Overview
Defines the class Contacts within the module Readiness::Salesforce.
Class Method Summary collapse
-
.usgov_contacts(client) ⇒ Array
Return an Array of contacts from Salesforce for US Government support.
-
.usgov_sync_object(contact) ⇒ Object
Return a Hash used for the contact sync for US Government support.
-
.usgov_sync_query_string ⇒ Object
Return a String used for the contact sync for US Government support.
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Class Method Details
.usgov_contacts(client) ⇒ Array
Return an Array of contacts from Salesforce for US Government support
32 33 34 35 36 37 38 39 |
# File 'lib/support_readiness/salesforce/contacts.rb', line 32 def self.usgov_contacts(client) query = Queries.new(usgov_sync_query_string) results = Queries.run!(client, query) contacts = results.map { |r| usgov_sync_object(r) }.compact.uniq grouped = contacts.group_by { |a| a['email'] }.values duplicates = grouped.select { |a| a.size > 1 }.flatten (contacts - duplicates).compact.uniq end |
.usgov_sync_object(contact) ⇒ Object
Return a Hash used for the contact sync for US Government support
46 47 48 49 50 51 52 53 54 |
# File 'lib/support_readiness/salesforce/contacts.rb', line 46 def self.usgov_sync_object(contact) { "name" => contact.Name, "email" => contact.Email.downcase, "org" => "#{Digest::SHA1.hexdigest(contact.Account.Account_ID_18__c)[0..7]} #{contact.Account.Name}", "salesforce_id" => contact.Account.Account_ID_18__c, "not_in_sfdc" => false } end |
.usgov_sync_query_string ⇒ Object
Return a String used for the contact sync for US Government support
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/support_readiness/salesforce/contacts.rb', line 61 def self.usgov_sync_query_string <<~QUERY SELECT Name, Email, Account.Account_ID_18__c, Account.Name FROM Contact WHERE Inactive_Contact__c = false AND Name != '' AND Email != '' AND Role__c INCLUDES ('Gitlab Admin') AND ( NOT Email LIKE '%gitlab.com' ) AND Account.Type IN ('Customer', 'Former Customer') AND AccountId IN ( SELECT Zuora__Account__c FROM Zuora__SubscriptionProductCharge__c WHERE Subscription_Status__c = 'Active' AND Zuora__EffectiveEndDate__c >= #{(Date.today - 91.days).iso8601} AND ( Name IN ( '12x5 US Citizen Support - 1 Year', '12x5 US Citizen Support - 2 Year', '12x5 US Citizen Support - 3 Year', '12x5 US Citizen Support - Monthly', '24x7 US Citizen Support - 1 Year', '24x7 US Citizen Support - 2 Year', '24x7 US Citizen Support - 3 Year', '24x7 US Citizen Support - Monthly', 'GitLab Dedicated for US Public Sector - Ultimate - 1 Year', 'GitLab Dedicated for US Public Sector - Ultimate - 2 Year', 'GitLab Dedicated for US Public Sector - Ultimate - 3 Year', 'GitLab Dedicated for US Public Sector - Ultimate - Monthly' ) OR Zuora__Account__r.Support_Instance__c = 'federal-support' ) ) QUERY end |