Sha256: 714ea80df7b5513335b3f056fe63c27920963cea8b4c584af1ac52b9a8d25697

Contents?: true

Size: 755 Bytes

Versions: 2

Compression:

Stored size: 755 Bytes

Contents

module Syobocalite
  # API client for https://cal.syoboi.jp/db.php
  # @see https://docs.cal.syoboi.jp/spec/db.php/
  class DbClient
    # Get program's flag
    # @param tid [Integer]
    # @param pid [Integer]
    # @return [Integer]
    # @see https://docs.cal.syoboi.jp/spec/proginfo-flag/
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
syobocalite-1.1.1 lib/syobocalite/db_client.rb
syobocalite-1.1.0 lib/syobocalite/db_client.rb