Sha256: c481f4f21a97b618667d37f41ec14ca3760aaf4576075d775c1b026b7498a15d
Contents?: true
Size: 1.56 KB
Versions: 42
Compression:
Stored size: 1.56 KB
Contents
module Bearcat class Client < Footrest::Client module OutcomeImports def import_outcomes(file_path, params={}) params = params.with_indifferent_access params['attachment'] = Faraday::UploadIO.new(file_path, 'text/csv') url = "api/v1/#{outcome_import_context_slug(params)}" url += "group/#{params[:group]}/" if params[:group].present? params.delete(:group) post(url, params) end def outcome_import_status(id, params={}) params = params.with_indifferent_access get("api/v1/#{outcome_import_context_slug(params)}#{id}", params) end def outcome_import_created_group_ids(id, params={}) params = params.with_indifferent_access get("api/v1/#{outcome_import_context_slug(params)}#{id}/created_group_ids", params) end protected def outcome_import_context_slug(params) context_hash = params.select { |k, _| k == "account" || k == "course" } if context_hash.keys.count > 1 raise ArgumentError, "cannot have account and course in params" elsif context_hash.empty? "accounts/self/outcome_imports/" else context_hash_key = context_hash.keys.first case context_hash_key when 'account' params.delete(:account) "accounts/#{context_hash[context_hash_key]}/outcome_imports/" when 'course' params.delete(:course) "courses/#{context_hash[context_hash_key]}/outcome_imports/" end end end end end end
Version data entries
42 entries across 42 versions & 1 rubygems
Version | Path |
---|---|
bearcat-1.4.10 | lib/bearcat/client/outcome_imports.rb |
bearcat-1.4.9 | lib/bearcat/client/outcome_imports.rb |