Sha256: 5e20c0676b55bef2749b0a558547b5368ed8e16662c78862df3e5f9c49f6ef63
Contents?: true
Size: 1.49 KB
Versions: 5
Compression:
Stored size: 1.49 KB
Contents
Dir[File.dirname(__FILE__) + '/../../vendor/*'].each do |directory| next unless File.directory?(directory) $LOAD_PATH.unshift File.expand_path(directory + '/lib') end require 'uri' require 'bigdecimal' require 'spreedly/version' module Spreedly # Generates a subscribe url for the given user id and plan. # Options: # :screen_name => a screen name for the user (shows up in the admin UI) # :email => pre-populate the email field # :first_name => pre-populate the first name field # :last_name => pre-populate the last name field def self.subscribe_url(id, plan, options={}) %w(screen_name email first_name last_name return_url).each do |option| options[option.to_sym] &&= URI.escape(options[option.to_sym]) end screen_name = options.delete(:screen_name) params = %w(email first_name last_name return_url).select{|e| options[e.to_sym]}.collect{|e| "#{e}=#{options[e.to_sym]}"}.join('&') url = "https://spreedly.com/#{site_name}/subscribers/#{id}/subscribe/#{plan}" url << "/#{screen_name}" if screen_name url << '?' << params unless params == '' url end # Generates an edit subscriber for the given subscriber token. The # token is returned with the subscriber info (i.e. by # Subscriber.find). def self.edit_subscriber_url(token, return_url = nil) "https://spreedly.com/#{site_name}/subscriber_accounts/#{token}" + if return_url "?return_url=#{URI.escape(return_url)}" else '' end end end
Version data entries
5 entries across 5 versions & 1 rubygems