module Birdseed
Constants
- OPEN_TIMEOUT
- REQUEST_TIMEOUT
- VERSION
Public Class Methods
api_key=(key)
click to toggle source
# File lib/birdseed.rb, line 12 def self.api_key=(key) @@api_key = key end
deliver(options={})
click to toggle source
See github.com/edmodo/fatbird#send-emails-using-rest-api
# File lib/birdseed.rb, line 25 def self.deliver(options={}) api_key = options.delete(:api_key) || @@api_key response = RestClient::Request.execute( method: :post, url: "#{self.fatbird_host}/deliveries", payload: JSON.generate(options), headers: {"Authorization" => "api_key #{api_key}", :content_type => :json, :accept => :json}, timeout: REQUEST_TIMEOUT, open_timeout: OPEN_TIMEOUT ) Hashie::Mash.new(JSON.parse(response)) end
deliver_item(options={})
click to toggle source
See github.com/edmodo/fatbird#send-emails-using-rest-api
# File lib/birdseed.rb, line 40 def self.deliver_item(options={}) api_key = options.delete(:api_key) || @@api_key response = RestClient::Request.execute( method: :post, url: "#{self.fatbird_host}/delivery_items", payload: JSON.generate(options), headers: {"Authorization" => "api_key #{api_key}", :content_type => :json, :accept => :json}, timeout: REQUEST_TIMEOUT, open_timeout: OPEN_TIMEOUT ) Hashie::Mash.new(JSON.parse(response)) end
fatbird_host()
click to toggle source
# File lib/birdseed.rb, line 20 def self.fatbird_host @@fatbird_host ||= "https://fatbird.edmodo.com" end
fatbird_host=(host)
click to toggle source
# File lib/birdseed.rb, line 16 def self.fatbird_host=(host) @@fatbird_host = host end
sample_data(campaign_id, options={})
click to toggle source
# File lib/birdseed.rb, line 54 def self.sample_data(campaign_id, options={}) api_key = options.delete(:api_key) || @@api_key default_value = options[:default_value] || 'VALUE' response = RestClient.get( "#{self.fatbird_host}/campaigns/#{campaign_id}/sample_data?dafault_value=#{default_value}", {"Authorization" => "api_key #{api_key}", :content_type => :json, :accept => :json} ) JSON.parse(response) end