Class: Touchpass::Rp::Verification

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/touchpass/rp/verification.rb

Instance Method Summary collapse

Constructor Details

#initializeVerification

debug_output



7
8
9
# File 'lib/touchpass/rp/verification.rb', line 7

def initialize
  self.class.base_uri Touchpass.base_uri
end

Instance Method Details

#cancel(id) ⇒ Object



33
34
35
36
37
# File 'lib/touchpass/rp/verification.rb', line 33

def cancel(id)
  http_options = { :body => {}, :headers => api_key_header }
  response = self.class.put("/verifications/#{id}/cancel.json", http_options)
  return Touchpass::Rp::Response.new(response)
end

#create(to_party, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/touchpass/rp/verification.rb', line 11

def create(to_party, options={})
  http_options = { :body => { :to_party => to_party }, :headers => api_key_header }

  # Defines which application will be used to handle the verification
  # (the default is to use the standalone app, or the first app registered)
  http_options[:body][:to_app_id] = Touchpass.app_id if Touchpass.app_id
  # puts "Touchpass.app_id: #{Touchpass.app_id}"

  # Get the verifying party devices so we can encrypt message/prp using the devices public key
  device = Touchpass::Rp::Device.new
  vp_devices = device.get_all(to_party).response
  # TODO: vp_devices can be empty here, in which case verification creation will fail.

  # Create verification object
  verification = Touchpass::Verification.new(vp_devices, options)
  http_options[:body].merge!(verification.http_params)

  response = self.class.post("/verifications.json", http_options)

  return Touchpass::Rp::Response.new(response)
end

#show(id) ⇒ Object



39
40
41
42
43
# File 'lib/touchpass/rp/verification.rb', line 39

def show(id)
  http_options = { :body => {}, :headers => api_key_header }
  response = self.class.get("/verifications/#{id}.json", http_options)
  return Touchpass::Rp::Response.new(response)
end