Sha256: 645af737e4b13cc8fe9687b7663e60674886706137c5baf36ce37fa321cdc969
Contents?: true
Size: 735 Bytes
Versions: 5
Compression:
Stored size: 735 Bytes
Contents
require "faraday" require "faraday_middleware" module Saber class Book # delegate to #populate def self.populate(*args) new.populate(*args) end attr_reader :client def initialize @client = Faraday.new(url: Rc.api_url) {|c| c.response :follow_redirects c.response :json, :content_type => /\bjson$/ c.adapter Faraday.default_adapter } end # @return [Hash] data def populate(isbn, filename) params = {} rep = client.get("/books/#{isbn}", params) data = rep.body if data["status"] == 0 data["tracker"] else Saber.ui.error "Can't populate book -- #{isbn} #{filename}." {} end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
saber-1.2.4 | lib/saber/book.rb |
saber-1.2.3 | lib/saber/book.rb |
saber-1.2.2 | lib/saber/book.rb |
saber-1.2.1 | lib/saber/book.rb |
saber-1.2.0 | lib/saber/book.rb |