module Twizo::BackupCodes

Attributes

params[R]

Getter for params

Public Instance Methods

delete() click to toggle source

Delete de backup codes

@return [Object]

# File lib/twizo/modules/backup_codes.rb, line 79
def delete
  response = send_api_call(Entity::ACTION_REMOVE, "#{location}/#{@params.identifier}")

  raise response if response.kind_of?(TwizoError)

  # return 204 No Content
  response
end
send() click to toggle source

Send message to the server and return response

@return [Object]

# File lib/twizo/modules/backup_codes.rb, line 36
def send
  post_params = @params.to_json

  response = send_api_call(Entity::ACTION_CREATE, location, post_params)

  raise response if response.kind_of?(TwizoError)

  response_to_array(response)
end
set(identifier) click to toggle source

@param [String] identifier

# File lib/twizo/modules/backup_codes.rb, line 26
def set(identifier)
  @params = BackupCodesParams.new
  @params.identifier = identifier
end
update() click to toggle source

Update de backup codes

@return [Object]

# File lib/twizo/modules/backup_codes.rb, line 64
def update
  post_params = @params.to_json

  response = send_api_call(Entity::ACTION_UPDATE, "#{location}/#{@params.identifier}", post_params)

  raise response if response.kind_of?(TwizoError)

  response_to_array(response)
end
verify(backup_code) click to toggle source

@param [String] backup_code

@return [Object]

# File lib/twizo/modules/backup_codes.rb, line 51
def verify(backup_code)
  response = send_api_call(Entity::ACTION_RETRIEVE, "#{location}/#{@params.identifier}?token=#{backup_code}")

  raise response if response.kind_of?(TwizoError)

  response_to_array(response)
end

Private Instance Methods

location() click to toggle source

@return [String]

# File lib/twizo/modules/backup_codes.rb, line 93
def location
  'backupcode'
end