Module: CampaignMonitor::Helpers

Included in:
CampaignMonitor, Campaign, Client, List, Subscriber
Defined in:
lib/campaign_monitor/helpers.rb

Instance Method Summary collapse

Instance Method Details

#formatted_timestamp(datetime, format = timestamp_format) ⇒ Object



20
21
22
# File 'lib/campaign_monitor/helpers.rb', line 20

def formatted_timestamp(datetime, format=timestamp_format)
  datetime.strftime(format)
end

#handle_response(response) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/campaign_monitor/helpers.rb', line 4

def handle_response(response)      
  return [] if response.empty?

  if response["Code"].to_i == 0
    # success!
    yield(response)
  else
    # error!
    raise response["Code"] + " - " + response["Message"]
  end      
end

#timestamp_formatObject



16
17
18
# File 'lib/campaign_monitor/helpers.rb', line 16

def timestamp_format
  '%Y-%m-%d %H:%M:%S'
end