lib/bearcat/api_array.rb in bearcat-0.9.22 vs lib/bearcat/api_array.rb in bearcat-1.0.0
- old
+ new
@@ -131,11 +131,20 @@
end
end
#TODO: This is a quick fix for JSONAPI responses if we need to do this for anything else we need to do this a better way
def self.array_key(response)
- 'conferences' if (response.env[:method] == :get && response.env[:url].path.match(/.*\/(courses||groups)\/\d+\/conferences/))
+ key = nil
+ if response.env[:method] == :get
+ path = response.env[:url].path
+ if path.match(/.*\/(courses||groups)\/\d+\/conferences/)
+ key = 'conferences'
+ elsif path.match(/.*\/accounts\/d+\/terms/)
+ key = 'enrollment_terms'
+ end
+ end
+ key
end
def process_body(response)
if response.body.is_a?(Array)
response.body
@@ -143,6 +152,6 @@
response.body[@array_key]
end
end
end
-end
\ No newline at end of file
+end