Class: LinkIO::AppTarget
- Inherits:
-
Object
- Object
- LinkIO::AppTarget
- Defined in:
- lib/linkio/app_target.rb
Overview
A single app target that LinkIO can route to. A configuration may hold many
of them, keyed by a routing value (e.g. a "role" such as "user" or
"vendor"). Each target carries its own iOS/Android identifiers, schemes,
store URLs, and an optional per-role fallback_url.
Constant Summary collapse
- REQUIRED =
Fields required for a target to be usable.
%i[ios_app_id ios_team_id ios_bundle_id android_package_name].freeze
Instance Attribute Summary collapse
-
#android_app_scheme ⇒ Object
Returns the value of attribute android_app_scheme.
-
#android_package_name ⇒ Object
Returns the value of attribute android_package_name.
-
#android_sha256_fingerprints ⇒ Object
Returns the value of attribute android_sha256_fingerprints.
-
#fallback_url ⇒ Object
Returns the value of attribute fallback_url.
-
#ios_app_id ⇒ Object
Returns the value of attribute ios_app_id.
-
#ios_app_scheme ⇒ Object
Returns the value of attribute ios_app_scheme.
-
#ios_bundle_id ⇒ Object
Returns the value of attribute ios_bundle_id.
-
#ios_team_id ⇒ Object
Returns the value of attribute ios_team_id.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
-
#android_store_url ⇒ String
The Google Play URL for this target.
-
#apple_app_id ⇒ String
The AASA appID, "
. ". -
#initialize(key, attributes = {}) ⇒ AppTarget
constructor
A new instance of AppTarget.
-
#ios_store_url ⇒ String
The iOS App Store URL for this target.
-
#missing_fields ⇒ Array<Symbol>
Required fields that are missing.
-
#scheme_for(platform) ⇒ String?
The custom URL scheme for the given platform, if any.
-
#store_url(platform) ⇒ String
The store URL appropriate for the given platform.
Constructor Details
#initialize(key, attributes = {}) ⇒ AppTarget
Returns a new instance of AppTarget.
24 25 26 27 28 29 30 31 |
# File 'lib/linkio/app_target.rb', line 24 def initialize(key, attributes = {}) @key = key.to_s @android_sha256_fingerprints = [] attributes.each do |name, value| setter = "#{name}=" public_send(setter, value) if respond_to?(setter) end end |
Instance Attribute Details
#android_app_scheme ⇒ Object
Returns the value of attribute android_app_scheme.
12 13 14 |
# File 'lib/linkio/app_target.rb', line 12 def android_app_scheme @android_app_scheme end |
#android_package_name ⇒ Object
Returns the value of attribute android_package_name.
12 13 14 |
# File 'lib/linkio/app_target.rb', line 12 def android_package_name @android_package_name end |
#android_sha256_fingerprints ⇒ Object
Returns the value of attribute android_sha256_fingerprints.
20 21 22 |
# File 'lib/linkio/app_target.rb', line 20 def android_sha256_fingerprints @android_sha256_fingerprints end |
#fallback_url ⇒ Object
Returns the value of attribute fallback_url.
12 13 14 |
# File 'lib/linkio/app_target.rb', line 12 def fallback_url @fallback_url end |
#ios_app_id ⇒ Object
Returns the value of attribute ios_app_id.
12 13 14 |
# File 'lib/linkio/app_target.rb', line 12 def ios_app_id @ios_app_id end |
#ios_app_scheme ⇒ Object
Returns the value of attribute ios_app_scheme.
12 13 14 |
# File 'lib/linkio/app_target.rb', line 12 def ios_app_scheme @ios_app_scheme end |
#ios_bundle_id ⇒ Object
Returns the value of attribute ios_bundle_id.
12 13 14 |
# File 'lib/linkio/app_target.rb', line 12 def ios_bundle_id @ios_bundle_id end |
#ios_team_id ⇒ Object
Returns the value of attribute ios_team_id.
12 13 14 |
# File 'lib/linkio/app_target.rb', line 12 def ios_team_id @ios_team_id end |
#key ⇒ Object
Returns the value of attribute key.
12 13 14 |
# File 'lib/linkio/app_target.rb', line 12 def key @key end |
Instance Method Details
#android_store_url ⇒ String
Returns the Google Play URL for this target.
43 44 45 |
# File 'lib/linkio/app_target.rb', line 43 def android_store_url "https://play.google.com/store/apps/details?id=#{android_package_name}" end |
#apple_app_id ⇒ String
Returns the AASA appID, "
64 65 66 |
# File 'lib/linkio/app_target.rb', line 64 def apple_app_id "#{ios_team_id}.#{ios_bundle_id}" end |
#ios_store_url ⇒ String
Returns the iOS App Store URL for this target.
38 39 40 |
# File 'lib/linkio/app_target.rb', line 38 def ios_store_url "https://apps.apple.com/app/id#{ios_app_id}" end |
#missing_fields ⇒ Array<Symbol>
Returns required fields that are missing.
69 70 71 |
# File 'lib/linkio/app_target.rb', line 69 def missing_fields REQUIRED.select { |field| blank?(public_send(field)) } end |