aladtec 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +20 -1
- data/lib/aladtec/authentication.rb +17 -0
- data/lib/aladtec/client.rb +15 -4
- data/lib/aladtec/configuration.rb +1 -3
- data/lib/aladtec/version.rb +1 -1
- data/spec/aladtec/client_spec.rb +0 -1
- data/spec/aladtec/range_denormalizer_spec.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4559364e023c7c4a781ecc7463901b10256bf125
|
4
|
+
data.tar.gz: fee96a2725c63d0b50b0251442e7be614e1b1791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7487b455740cf72952d88ac0da3998d5523e36caf86a9d5fd0dbc212ae6f6215ea1007d29c1d19fac8efb74611a53fa93780308117c05527411b064a628aa89
|
7
|
+
data.tar.gz: 2d003cffb72914e92712dbc08990ae19d4a71f55155032aa3602296b4f1f4151cb7485264086596466d0049cd124698187d445a34ff6983c4f89f815ba29e426
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Aladtec
|
2
2
|
[![Build Status](https://travis-ci.org/travisdahlke/aladtec.svg)](https://travis-ci.org/travisdahlke/aladtec)
|
3
|
+
[![Inline docs](http://inch-ci.org/github/travisdahlke/aladtec.svg?branch=master)](http://inch-ci.org/github/travisdahlke/aladtec)
|
3
4
|
|
4
5
|
A Ruby client library for the Aladtec FireManager API.
|
5
6
|
|
@@ -19,7 +20,25 @@ Or install it yourself as:
|
|
19
20
|
|
20
21
|
## Usage
|
21
22
|
|
22
|
-
|
23
|
+
Configure the gem with your credentials:
|
24
|
+
|
25
|
+
Aladtec.configure do |config|
|
26
|
+
config.acc_key = ENV['ALADTEC_ACC_KEY']
|
27
|
+
config.acc_id = ENV['ALADTEC_ACC_ID']
|
28
|
+
config.endpoint = ENV['ALADTEC_ENDPOINT']
|
29
|
+
end
|
30
|
+
|
31
|
+
Get members
|
32
|
+
client = Aladtec::Client.new
|
33
|
+
client.members
|
34
|
+
|
35
|
+
Get events
|
36
|
+
client.events(begin_date: Date.today)
|
37
|
+
|
38
|
+
Get schedules
|
39
|
+
client.schedules
|
40
|
+
|
41
|
+
Refer to the [documentation](http://www.rubydoc.info/github/travisdahlke/aladtec) for more detailed usage.
|
23
42
|
|
24
43
|
## Contributing
|
25
44
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
|
3
|
+
module Aladtec
|
4
|
+
class Authentication
|
5
|
+
include HappyMapper
|
6
|
+
|
7
|
+
tag 'authentication'
|
8
|
+
attribute :code, Integer
|
9
|
+
attribute :retry, Integer
|
10
|
+
element :message, String
|
11
|
+
has_one :member, Member
|
12
|
+
|
13
|
+
def success?
|
14
|
+
self.code == 0
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/aladtec/client.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require 'kconv'
|
1
2
|
require 'rest-client'
|
2
3
|
require 'aladtec/event'
|
3
4
|
require 'aladtec/member'
|
5
|
+
require 'aladtec/authentication'
|
4
6
|
require 'aladtec/range'
|
5
7
|
require 'aladtec/schedule'
|
6
8
|
require 'aladtec/range_denormalizer'
|
@@ -32,15 +34,24 @@ module Aladtec
|
|
32
34
|
end
|
33
35
|
response = request(:getEvents, bd: bd, ed: ed)
|
34
36
|
Event.parse(response.body)
|
37
|
+
rescue LibXML::XML::Error
|
38
|
+
Event.parse(Kconv.toutf8(response.body))
|
35
39
|
end
|
36
40
|
|
37
41
|
# Public: Get a list of members
|
38
42
|
#
|
39
43
|
def members
|
40
|
-
response = request(:getMembers)
|
44
|
+
response = request(:getMembers, ia: 'all')
|
41
45
|
Member.parse(response.body)
|
42
46
|
end
|
43
47
|
|
48
|
+
# Public: Authenticate member
|
49
|
+
#
|
50
|
+
def auth(username, password)
|
51
|
+
response = request(:authenticateMember, memun: username, mempw: password)
|
52
|
+
Authentication.parse(response.body)
|
53
|
+
end
|
54
|
+
|
44
55
|
# Public: Get a list of schedules
|
45
56
|
#
|
46
57
|
def schedules
|
@@ -62,8 +73,8 @@ module Aladtec
|
|
62
73
|
def scheduled_range(options = {})
|
63
74
|
bt = options.fetch(:begin_time) { raise "You must supply a :begin_time!"}
|
64
75
|
et = options.fetch(:end_time) { raise "You must supply an :end_time!"}
|
65
|
-
bt = bt.is_a?(Time) ? bt.utc.iso8601 : Time.parse(bt).utc.iso8601
|
66
|
-
et = et.is_a?(Time) ? et.utc.iso8601 : Time.parse(et).utc.iso8601
|
76
|
+
bt = bt.is_a?(Time) ? bt.clone.utc.iso8601 : Time.parse(bt).utc.iso8601
|
77
|
+
et = et.is_a?(Time) ? et.clone.utc.iso8601 : Time.parse(et).utc.iso8601
|
67
78
|
response = request(:getScheduledTimeRanges, bt: bt, et: et, isp: 1)
|
68
79
|
denormalize_ranges(Range.parse(response.body))
|
69
80
|
end
|
@@ -73,7 +84,7 @@ module Aladtec
|
|
73
84
|
end
|
74
85
|
|
75
86
|
def auth_params
|
76
|
-
{accid: acc_id, acckey: acc_key
|
87
|
+
{accid: acc_id, acckey: acc_key}
|
77
88
|
end
|
78
89
|
private :auth_params
|
79
90
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Aladtec
|
2
2
|
module Configuration
|
3
3
|
VALID_CONNECTION_KEYS = [:endpoint, :method, :user_agent].freeze
|
4
|
-
VALID_OPTIONS_KEYS = [:acc_id, :acc_key
|
4
|
+
VALID_OPTIONS_KEYS = [:acc_id, :acc_key].freeze
|
5
5
|
VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
|
6
6
|
|
7
7
|
DEFAULT_ENDPOINT = 'https://secure.emsmanager.net/api/index.php'
|
@@ -10,7 +10,6 @@ module Aladtec
|
|
10
10
|
|
11
11
|
DEFAULT_ACC_ID = nil
|
12
12
|
DEFAULT_ACC_KEY = nil
|
13
|
-
DEFAULT_CUS_ID = nil
|
14
13
|
|
15
14
|
attr_accessor *VALID_CONFIG_KEYS
|
16
15
|
|
@@ -25,7 +24,6 @@ module Aladtec
|
|
25
24
|
|
26
25
|
self.acc_id = DEFAULT_ACC_ID
|
27
26
|
self.acc_key = DEFAULT_ACC_KEY
|
28
|
-
self.cus_id = DEFAULT_CUS_ID
|
29
27
|
end
|
30
28
|
|
31
29
|
def configure
|
data/lib/aladtec/version.rb
CHANGED
data/spec/aladtec/client_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aladtec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Dahlke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- Rakefile
|
125
125
|
- aladtec.gemspec
|
126
126
|
- lib/aladtec.rb
|
127
|
+
- lib/aladtec/authentication.rb
|
127
128
|
- lib/aladtec/client.rb
|
128
129
|
- lib/aladtec/configuration.rb
|
129
130
|
- lib/aladtec/event.rb
|
@@ -163,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
164
|
version: '0'
|
164
165
|
requirements: []
|
165
166
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.4.5.1
|
167
168
|
signing_key:
|
168
169
|
specification_version: 4
|
169
170
|
summary: Client library for the Aladtec API
|