class LivePaper::LivePaperSession
Public Class Methods
new(auth)
click to toggle source
# File lib/live_paper.rb, line 24 def initialize(auth) #todo: tdd, verify hash $lpp_basic_auth = Base64.strict_encode64("#{auth[:id]}:#{auth[:secret]}") BaseObject::request_access_token BaseObject::request_project_id if $lpp_access_token @remote_resources={} end
Public Instance Methods
qr_bytes(dest)
click to toggle source
# File lib/live_paper.rb, line 61 def qr_bytes(dest) t=QrTrigger.create(name: 'QR code trigger') p=Payoff.create(name: 'name', type: Payoff::TYPE[:WEB], url: dest) l=Link.create(payoff_id: p.id, trigger_id: t.id, name: "link") @remote_resources={link: l, payoff: p, trigger: t} t.download_qrcode end
resources()
click to toggle source
# File lib/live_paper.rb, line 33 def resources @remote_resources end
shorten(dest)
click to toggle source
# File lib/live_paper.rb, line 53 def shorten(dest) t=ShortTrigger.create(name: 'short trigger') p=Payoff.create(name: 'name', type: Payoff::TYPE[:WEB], url: dest) l=Link.create(payoff_id: p.id, trigger_id: t.id, name: "link") @remote_resources={link: l, payoff: p, trigger: t} t.short_url end
smart_link(dest, image=nil)
click to toggle source
# File lib/live_paper.rb, line 37 def smart_link(dest, image=nil) uber = {} uber[:short] = shorten dest qr_data = qr_bytes dest File.open("uber-qr.png", "wb") { |f| f.write(qr_data) } uber[:qr] = "./uber-qr.png" if image wm_bytes = watermark_bytes(dest, image) File.open("uber-wm.jpg", "wb") { |f| f.write(wm_bytes) } uber[:wm] = 'uber-wm.jpg' end uber end
watermark_bytes(dest, image_uri)
click to toggle source
# File lib/live_paper.rb, line 69 def watermark_bytes(dest, image_uri) image = Image.upload image_uri t=WmTrigger.create(name: 'watermark') p=Payoff.create(name: 'name', type: Payoff::TYPE[:WEB], url: dest) l=Link.create(payoff_id: p.id, trigger_id: t.id, name: "link") @remote_resources={link: l, payoff: p, trigger: t} t.download_watermark(image) rescue Exception => e puts "Exception!" puts e.response end