yikyak 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/yikyak.rb +46 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d06f95c73646b7728e0db990546dd0563945f0bd
|
4
|
+
data.tar.gz: 545959bc98b642dbc74e6f44c58f46bd14743fdf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 00b0f96e85bc2018c785a04c63d1fcdb75a86c780961671f0822329b82a566ff43a125f88f719c50f1c9898d5f7c4e18be9b357c84dedee2f0a5dd2cd81811f7
|
7
|
+
data.tar.gz: 17491c7f6d30f62886cb05389c41bf933c1d585bbb09fb784b00300a6d603b4b775b827181209909c8573c7635612c185d1837f60d041318fbcce5fd122a9063
|
data/lib/yikyak.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'jwt'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
class YikYak
|
5
|
+
URL = 'https://api.yikyak.io/status/v1beta1'
|
6
|
+
|
7
|
+
def initialize user, app, secret
|
8
|
+
@user = user
|
9
|
+
@app = app
|
10
|
+
@secret = secret
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_status status
|
14
|
+
endpoint = '/setstatus'
|
15
|
+
payload = {
|
16
|
+
UserToken: @user,
|
17
|
+
ApplicationId: @app,
|
18
|
+
Status: status,
|
19
|
+
Latitude: 0,
|
20
|
+
Longitude: 0,
|
21
|
+
IgnoreLatLng: true,
|
22
|
+
VelocityEsitmateMagnitude: 0,
|
23
|
+
VelocityEsitmateTheta: 0,
|
24
|
+
Checksum: ''
|
25
|
+
}
|
26
|
+
|
27
|
+
post endpoint, payload
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def post(endpoint, payload)
|
33
|
+
options = {
|
34
|
+
body: prepare(payload).to_json,
|
35
|
+
headers: { 'Content-Type' => 'application/json' }
|
36
|
+
}
|
37
|
+
res = HTTParty.post(URL + endpoint, options)
|
38
|
+
res.code/100 == 2 # Returns true if the request worked and false otherwise
|
39
|
+
end
|
40
|
+
|
41
|
+
def prepare(payload)
|
42
|
+
token = JWT.encode payload, Array(@secret).pack('H*'), 'HS512'
|
43
|
+
payload[:Checksum] = token
|
44
|
+
payload
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yikyak
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luis Ferrer-Labarca
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Super easy Ruby library for using YikYak's public API
|
14
|
+
email: gems@ferrerluis.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/yikyak.rb
|
20
|
+
homepage: http://rubygems.org/gems/yikyak
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.5.1
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Ruby Wrapper for YikYak's API
|
44
|
+
test_files: []
|