Class: Passkit::Api::V1::RegistrationsController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/passkit/api/v1/registrations_controller.rb

Overview

TODO: check with authentication_token This Class Implements the Apple PassKit API

See Also:

  • https://developer.apple.com/library/archive/documentation/PassKit/Reference/PassKit_WebService/WebService.html
  • https://walletpasses.io/developer/

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/passkit/api/v1/registrations_controller.rb', line 16

def create
  if @pass.devices.find_by(identifier: params[:device_id])
    render json: {}, status: :ok
    return
  end

  register_device
  render json: {}, status: :created
end

#destroyObject



50
51
52
53
54
# File 'app/controllers/passkit/api/v1/registrations_controller.rb', line 50

def destroy
  registrations = @pass.registrations.where(passkit_device_id: params[:device_id])
  registrations.delete_all
  render json: {}, status: :ok
end

#showObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/passkit/api/v1/registrations_controller.rb', line 32

def show
  if @device.nil?
    render json: {}, status: :not_found
    return
  end

  passes = fetch_registered_passes
  if passes.none?
    render json: {}, status: :no_content
    return
  end

  render json: updatable_passes(passes).to_json
end