Class: ConnpassToCalendar::Api::Connpass::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/connpass_to_calendar/api/connpass/event.rb

Class Method Summary collapse

Class Method Details

.get(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/connpass_to_calendar/api/connpass/event.rb', line 10

def self.get(params)
  begin
    validation params
    params = URI.encode_www_form params
    uri = URI.parse("https://connpass.com/api/v1/event/?#{params}")
    response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) { |http|
      request = Net::HTTP::Get.new uri
      http.request request
    }
    JSON.parse response.body
  rescue ArgumentError => e
    puts e.message
    exit
  rescue IOError => e
    puts e.message
    exit
  rescue Timeout::Error => e
    puts e.message
    exit
  rescue JSON::ParserError => e
    puts e.message
    exit
  rescue => e
    puts e.message
    exit
  end
end