Sha256: 4c08e29b06b9a44511480395b5a072a073fa54109b51432db1bc53d15c4f2b5f
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'faraday' require 'faraday_middleware' module Ask extend self API_URL = "https://api.asksurveys.com/" attr_accessor :api_token # Sends a POST to the Asksurveys API to schedule a satisfaction survey to be sent # after a set amount of time. # # @see http://asksurveys.com/docs # # @param [User] user The user to send a survey to. # @param [FixNum] delay How long to wait before sending the survey. # @param [Hash] properties Additional properties to send about # this user, purchase, item, etc. def schedule_nps(email, name=nil, delay=nil, properties = {}) unless defined?(Ask.api_token) raise "Make sure to set the API key before using the library: Ask.key = '1234567890'" end connection = Faraday.new(url: API_URL) do |faraday| faraday.basic_auth api_token, '' faraday.request :url_encoded faraday.response :json # Parses response bodies as json. faraday.adapter Faraday.default_adapter end payload = {} payload[:email] = email payload[:name] = name if name payload[:schedule_at] = delay if delay payload[:properties] = properties connection.post "/v1/nps.json", payload end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ask-ruby-0.0.2 | lib/ask.rb |