Class: AppStoreConnectAPI::Client
- Inherits:
-
Object
- Object
- AppStoreConnectAPI::Client
- Includes:
- TestFlight::BetaTesters, HTTParty
- Defined in:
- lib/app_store_connect_api/client.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(issuer_id, key_id, access_key_path) ⇒ Client
constructor
Configure the client.
Methods included from TestFlight::BetaTesters
Constructor Details
#initialize(issuer_id, key_id, access_key_path) ⇒ Client
Configure the client
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/app_store_connect_api/client.rb', line 32 def initialize(issuer_id, key_id, access_key_path) raise ConfigurationError, 'issuer_id is required' if issuer_id.nil? raise ConfigurationError, 'key_id is required' if key_id.nil? raise ConfigurationError, 'access_key_path is required' if access_key_path.nil? private_key = OpenSSL::PKey.read(File.read(access_key_path)) @token = JWT.encode( { iss: issuer_id, exp: Time.now.to_i + 20 * 60, aud: 'appstoreconnect-v1' }, private_key, 'ES256', header_fields={ kid: key_id } ) end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
22 23 24 |
# File 'lib/app_store_connect_api/client.rb', line 22 def token @token end |
Instance Method Details
#headers ⇒ Object
52 53 54 |
# File 'lib/app_store_connect_api/client.rb', line 52 def headers { 'Authorization' => "Bearer #{@token}" } end |