Module: Median::Aleph::Patron

Included in:
Median::Aleph
Defined in:
lib/median/aleph/patron.rb

Instance Method Summary collapse

Instance Method Details

#change_patron_email(patron_id, email) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/median/aleph/patron.rb', line 4

def change_patron_email(patron_id, email)
  data01 = change_patron_email!(patron_id, email, "01")
  data02 = change_patron_email!(patron_id, email, "02")

  if bor_update_successfull?(data02)
    return true
  else
    return false
  end
end

#change_patron_password(patron_id, current_password, new_password) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/median/aleph/patron.rb', line 16

def change_patron_password(patron_id, current_password, new_password)
  # first (re)authenticate
  if AlephApi.authenticate(patron_id, current_password)
    # after successfull authentication, write the new password
    data = post_url(Median.config.aleph_x_service_base_url,
      op: 'update_bor',
      update_flag: 'Y',
      library: Median.config.aleph_user_library,
      xml_full_req: <<-XML
        <?xml version="1.0"?>
        <p-file-20>
          <patron-record>
            <z303>
              <match-id-type>01</match-id-type>
              <match-id>#{patron_id}</match-id>
              <record-action>X</record-action>
            </z303>
            <z308>
              <record-action>U</record-action>
              <z308-key-type>01</z308-key-type>
              <z308-key-data>#{patron_id}</z308-key-data>
              <z308-verification>#{new_password}</z308-verification>
            </z308>
          </patron-record>
        </p-file-20>
      XML
    )

    if bor_update_successfull?(data)
      return true
    else
      return false
    end
  else
    return false
  end
end