Sha256: 16333b62b7311d4667f2fc32830609c362c82001fb845f02fd9875b60ba8a285
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module Idonethis::UseCases module Teams class << self def apply(credential, args={}) log = args[:log] || fail("You need to supply :log adapter") view = args[:view] || fail("You need to supply :view adapter") list = get(credential, log, args).tap{|result| log.call(result)} view.call list end private def get(credential, log, args) result = [] page = 1 loop do reply = get_page(page, credential, log, args) result += reply["results"] page += 1 break if reply["next"].nil? end result end def get_page(page, credential, log, args) # https://idonethis.com/api/v0.1/teams/ url = Idonethis::Index.teams log.call "url: #{url}" internet = args[:internet] || fail("You need to supply :internet adapter") parse internet.get(url, { "Authorization" => "Token #{credential[:token]}", accept: "application/json"}) end def parse(reply) require 'json' JSON.parse(reply.body) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
idonethis-cli-0.12.0 | lib/idonethis/use_cases/teams.rb |