cpr-client 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cpr_client/client.rb +20 -0
- data/lib/cpr_client/errors.rb +28 -1
- data/lib/cpr_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb7f4209147627317ba9209cf53be51a4ea3c07d
|
4
|
+
data.tar.gz: 5d6d003dca51f2b5957ded2259a0fef1da177200
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec765fba45e010df5908316e600df7223ecb6d4fe52ea57dd11daef3be4b0ff7b78698cd6764ac8dab3e495428abbbf6f15bd81cded4d4c44d2d3231ac28873
|
7
|
+
data.tar.gz: e899301aa5c006c69a757e90575908fb087428dd8f0a0e15727fdc274a8e57f10d8b31aa25ca2e84040b4db3f96e870882cb0b8f2a0793eaf1100c59305087a1
|
data/lib/cpr_client/client.rb
CHANGED
@@ -47,6 +47,16 @@ module CPRClient
|
|
47
47
|
code == 900 or raise LoginError, code
|
48
48
|
end
|
49
49
|
|
50
|
+
# Performs change of password.
|
51
|
+
#
|
52
|
+
# @return true
|
53
|
+
# @raise NewPasswordError if password change failed
|
54
|
+
|
55
|
+
def new_password(new_password)
|
56
|
+
code = receipt_code(post(new_password_body(new_password)))
|
57
|
+
code == 900 or raise NewPasswordError, code
|
58
|
+
end
|
59
|
+
|
50
60
|
protected
|
51
61
|
|
52
62
|
# Returns the gctp status code of the given xml_doc.
|
@@ -133,5 +143,15 @@ module CPRClient
|
|
133
143
|
DATA
|
134
144
|
end
|
135
145
|
|
146
|
+
def new_password_body(new_password)
|
147
|
+
<<-DATA
|
148
|
+
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
|
149
|
+
<root xmlns="http://www.cpr.dk">
|
150
|
+
<Gctp v="1.0">
|
151
|
+
<Sik function="newpass" userid="#{@user}" password="#{@pass}" newpass1="#{new_password}"/>
|
152
|
+
</Gctp>
|
153
|
+
</root>
|
154
|
+
DATA
|
155
|
+
end
|
136
156
|
end
|
137
157
|
end
|
data/lib/cpr_client/errors.rb
CHANGED
@@ -16,4 +16,31 @@ module CPRClient
|
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
class NewPasswordError < ClientError
|
20
|
+
|
21
|
+
attr_reader :code
|
22
|
+
|
23
|
+
# Returns a new instance of NewPasswordError.
|
24
|
+
#
|
25
|
+
# @param code new password error code
|
26
|
+
def initialize(code)
|
27
|
+
@code = code
|
28
|
+
super("CPRClient failed to update password [#{code}]")
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# Possible error codes
|
37
|
+
#
|
38
|
+
# 900 Signon successful
|
39
|
+
# 901 Token kendes ikke
|
40
|
+
# 902 Bruger-id er ikke defineret i sikkerhedssystemet
|
41
|
+
# 903 Bruger-id er inaktivt i sikkerhedssystemet
|
42
|
+
# 904 Ugyldig Bruger-id indtastet
|
43
|
+
# 905 Ugyldig kodeord indtastet
|
44
|
+
# 906 Dit kodeord er udløbet
|
45
|
+
# 907 Begge kodeord skal være ens
|
46
|
+
# 908 Det nye kodeord er ikke gyldigt
|
data/lib/cpr_client/version.rb
CHANGED