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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf23e84f98683bba046f331784f14449fb0b3cc2
4
- data.tar.gz: a40302dee0b22a2d2d0ed211334458aa41d36943
3
+ metadata.gz: 4559364e023c7c4a781ecc7463901b10256bf125
4
+ data.tar.gz: fee96a2725c63d0b50b0251442e7be614e1b1791
5
5
  SHA512:
6
- metadata.gz: a2c3f502b90585531bb740bb334ce87bbf25e871123db10831241faaeac0e2fdc53a7ec5fa24d86539f3dfd70ba0eab0d94dbd053f601880bfca6c0a434b1d97
7
- data.tar.gz: 4e9596d8bd4b181c622714325775caf2e061fbdc41c987a7da07633624c3186940cc5c42afbd2487427f6fdee9c8cf5337cc1a1254579e088c1fa40b7c472c1e
6
+ metadata.gz: d7487b455740cf72952d88ac0da3998d5523e36caf86a9d5fd0dbc212ae6f6215ea1007d29c1d19fac8efb74611a53fa93780308117c05527411b064a628aa89
7
+ data.tar.gz: 2d003cffb72914e92712dbc08990ae19d4a71f55155032aa3602296b4f1f4151cb7485264086596466d0049cd124698187d445a34ff6983c4f89f815ba29e426
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
4
  - 2.1.0
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
- TODO: Write usage instructions here
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
@@ -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, cusid: cus_id}
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, :cus_id].freeze
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
@@ -1,3 +1,3 @@
1
1
  module Aladtec
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -165,7 +165,6 @@ describe Aladtec::Client do
165
165
  {
166
166
  :acc_id => 'ai',
167
167
  :acc_key => 'ak',
168
- :cus_id => 'ci',
169
168
  :endpoint => 'ep',
170
169
  :user_agent => 'ua',
171
170
  :method => 'hm',
@@ -1,4 +1,5 @@
1
1
  require_relative File.join('..','spec_helper')
2
+ require 'ostruct'
2
3
 
3
4
  describe Aladtec::RangeDenormalizer do
4
5
  let(:members) {[OpenStruct.new(id: 1, name: "Joe Schmoe"), OpenStruct.new(id: 2, name: "Ann Perkins")]}
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.1
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: 2014-05-16 00:00:00.000000000 Z
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.2.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