OSDN Git Service

t#30322:create provider license import func
[pettanr/pettanr.git] / app / controllers / application_controller.rb
index bd48f0f..d802fbf 100644 (file)
@@ -87,6 +87,29 @@ class ApplicationController < ActionController::Base
     end
   end
   
+  def ymd_to_time ymd_str
+    return nil if ymd_str.blank?
+    date = nil
+    begin
+      date = Time.parse(ymd_str[0..3] + '/' + ymd_str[4..5] + '/' + ymd_str[6..7])
+    rescue
+      date = nil
+    end
+    date
+  end
+  
+  def export_url demander_url, token, date
+    u = demander_url + (demander_url[-1] == '/' ? '' : '/')
+    u = URI.join(u, 'licenses_export.json?auth_token=' + token)
+    u = URI.join(u, '&date=' + date) unless date.blank?
+    u.to_s
+  end
+  
+  def export_from_provider url
+    json = RestClient.get url
+    JSON.parse json
+  end
+  
 =begin
   rescue_from ActiveRecord::RecordNotFound, :with => :render_404