Class: Passkit::Configuration

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

Constant Summary collapse

DEFAULT_AUTHENTICATION =
proc do
  authenticate_or_request_with_http_basic("Passkit Dashboard. Login required") do |username, password|
    username == ENV["PASSKIT_DASHBOARD_USERNAME"] && password == ENV["PASSKIT_DASHBOARD_PASSWORD"]
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



42
43
44
45
46
47
48
49
50
51
# File 'lib/passkit.rb', line 42

def initialize
  @available_passes = {"Passkit::ExampleStoreCard" => -> {}}
  @web_service_host = ENV["PASSKIT_WEB_SERVICE_HOST"] || (raise "Please set PASSKIT_WEB_SERVICE_HOST")
  raise("PASSKIT_WEB_SERVICE_HOST must start with https://") unless @web_service_host.start_with?("https://")
  @certificate_key = ENV["PASSKIT_CERTIFICATE_KEY"] || (raise "Please set PASSKIT_CERTIFICATE_KEY")
  @private_p12_certificate = ENV["PASSKIT_PRIVATE_P12_CERTIFICATE"] || (raise "Please set PASSKIT_PRIVATE_P12_CERTIFICATE")
  @apple_intermediate_certificate = ENV["PASSKIT_APPLE_INTERMEDIATE_CERTIFICATE"] || (raise "Please set PASSKIT_APPLE_INTERMEDIATE_CERTIFICATE")
  @apple_team_identifier = ENV["PASSKIT_APPLE_TEAM_IDENTIFIER"] || (raise "Please set PASSKIT_APPLE_TEAM_IDENTIFIER")
  @pass_type_identifier = ENV["PASSKIT_PASS_TYPE_IDENTIFIER"] || (raise "Please set PASSKIT_PASS_TYPE_IDENTIFIER")
end

Instance Attribute Details

#apple_intermediate_certificateObject

Returns the value of attribute apple_intermediate_certificate.



24
25
26
# File 'lib/passkit.rb', line 24

def apple_intermediate_certificate
  @apple_intermediate_certificate
end

#apple_team_identifierObject

Returns the value of attribute apple_team_identifier.



24
25
26
# File 'lib/passkit.rb', line 24

def apple_team_identifier
  @apple_team_identifier
end

#available_passesObject

Returns the value of attribute available_passes.



24
25
26
# File 'lib/passkit.rb', line 24

def available_passes
  @available_passes
end

#certificate_keyObject

Returns the value of attribute certificate_key.



24
25
26
# File 'lib/passkit.rb', line 24

def certificate_key
  @certificate_key
end

#pass_type_identifierObject

Returns the value of attribute pass_type_identifier.



24
25
26
# File 'lib/passkit.rb', line 24

def pass_type_identifier
  @pass_type_identifier
end

#private_p12_certificateObject

Returns the value of attribute private_p12_certificate.



24
25
26
# File 'lib/passkit.rb', line 24

def private_p12_certificate
  @private_p12_certificate
end

#web_service_hostObject

Returns the value of attribute web_service_host.



24
25
26
# File 'lib/passkit.rb', line 24

def web_service_host
  @web_service_host
end

Instance Method Details

#authenticate_dashboard_with(&block) ⇒ Object



37
38
39
40
# File 'lib/passkit.rb', line 37

def authenticate_dashboard_with(&block)
  @authenticate = block if block
  @authenticate || DEFAULT_AUTHENTICATION
end