Class: CampaignMaster::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/campaign_master/subscriber.rb

Constant Summary collapse

ImportError =
Class.new(RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Subscriber

Returns a new instance of Subscriber.



9
10
11
# File 'lib/campaign_master/subscriber.rb', line 9

def initialize(client)
  self.client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



7
8
9
# File 'lib/campaign_master/subscriber.rb', line 7

def client
  @client
end

Instance Method Details

#import(format, delimeter, subscribers) ⇒ Object

Raises:



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/campaign_master/subscriber.rb', line 13

def import(format, delimeter, subscribers)
  soap_client = CampaignMaster::SoapClient.get_client(self.get_import_headers(delimeter))

  response = soap_client.call(:submit_import_job,
          message_tag: "SubmitJobRequest",
          message: { FileToImport: Base64.encode64("#{format}\r\n#{subscribers}") },
          :attributes => CampaignMaster::SoapClient.attributes
  )

  raise ImportError if !self.valid_response?(response)

  response.body[:job_submission_result_message][:job_id].to_i
end