Class: Cb::EmailSubscriptionApi

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/clients/email_subscription_api.rb

Class Method Summary collapse

Class Method Details

.modify_subscription(ext_id, host_site, career_resources, product_sponsor_info, applicant_survey_invites, job_recs, unsubscribe_all) ⇒ Object

Update subscription values for a user

For detailed information around this API please visit: http://api.careerbuilder.com/usersubscriptionretrieve.aspx



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cb/clients/email_subscription_api.rb', line 27

def self.modify_subscription ext_id, host_site, career_resources, product_sponsor_info, applicant_survey_invites, job_recs, unsubscribe_all
  if unsubscribe_all && unsubscribe_all != 'false'
    career_resources = product_sponsor_info = applicant_survey_invites = job_recs = false.to_s
  end

  career_resources = career_resources.nil? ? 'false' : career_resources
  product_sponsor_info = product_sponsor_info.nil? ? 'false' : product_sponsor_info
  applicant_survey_invites = applicant_survey_invites.nil? ? 'false' : applicant_survey_invites
  job_recs = job_recs.nil? ? 'false' : job_recs
  unsubscribe_all = unsubscribe_all.nil? ? 'false' : unsubscribe_all

  my_api = Cb::Utils::Api.new()

  xml_body = "<Request>"
  xml_body += "<DeveloperKey>" + Cb.configuration.dev_key.to_s + "</DeveloperKey>"
  xml_body += "<ExternalID>" + ext_id.to_s + "</ExternalID>"
  xml_body += "<Hostsite>" + host_site.to_s + "</Hostsite>"
  xml_body += "<CareerResources>" + career_resources.to_s + "</CareerResources>"
  xml_body += "<ProductSponsorInfo>" + product_sponsor_info.to_s + "</ProductSponsorInfo>"
  xml_body += "<ApplicantSurveyInvites>" + applicant_survey_invites.to_s + "</ApplicantSurveyInvites>"
  xml_body += "<JobRecs>" + job_recs.to_s + "</JobRecs>"
  xml_body += "<UnsubscribeAll>" + unsubscribe_all.to_s + "</UnsubscribeAll>"
  xml_body += "</Request>"


  cb_response = my_api.cb_post(Cb.configuration.uri_subscription_modify,
                              :body => xml_body)

  json_hash = JSON.parse(cb_response.response.body)

  subscription = CbEmailSubscription.new(json_hash['SubscriptionValues'])

  return subscription
end

.retrieve_by_did(did, host_site = '') ⇒ Object

Retrieve subscription values for a user

For detailed information around this API please visit: http://api.careerbuilder.com/usersubscriptionretrieve.aspx



11
12
13
14
15
16
17
18
# File 'lib/cb/clients/email_subscription_api.rb', line 11

def self.retrieve_by_did(did, host_site = '')
  my_api = Cb::Utils::Api.new()
  cb_response = my_api.cb_get(Cb.configuration.uri_subscription_retrieve, :query => {:ExternalID => did, :Hostsite => host_site})
  json_hash = JSON.parse(cb_response.response.body)
  subscription = CbEmailSubscription.new(json_hash['SubscriptionValues'])

  return subscription
end