plugair_sdk 1.0.1 → 1.0.2
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 +4 -4
- data/README.md +28 -0
- data/lib/plugair_sdk.rb +22 -4
- data/lib/plugair_sdk/version.rb +1 -1
- data/spec/plugair_sdk/plugair_sdk_spec.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60296f40aae188030de76fcd05e71958f8996357
|
4
|
+
data.tar.gz: e4c0aee342ec65fe81bcd16e257c00107d4599a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 489e6f16bbb3230f8715eb19ce329ee09fc5f3e14b8faf20ab3821541b0e4f50584b56fff027021c0c1bca7925555e7157f4eb5c9b3c0dc5c993e43b57ede305
|
7
|
+
data.tar.gz: 23bf8ab87e441cc2106051076d01e0a4b51aedaa42f7dd016ab9f8d6c72e82257308997b2050a88ab8d7307b8fa0509a491f0c9177f92c8ee26ebe8d90cf5886
|
data/README.md
CHANGED
@@ -95,6 +95,34 @@ pa.verify(credential_key, auth_key, auth_data)
|
|
95
95
|
- serialNumber `String` - 9 Bytes serialNumber in Hex
|
96
96
|
- apps `Array` - store correct iOS/Android app info when authResult is PlugAir::AUTH\_RESULT\_OTHER\_APP\_PLUG
|
97
97
|
|
98
|
+
### Exceptions
|
99
|
+
|
100
|
+
#### PlugAirAuthError
|
101
|
+
- status `Integer` - Status code
|
102
|
+
- reason `String` - Error reason
|
103
|
+
- message `String` - Detail error message
|
104
|
+
|
105
|
+
#### PlugAirApiKeyError
|
106
|
+
|
107
|
+
API key error
|
108
|
+
|
109
|
+
#### PlugAirUnknownError
|
110
|
+
|
111
|
+
Unknown error
|
112
|
+
|
113
|
+
|
114
|
+
### Error reasons
|
115
|
+
|
116
|
+
| Reason |
|
117
|
+
|:-----------------------------------------|
|
118
|
+
| SERVER\_API\_KEY\_AUTHENTICATION\_ERROR |
|
119
|
+
| CLIENT_CREDENTIAL\_AUTHENTICATION\_ERROR |
|
120
|
+
| INVALID\_CHALLENGE |
|
121
|
+
| PLUGAIR\_AUTHENTICATION\_ERROR |
|
122
|
+
| PLUGAIR\_NOT\_FOUND |
|
123
|
+
| INTERNAL\_SERVER\_ERROR |
|
124
|
+
|
125
|
+
|
98
126
|
## License
|
99
127
|
Apache 2.0
|
100
128
|
|
data/lib/plugair_sdk.rb
CHANGED
@@ -5,9 +5,27 @@ require 'net/http'
|
|
5
5
|
require 'uri'
|
6
6
|
|
7
7
|
# Errors
|
8
|
-
class PlugAirAuthError < StandardError; end
|
9
8
|
class PlugAirApiKeyError < StandardError; end
|
10
9
|
class PlugAirUnknownError < StandardError; end
|
10
|
+
class PlugAirAuthError < StandardError
|
11
|
+
def initialize(status, reason, message)
|
12
|
+
@status = status
|
13
|
+
@reason = reason
|
14
|
+
@message = message
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"[#{@status}:#{@reason}] #{@message}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def status
|
22
|
+
@status
|
23
|
+
end
|
24
|
+
|
25
|
+
def reason
|
26
|
+
@reason
|
27
|
+
end
|
28
|
+
end
|
11
29
|
|
12
30
|
# PlugAir Class
|
13
31
|
class PlugAir
|
@@ -25,7 +43,7 @@ class PlugAir
|
|
25
43
|
|
26
44
|
AUTH_RESULT_OK = 'OK'
|
27
45
|
AUTH_RESULT_NG = 'NG'
|
28
|
-
AUTH_RESULT_OTHER_APP_PLUG = '
|
46
|
+
AUTH_RESULT_OTHER_APP_PLUG = 'OTHER_APPS_PLUG'
|
29
47
|
|
30
48
|
|
31
49
|
def initialize(api_key=ENV['PLUGAIR_API_KEY'], shared_secret=ENV['PLUGAIR_SHARED_SECRET'])
|
@@ -60,7 +78,7 @@ class PlugAir
|
|
60
78
|
else
|
61
79
|
json = JSON.parse(res.body)
|
62
80
|
if json['status'] and json['reason'] and json['message'] then
|
63
|
-
raise PlugAirAuthError.new(json['message'])
|
81
|
+
raise PlugAirAuthError.new(json['status'], json['reason'], json['message'])
|
64
82
|
else
|
65
83
|
raise PlugAirUnknownError.new
|
66
84
|
end
|
@@ -97,7 +115,7 @@ class PlugAir
|
|
97
115
|
else
|
98
116
|
json = JSON.parse(res.body)
|
99
117
|
if json['status'] and json['reason'] and json['message'] then
|
100
|
-
raise PlugAirAuthError.new(json['message'])
|
118
|
+
raise PlugAirAuthError.new(json['status'], json['reason'], json['message'])
|
101
119
|
else
|
102
120
|
raise PlugAirUnknownError.new
|
103
121
|
end
|
data/lib/plugair_sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plugair_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hideyuki Takei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|