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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab8c7d4ff27eab71f8a508a70ea5e82f74930fff
4
- data.tar.gz: 5d35cf5c9e06f9159635bb46c0a28ce3f0cbad2b
3
+ metadata.gz: cb7f4209147627317ba9209cf53be51a4ea3c07d
4
+ data.tar.gz: 5d6d003dca51f2b5957ded2259a0fef1da177200
5
5
  SHA512:
6
- metadata.gz: 782553d02d2cd44b8191df7623e49aef74a2e8abde9962b1b62db495180ce221583373c98b772e2afde401cdcc9067fc45f789d58b8b45a32003243f865b7b45
7
- data.tar.gz: 9a0c7c4ef012d018decb90773bd5d2e194e6f1e5b41295f4f7139ec320559ec0ffd2715900a88bb47a172bb8b32ad985a542aed3ac201dcd996339e0885682b7
6
+ metadata.gz: aec765fba45e010df5908316e600df7223ecb6d4fe52ea57dd11daef3be4b0ff7b78698cd6764ac8dab3e495428abbbf6f15bd81cded4d4c44d2d3231ac28873
7
+ data.tar.gz: e899301aa5c006c69a757e90575908fb087428dd8f0a0e15727fdc274a8e57f10d8b31aa25ca2e84040b4db3f96e870882cb0b8f2a0793eaf1100c59305087a1
@@ -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
@@ -16,4 +16,31 @@ module CPRClient
16
16
 
17
17
  end
18
18
 
19
- end
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
@@ -1,3 +1,3 @@
1
1
  module CPRClient
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpr-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Andersen