safeguard-api 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/safeguard-api/api.rb +31 -0
- data/lib/safeguard-api.rb +22 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OGE5NTE2YWU3ZjRkZDBhNTkyNjNkNGZlZTdlNTVlNTU4MzZhMGFjMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTA0Zjc2MTk2MDIzNzgxMjhlNzk5M2FmMjE2MWViZTI0MjhmMDc0MA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTA4NjY3NWM3ZWY0NTYzM2E3YjJmN2Q0NjkyODJiYjZlOTk0OWQ4NTYxNzdm
|
10
|
+
MzQ0NjM0ZGMzODIxNmJjNDIwYTI3ZWM3ZjZlNDg1ZTEzMjI5ZGFhMTBiNDYx
|
11
|
+
OGE1MDcwMjYwZGYxNzUzZmU3NmE3YTE4ODQzYjBlMGFmNjY3ZTA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Nzc4MTg5YzdiYjhlN2FhYTM0YjBkMzdmNTlkOTY3YjEwY2MyZDI3MGZlMjRk
|
14
|
+
Mjc0Y2JiNDMwNzg4OGI3ZDU3Nzk1Y2IxNmRmYjY2MzQwNDRmNjg4NzU0ZTM4
|
15
|
+
YmIxMTAxODM1YzUyNDY1M2FhNTc2MGI2OGNlYzZhNzUxYmFjNjE=
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'json'
|
4
|
+
module Safeguard
|
5
|
+
class API
|
6
|
+
|
7
|
+
def self.is_valid?(params)
|
8
|
+
token = params[:token]
|
9
|
+
email = params[:email]
|
10
|
+
parsed_response = get "check_token_password?token=#{token}&email=#{email}"
|
11
|
+
return true if parsed_response['status'] == 200
|
12
|
+
return false
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def self.get uri
|
17
|
+
begin
|
18
|
+
url = "#{Safeguard.api_uri}/#{uri}&api_key=#{Safeguard.api_key}"
|
19
|
+
response = URI.parse(url).read
|
20
|
+
parsed_response = parse_response response
|
21
|
+
rescue
|
22
|
+
parsed_response = {:status => 500}
|
23
|
+
end
|
24
|
+
parsed_response
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.parse_response response
|
28
|
+
JSON.parse response
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.unshift File.expand_path("..", __FILE__)
|
2
|
+
module Safeguard
|
3
|
+
class << self
|
4
|
+
def api_key=(key)
|
5
|
+
@api_key = key
|
6
|
+
end
|
7
|
+
|
8
|
+
def api_key
|
9
|
+
@api_key
|
10
|
+
end
|
11
|
+
|
12
|
+
def api_uri=(uri)
|
13
|
+
@api_uri = uri
|
14
|
+
end
|
15
|
+
|
16
|
+
def api_uri
|
17
|
+
@api_uri
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'safeguard-api/api'
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: safeguard-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ''
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Gem to access Safeguard API
|
14
|
+
email: contato@vizir.com.br
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/safeguard-api.rb
|
20
|
+
- lib/safeguard-api/api.rb
|
21
|
+
homepage: ''
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.2.2
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Safeguard API
|
45
|
+
test_files: []
|
46
|
+
has_rdoc:
|