class BranchIOCLI::BranchApp

Constants

API_ENDPOINT

Attributes

alternate_short_url_domain[R]
android_package_name[R]
android_uri_scheme[R]
default_short_url_domain[R]
ios_bundle_id[R]
ios_team_id[R]
ios_uri_scheme[R]
key[R]
short_url_domain[R]

Public Class Methods

[](key) click to toggle source
# File lib/branch_io_cli/branch_app.rb, line 9
def [](key)
  fetch key
end
fetch(key, cache: true) click to toggle source
# File lib/branch_io_cli/branch_app.rb, line 13
def fetch(key, cache: true)
  @apps ||= {}
  @apps[key] = new(key) unless cache && @apps[key]
  @apps[key]
end
new(key) click to toggle source
# File lib/branch_io_cli/branch_app.rb, line 32
def initialize(key)
  @key = key

  spinner = TTY::Spinner.new "[:spinner] Fetching configuration from Branch Dashboard for #{key}.", format: :flip
  spinner.auto_spin

  begin
    @hash = JSON.parse(Helper::BranchHelper.fetch("#{API_ENDPOINT}#{key}", spin: false)).symbolize_keys.merge key: key
    spinner.success
    @valid = true
  rescue StandardError => e
    spinner.error
    say e.message
    @valid = false
    return
  end

  @alternate_short_url_domain = @hash[:alternate_short_url_domain]
  @android_package_name = @hash[:android_package_name]
  @android_uri_scheme = @hash[:android_uri_scheme]
  @default_short_url_domain = @hash[:default_short_url_domain]
  @ios_bundle_id = @hash[:ios_bundle_id]
  @ios_team_id = @hash[:ios_team_id]
  @ios_uri_scheme = @hash[:ios_uri_scheme]
  @short_url_domain = @hash[:short_url_domain]
end

Public Instance Methods

domains() click to toggle source
# File lib/branch_io_cli/branch_app.rb, line 63
def domains
  [alternate_short_url_domain, default_short_url_domain, short_url_domain].compact.uniq
end
inspect() click to toggle source
# File lib/branch_io_cli/branch_app.rb, line 79
def inspect
  "#<BranchIOCLI::BranchApp #{self}>"
end
to_hash() click to toggle source
# File lib/branch_io_cli/branch_app.rb, line 67
def to_hash
  @hash
end
to_s() click to toggle source
# File lib/branch_io_cli/branch_app.rb, line 71
def to_s
  # Changes
  # {:key1=>"value1", :key2=>"value2"}
  # to
  # key1="value1" key2="value2"
  @hash.to_s.sub(/^\{\:/, '').sub(/\}$/, '').gsub(/, \:/, ' ').gsub(/\=\>/, '=')
end
valid?() click to toggle source
# File lib/branch_io_cli/branch_app.rb, line 59
def valid?
  @valid
end