@@ -50,14 +50,14 @@ def authenticate_alma_patron?(alma_user_id, alma_password)
5050 def get_user ( alma_user_id )
5151 params = { view : 'full' , expand : 'fees' }
5252 connection . get ( user_uri_for ( alma_user_id ) , params ) . tap do |res |
53- raise ActiveRecord :: RecordNotFound , "Alma query failed with response: #{ res . status } " unless res . status == 200
53+ raise Error :: AlmaRecordNotFoundError , "Alma query failed with response: #{ res . status } " unless res . status == 200
5454 end
5555 end
5656
5757 def save ( alma_user_id , user )
5858 # noinspection RubyArgCount
5959 connection . put ( user_uri_for ( alma_user_id ) , user . to_json , { 'Content-Type' => 'application/json' } ) . tap do |res |
60- raise ActiveRecord :: RecordNotFound , 'Failed to save.' unless res . status == 200
60+ raise Error :: AlmaRecordNotFoundError , 'Failed to save.' unless res . status == 200
6161 end
6262
6363 'Saved user.' # TODO: what is this for?
@@ -85,7 +85,7 @@ def fee_uri_for(alma_id, fee_id)
8585
8686 def fetch_all ( alma_user_id )
8787 res = connection . get ( fees_uri_for ( alma_user_id ) )
88- raise ActiveRecord :: RecordNotFound , 'No fees could be found.' unless res . status == 200
88+ raise Error :: AlmaRecordNotFoundError , 'No fees could be found.' unless res . status == 200
8989
9090 JSON . parse ( res . body )
9191 end
@@ -97,7 +97,7 @@ def credit(alma_user_id, pp_ref_number, fee)
9797 payment_uri = URIs . append ( fee_uri_for ( alma_user_id , fee . id ) , '?' , URI . encode_www_form ( params ) )
9898
9999 connection . post ( payment_uri ) . tap do |res |
100- raise ActiveRecord :: RecordNotFound , "Alma query failed with response: #{ res . status } " unless res . status == 200
100+ raise Error :: AlmaRecordNotFoundError , "Alma query failed with response: #{ res . status } " unless res . status == 200
101101 end
102102 end
103103 end
@@ -119,14 +119,14 @@ def fetch_sets(env, offset = 0)
119119 }
120120
121121 res = connection ( env ) . get ( URIs . append ( alma_api_url , 'conf/sets' ) , params )
122- raise ActiveRecord :: RecordNotFound , 'No item sets could be found..' unless res . status == 200
122+ raise Error :: AlmaRecordNotFoundError , 'No item sets could be found..' unless res . status == 200
123123
124124 JSON . parse ( res . body )
125125 end
126126
127127 def fetch_set ( env , id )
128128 res = connection ( env ) . get ( URIs . append ( alma_api_url , "conf/sets/#{ id } " ) )
129- raise ActiveRecord :: RecordNotFound , "No set with ID #{ id } found..." unless res . status == 200
129+ raise Error :: AlmaRecordNotFoundError , "No set with ID #{ id } found..." unless res . status == 200
130130
131131 JSON . parse ( res . body )
132132 end
@@ -137,15 +137,15 @@ def fetch_members(set_id, env, offset = 0)
137137 limit : 100
138138 }
139139 res = connection ( env ) . get ( URIs . append ( alma_api_url , "conf/sets/#{ set_id } /members" ) , params )
140- raise ActiveRecord :: RecordNotFound , 'No item sets could be found.' unless res . status == 200
140+ raise Error :: AlmaRecordNotFoundError , 'No item sets could be found.' unless res . status == 200
141141
142142 JSON . parse ( res . body )
143143 end
144144
145145 def fetch_item ( env , mms_id , holding_id , item_pid )
146146 uri = URIs . append ( alma_api_url , "bibs/#{ mms_id } /holdings/#{ holding_id } /items/#{ item_pid } " )
147147 res = connection ( env ) . get ( uri )
148- raise ActiveRecord :: RecordNotFound , 'Item could be found.' unless res . status == 200
148+ raise Error :: AlmaRecordNotFoundError , 'Item could be found.' unless res . status == 200
149149
150150 JSON . parse ( res . body )
151151 end
0 commit comments