Class: FFS::Share

Inherits:
Object
  • Object
show all
Defined in:
lib/ffs/share.rb

Constant Summary collapse

DEFAULT =
{
  android: true,
  ios: true,
  min_package: false,
  ipad: false,
  custom_scheme: false,
  fallback: false,
  analytics: false,
  bitly: false
}.freeze

Instance Method Summary collapse

Instance Method Details



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ffs/share.rb', line 18

def generate_dynamic_link(hash, **options)
  opts = DEFAULT.merge(options)
  uri = URI.parse("https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=#{FFS.configuration.firebase_api_key}")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  headers = { 'Content-Type' => 'application/json' }
  body = build_json_body(hash, opts)
  res = http.post(uri, body, headers).body

  return res unless opts[:bitly]
  shorten_with_bitly(res)
end