Class: Talkable::Offer

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/talkable/resources/offer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(result_hash) ⇒ Object



3
4
5
6
7
8
# File 'lib/talkable/resources/offer.rb', line 3

def self.parse(result_hash)
  return nil unless result_hash && result_hash[:offer] && result_hash[:offer].size > 0
  offer = self.new(result_hash[:offer])
  offer.claim_links ||= Hashie::Mash.new(result_hash[:claim_links])
  offer
end

Instance Method Details

#advocate_share_iframe(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/talkable/resources/offer.rb', line 10

def advocate_share_iframe(options = {})
  show_trigger = !options[:ignore_trigger]
  iframe_options = default_iframe_options.merge(options[:iframe] || {})
  url = show_trigger ? Furi.merge(show_url, query: {trigger_enabled: 1}) : show_url

  snippets = []
  if !options[:iframe] || !options[:iframe][:container]
    snippets << render_container_snipet(iframe_options[:container])
  end
  snippets << render_share_snipet({
    url: url,
    iframe: iframe_options,
  })

  snippets.join("\n")
end