pass_server.rb
# this one is an old routine
# for giving away a pass by web/admin link (in user's profile)
this one is an old routine
for giving away a pass by web/admin link (in user's profile)
this one is an old routine for giving away a pass by web / admin link ( in user ' s profile )
def deliver_pass(pass, is_user_attached=true)
    pass_id = pass[:id]
    user_id = pass[:user_id] if is_user_attached
    if is_user_attached && user_id
      user = self.users.where(:id => user_id).first || halt(404) 
    end
    passes_folder_path = File.dirname(File.expand_path(__FILE__)) + "/data/passes"
    template_folder_path = passes_folder_path + "/template"
    target_folder_path = passes_folder_path + "/#{pass_id}"
    if (File.exists?(target_folder_path))
      puts "[ ok ] Deleting existing pass data."
      FileUtils.remove_dir(target_folder_path)
    end
    puts "[ ok ] Creating pass data from template."
    FileUtils.cp_r template_folder_path + "/.", target_folder_path
    puts "[ ok ] Updating pass data."
    json_file_path = target_folder_path + "/pass.json"
    pass_json = JSON.parse(File.read(json_file_path))
    pass_json["passTypeIdentifier"] = settings.pass_type_identifier
    pass_json["teamIdentifier"] = settings.team_identifier
    pass_json["serialNumber"] = pass[:serial_number]
    pass_json["authenticationToken"] = pass[:authentication_token]
    pass_json["webServiceURL"] = "https://#{settings.hostname}:#{settings.port}/"
    ######
    File.open(json_file_path, "w") do |f|
      f.write JSON.pretty_generate(pass_json)
    end
    pass_folder_path = target_folder_path
    pass_signing_certificate_path = get_certificate_path
    wwdr_certificate_path = get_wwdr_certificate_path
    pass_output_path = passes_folder_path + "/#{pass_id}.pkpass"
    if File.exists?(pass_output_path)
      File.delete(pass_output_path)
    end
    ######
    pass_signer = SignPass.new(pass_folder_path, pass_signing_certificate_path, settings.certificate_password, wwdr_certificate_path, pass_output_path)
    pass_signer.sign_pass!
    puts '[ ok ] Sending pass file.'
    send_file(pass_output_path, :type => :pkpass, :filename => "iVeew.co.pkpass")
  end
def deliver_pass ( pass , is_user_attached = true ) pass_id = pass [ :id ] user_id = pass [ :user_id ] if is_user_attached if is_user_attached && user_id user = self . users . where ( :id => user_id ) . first || halt ( 404 ) end passes_folder_path = File . dirname ( File . expand_path ( __FILE__ ) ) + "/data/passes" template_folder_path = passes_folder_path + "/template" target_folder_path = passes_folder_path + "/#{pass_id}" if ( File . exists? ( target_folder_path ) ) puts "[ ok ] Deleting existing pass data." FileUtils . remove_dir ( target_folder_path ) end puts "[ ok ] Creating pass data from template." FileUtils . cp_r template_folder_path + "/." , target_folder_path puts "[ ok ] Updating pass data." json_file_path = target_folder_path + "/pass.json" pass_json = JSON . parse ( File . read ( json_file_path ) ) pass_json [ "passTypeIdentifier" ] = settings . pass_type_identifier pass_json [ "teamIdentifier" ] = settings . team_identifier pass_json [ "serialNumber" ] = pass [ :serial_number ] pass_json [ "authenticationToken" ] = pass [ :authentication_token ] pass_json [ "webServiceURL" ] = "https://#{settings.hostname}:#{settings.port}/" File . open ( json_file_path , "w" ) do | f | f . write JSON . pretty_generate ( pass_json ) end pass_folder_path = target_folder_path pass_signing_certificate_path = get_certificate_path wwdr_certificate_path = get_wwdr_certificate_path pass_output_path = passes_folder_path + "/#{pass_id}.pkpass" if File . exists? ( pass_output_path ) File . delete ( pass_output_path ) end pass_signer = SignPass . new ( pass_folder_path , pass_signing_certificate_path , settings . certificate_password , wwdr_certificate_path , pass_output_path ) pass_signer . sign_pass! puts '[ ok ] Sending pass file.' send_file ( pass_output_path , :type => :pkpass , :filename => "iVeew.co.pkpass" ) end
this one is an old routine
for giving away a pass by web/admin link (in user's profile)
this one is an old routine for giving away a pass by web / admin link ( in user ' s profile )
#, 'cannot find user with specified identifier' # Configure folder paths # Delete pass folder if it already exists # Copy pass files from template folder ###################### # here should be 'get json pass template/payload from DB' ###################### #******************************************************** # Modify the pass json ###pass_json["barcode"]["message"] = barcode_string_for_pass(pass) #if user #  pass_json["storeCard"]["primaryFields"][0]["value"] = user[:account_balance] #  pass_json["storeCard"]["secondaryFields"][0]["value"] = user[:name] #else #  pass_json["storeCard"]["primaryFields"][0]["value"] = 1000000 # just a demo value #  pass_json["storeCard"]["secondaryFields"][0]["value"] = "John Doe" # a demo value #end #******************************************************** # Write out the updated JSON ############################ # => to DB # ************************** # Prepare for pass signing # Remove the old pass if it exists # Generate and sign the new pass ############################ # => to DB # ************************** # ************************** # Send the pass file
pass
<not_specific>
is_user_attached
<not_specific>