Sha256: 81894b05d0846b0a4e5d58ce16d1b0127d2665f8e1c7e60660086d57eba28fb3

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

class CampaignMonitor
  module Helpers

    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

    def wsdl_driver_factory
      SOAP::WSDLDriverFactory.new("#{api_url}?WSDL")
    end

    def using_soap
      driver = wsdl_driver_factory.create_rpc_driver
      response = yield(driver)
      driver.reset_stream
      response
    end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turingstudio-campaign_monitor-1.3.1 lib/campaign_monitor/helpers.rb