Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sets up Apple::Api inspect #724

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions app/models/apple/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ class Api
attr_accessor :provider_id, :key_id, :key, :bridge_url

def self.from_env
apple_key_pem = Base64.decode64(ENV["APPLE_KEY_PEM_B64"])
apple_key_id = ENV["APPLE_KEY_ID"]
apple_provider_id = ENV["APPLE_PROVIDER_ID"]
apple_key_pem_b64 = ENV["APPLE_KEY_PEM_B64"]

new(provider_id: ENV["APPLE_PROVIDER_ID"],
key_id: ENV["APPLE_KEY_ID"],
raise "Apple::Api.from_env Apple key details missing from ENV" if [apple_key_id, apple_provider_id, apple_key_pem_b64].any?(&:blank?)

apple_key_pem = Base64.decode64(apple_key_pem_b64)

new(provider_id: apple_provider_id,
key_id: apple_key_id,
key: apple_key_pem)
end

Expand All @@ -40,6 +46,10 @@ def initialize(provider_id:, key_id:, key:, bridge_url: nil)
@bridge_url = URI(bridge_url)
end

def inspect
"#<Apple:Api:#{object_id} key_id=#{@key_id || "nil"} bridge_url=#{@bridge_url || "nil"}>"
end

def ec_key
@ec_key ||= OpenSSL::PKey::EC.new(key)
end
Expand Down