Skip to content

Commit

Permalink
Dönem türleri endpoint'ini ekle
Browse files Browse the repository at this point in the history
  • Loading branch information
huseyin committed Jul 4, 2020
1 parent 1ef82c0 commit b11ae21
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/yoksis/references_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def placement_types
render json: { data: { general: 'Genel', additional_score: 'Ek Puanlı' } }
end

def term_types
render json: { data: @references.term_types }
end

private

def set_references
Expand Down
9 changes: 9 additions & 0 deletions app/services/lib/services/yoksis/endpoints/references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Services
module Yoksis
class References
WSDL_URL = 'https://servisler.yok.gov.tr/ws/Referanslarv1?WSDL'
TERM_TYPES_ENDPOINT = 'http://servisler.yok.gov.tr/rest/schema/donemTur'

ARGS.each_key do |method|
define_method method do
Expand All @@ -27,6 +28,14 @@ def districts(city_code:)
reference_result :districts
end

def term_types
xpath = %w[schema simpleType restriction enumeration]
parser = Nori.new(delete_namespace_attributes: true, strip_namespaces: true)
response = RestClient.get(TERM_TYPES_ENDPOINT)
collection = parser.parse(response.body).dig(*xpath)
collection.map { |object| object.values }.flatten
end

private

def reference_has_error?(method)
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
get :student_punishment_types
get :student_studentship_rights
get :student_studentship_statuses
get :term_types
get :unit_instruction_languages
get :unit_instruction_types
get :unit_statuses
Expand Down

0 comments on commit b11ae21

Please sign in to comment.