Class: PeanutLabs::Builder::IframeUrl
- Inherits:
-
Object
- Object
- PeanutLabs::Builder::IframeUrl
- Defined in:
- lib/peanut_labs/builder/iframe_url.rb
Constant Summary collapse
- ENDPOINT =
'https://www.peanutlabs.com/userGreeting.php'.freeze
Instance Method Summary collapse
-
#call(params) ⇒ Object
Documentation here: peanut-labs.github.io/publisher-doc/index.html#iframe-optionalpara.
-
#initialize(params = nil) ⇒ IframeUrl
constructor
A new instance of IframeUrl.
Constructor Details
#initialize(params = nil) ⇒ IframeUrl
Returns a new instance of IframeUrl.
11 12 13 |
# File 'lib/peanut_labs/builder/iframe_url.rb', line 11 def initialize(params=nil) @credentials = Credentials.new(params) end |
Instance Method Details
#call(params) ⇒ Object
Documentation here: peanut-labs.github.io/publisher-doc/index.html#iframe-optionalpara
Accepts these parameters
params[:id] -> required, specially encoded from peanut labs user_id
params[:dob] -> not required, classes accepted - Date, DateTime, Time or formatted "MM-DD-YYYY" string
params[:sex] -> not required, 1 for male, 2 for female
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/peanut_labs/builder/iframe_url.rb', line 23 def call(params) raise PeanutLabs::UserIdMissingError if params[:id].nil? || params[:id].empty? result = "#{ENDPOINT}?userId=#{UserId.new(credentials: credentials).call(params[:id])}" if (sex = PeanutLabs::Parser::Sex.call(params[:sex])) result << "&sex=#{sex}" end if (dob = PeanutLabs::Parser::DateOfBirth.iframe(params[:dob])) result << "&dob=#{dob}" end result end |