Class: Syobocalite::DbClient

Inherits:
Object
  • Object
show all
Defined in:
lib/syobocalite/db_client.rb

Overview

API client for cal.syoboi.jp/db.php

Instance Method Summary collapse

Instance Method Details

#get_program_flag(tid:, pid:) ⇒ Integer

Get program’s flag

Parameters:

  • tid (Integer)
  • pid (Integer)

Returns:

  • (Integer)

See Also:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/syobocalite/db_client.rb', line 10

def get_program_flag(tid:, pid:)
  params = {
    "Command" => "ProgLookup",
    "Fields" => "Flag",
    "TID" => tid,
    "PID" => pid,
  }

  headers = {
    "User-Agent" => Syobocalite.user_agent,
  }

  xml = URI.open("https://cal.syoboi.jp/db.php?#{params.to_param}", headers).read
  response = MultiXml.parse(xml)
  response["ProgLookupResponse"]["ProgItems"]["ProgItem"]["Flag"].to_i
end