tesults 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tesults.rb +27 -0
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c15259469dbfd58bd8b47b3cf55c29b12d23ca3d
4
- data.tar.gz: 8b67e87c3f63525541d305d29847ea86c2d02e49
3
+ metadata.gz: 7fa9be7865cbdeda9f2eccd4dd11c4810788b279
4
+ data.tar.gz: 3aebfd30793e3d4ccb90ebce82215b9611e6d846
5
5
  SHA512:
6
- metadata.gz: 65e3ad7d510141d0ec533835140c1d14fc922401dfb325c15f697f5a39337982c7aaf12ee280f055cf63053553f16c4d05031b1531430a6baf76f7fc8f80c139
7
- data.tar.gz: 696dd96e55766068df1b8c0c05bb9e3e3d421215616f9dcdcf61e9f4e07a323450b3cc4b10cd9695702fe06bad80a85217a3368303293ce83f735094c6aea70f
6
+ metadata.gz: 2a43aa758c8d5284900d819fd954dac879baffa35c1b28d720115b3d4b9974542648f9ff8d4eb23ea7e4d63154d38899c091f684ebc02c1eadbc4b0aca894f7d
7
+ data.tar.gz: cece65ac6296ca768f93c1862b24295c020923a9327965e7bee21433cf71ac84b2990e8d14ed2a67945aa5eddf9dc4faaf44cd1e84436d690acd4c324c4d9dde
data/lib/tesults.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+ require 'uri'
3
+ require 'net/https'
4
+
5
+ module Tesults
6
+ def self.upload(data)
7
+ uri = URI("https://www.tesults.com/results")
8
+ http = Net::HTTP.new(uri.host, uri.port)
9
+ http.use_ssl = true
10
+ req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
11
+ req.body = data.to_json
12
+ res = http.request(req)
13
+ jsonData = JSON.parse(res.body)
14
+ success = false
15
+ message = ""
16
+ if jsonData['error'] == nil
17
+ success = true
18
+ message = (jsonData['data'])['message']
19
+ else
20
+ success = false
21
+ message = (jsonData['error'])['message']
22
+ end
23
+ val = {:success => success, :message => message}
24
+ rescue => e
25
+ val = {:success => false, :message => e}
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tesults
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tesults
@@ -17,7 +17,8 @@ email:
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
- files: []
20
+ files:
21
+ - lib/tesults.rb
21
22
  homepage: https://www.tesults.com
22
23
  licenses:
23
24
  - MIT