Class: Flexipass::MobileKey

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

Overview

Represents a mobile key in the Flexipass system.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ MobileKey

Initializes a new instance of the MobileKey class.



7
8
9
# File 'lib/flexipass/mobile_key.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#create(params) ⇒ Object

Creates a new mobile key.

Options Hash (params):

  • :Name (String)

    The name of the mobile key holder.

  • :Surname (String)

    The surname of the mobile key holder.

  • :Mail (String)

    The email of the mobile key holder.

  • :Door (String)

    The door associated with the mobile key.

  • :Checkin_date (String)

    The check-in date of the mobile key.

  • :Checkin_time (String)

    The check-in time of the mobile key.

  • :Checkout_date (String)

    The check-out date of the mobile key.

  • :Checkout_time (String)

    The check-out time of the mobile key.

  • :MobileKeyType (Integer)

    The type of the mobile key (0 or 1).

Raises:

  • (ArgumentError)

    If any required parameters are missing or if the date or time format is invalid.



24
25
26
27
# File 'lib/flexipass/mobile_key.rb', line 24

def create(params)
  validate_params(params)
  @client.send_request('POST', '/Flexipass/rest/webapi/createMobileKey', params)
end

#delete(mobile_key_id) ⇒ Object

Deletes a mobile key.



51
52
53
# File 'lib/flexipass/mobile_key.rb', line 51

def delete(mobile_key_id)
  @client.send_request('DELETE', "/Flexipass/rest/webapi/deleteMobileKey?mkID=#{mobile_key_id}")
end

#details(mobile_key_id) ⇒ Object

Retrieves details of a mobile key.



71
72
73
# File 'lib/flexipass/mobile_key.rb', line 71

def details(mobile_key_id)
  @client.send_request('GET', "/Flexipass/rest/webapi/getMobileKeyDetails?mkID=#{mobile_key_id}")
end

#list(door, params) ⇒ Object

Lists mobile keys for a specific door.

Options Hash (params):

  • :StartDate (String)

    The start date for filtering mobile keys.

  • :EndDate (String)

    The end date for filtering mobile keys.

Raises:

  • (ArgumentError)

    If the date format is invalid.



62
63
64
65
66
# File 'lib/flexipass/mobile_key.rb', line 62

def list(door, params)
  validate_list_params(params)
  params[:Door] = door
  @client.send_request('POST', "/Flexipass/rest/webapi/getMobileKeyList", params)
end

#send_mail(mobile_key_id) ⇒ Object

Sends an email for a mobile key.



78
79
80
# File 'lib/flexipass/mobile_key.rb', line 78

def send_mail(mobile_key_id)
  @client.send_request('GET', "/Flexipass/rest/webapi/sendMail?mkID=#{mobile_key_id}")
end

#send_sms(mobile_key_id) ⇒ Object

Sends an SMS for a mobile key.



85
86
87
# File 'lib/flexipass/mobile_key.rb', line 85

def send_sms(mobile_key_id)
  @client.send_request('GET', "/Flexipass/rest/webapi/sendSMS?mkID=#{mobile_key_id}")
end

#update(mobile_key_id, params) ⇒ Object

Updates an existing mobile key.

Options Hash (params):

  • :Name (String)

    The name of the mobile key holder.

  • :Surname (String)

    The surname of the mobile key holder.

  • :Mail (String)

    The email of the mobile key holder.

  • :Door (String)

    The door associated with the mobile key.

  • :Checkin_date (String)

    The check-in date of the mobile key.

  • :Checkin_time (String)

    The check-in time of the mobile key.

  • :Checkout_date (String)

    The check-out date of the mobile key.

  • :Checkout_time (String)

    The check-out time of the mobile key.

  • :MobileKeyType (Integer)

    The type of the mobile key (0 or 1).

Raises:

  • (ArgumentError)

    If any required parameters are missing or if the date or time format is invalid.



43
44
45
46
# File 'lib/flexipass/mobile_key.rb', line 43

def update(mobile_key_id, params)
  validate_params(params)
  @client.send_request('PUT', "/Flexipass/rest/webapi/updateMobileKey?mkID=#{mobile_key_id}", params)
end