kontakt 0.0.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/kontakt.rb +75 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 04e4e243e12b43bbdd9e50487f0d8dedcec8e1e8
|
4
|
+
data.tar.gz: 04fb7370c21429b551f13b6da3c990680bde3683
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1841a6393c2e66ff1f2387fdbd9eaa3c11d458991a42b42af5423c5343e00a6794340b5d422dcca41f70144ca619c5d150cf96a28a5b4f7980a8e09634733620
|
7
|
+
data.tar.gz: 57ed241ceec02a250e6be938a5e586f9636e4e43dec368e76bed4950ef2c019f7986ec9fc3e012c2c9b57b59914fdbd95be257d5c4b228c5b200a04867fef8ff
|
data/lib/kontakt.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# For use with Kontakt.io API only.
|
2
|
+
# http://docs.kontakt.io/rest-api
|
3
|
+
|
4
|
+
# This is an unoffical gem for Kontakt.io
|
5
|
+
# the authors have no affiliation Kontakt.io
|
6
|
+
|
7
|
+
require 'rest-client'
|
8
|
+
require 'yaml'
|
9
|
+
|
10
|
+
module Kontakt
|
11
|
+
GEM_ROOT = File.expand_path("../..", __FILE__)
|
12
|
+
AUTH_INFO = YAML.load_file("#{GEM_ROOT}/config/kontakt.yml")
|
13
|
+
API_URL = "https://api.kontakt.io"
|
14
|
+
RESOURCE_DATA = {:accept => "application/vnd.com.kontakt+json;version=6", :"Api-Key" => AUTH_INFO["key"], :content_type => "application/x-www-form-urlencoded"}
|
15
|
+
|
16
|
+
class Auth
|
17
|
+
# => Kontakt Authentication
|
18
|
+
def self.make_request(method, path, options = {}, payload = {})
|
19
|
+
RestClient::Request.execute(method: method.to_sym, url: API_URL + path, payload: payload, headers: options.merge(RESOURCE_DATA))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Venue < Auth
|
24
|
+
# ==========================
|
25
|
+
# => Venues
|
26
|
+
def self.list
|
27
|
+
return JSON.parse(make_request('get', '/venue').body)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Device < Auth
|
32
|
+
# ==========================
|
33
|
+
# => Devices / Beacons
|
34
|
+
def self.list(options = {})
|
35
|
+
# => managerId needs to be a string separated by comma for more then one
|
36
|
+
# managerIds = array | managerIds.join(',') before passing to Device.list
|
37
|
+
return JSON.parse(make_request('get', '/device', {params: options}).body)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.unassigned(managerId)
|
41
|
+
return JSON.parse(make_request('get', '/device/unassigned/' + managerId))
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.assign(venueId, deviceId)
|
45
|
+
return make_request('post', '/device/assign', {}, {:venueId => venueId, :deviceId => deviceId})
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.by_id(id)
|
49
|
+
return JSON.parse(make_request('get', '/device/' + id).body)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.update(id, type, options = {})
|
53
|
+
return make_request('post', '/device/update', {}, {:uniqueId => id, :deviceType => type}.merge(options))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Analytics < Auth
|
58
|
+
# ==========================
|
59
|
+
# => Analytics
|
60
|
+
def self.metrics_ranges(venue_id, startTime, options = {endTime: Time.now.to_i, maxResults: 100})
|
61
|
+
|
62
|
+
request_options = {
|
63
|
+
params: {:sourceType => "VENUE",
|
64
|
+
:sourceId => venue_id,
|
65
|
+
:iso8601Timestamps => "true",
|
66
|
+
:startTimestamp => startTime,
|
67
|
+
:endTimestamp => options[:endTime],
|
68
|
+
:maxResults => options[:maxResults]}
|
69
|
+
}
|
70
|
+
return JSON.parse(make_request('get', '/analytics/metrics/ranges', request_options, {}).body)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kontakt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Greg Winn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: For use with Kontakt.io API
|
14
|
+
email: winn.greg@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/kontakt.rb
|
20
|
+
homepage: http://winn.ws
|
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.8
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Kontakt
|
44
|
+
test_files: []
|