Sha256: 6e3375af074d5d4011b3f4858511b88f7877ef4a256f94743b58e6cc5cdb5b9e

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

module MyAnimeList
  class Manga

    def initialize(options={})
      @myanimelist_username = options[:username]
      @myanimelist_password = options[:password]
    end

    def search(name)
      get_search(name)
    end

    def get_search(name)
      response = RestClient::Request.new(
        method: :get,
        url: "https://myanimelist.net/api/manga/search.xml?q=#{CGI::escape name}",
        user: @myanimelist_username,
        password: @myanimelist_password,
        content_type: :xml ).execute

      parse_xml response
    end

    def parse_xml(response)
      serialize Hash.from_xml response
    end

    def serialize(data)
      result = MyAnimeList::Serializer.new data, 'manga'
      result.fetch
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
myanimelist-0.0.6 lib/myanimelist/manga.rb