Sha256: 6d61f04db49440ae329100756977a86e8d71cb1181c08b456dc9e66a22bc21e5
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true module PlatformSdk module PowerSchool # Powerschool::Client class Client attr_reader :bearer_token, :conn def initialize(base_url:, bearer_token: nil, expansions: nil) @bearer_token = bearer_token @bearer_token ||= PlatformSdk::PowerSchool.bearer_token @expansions = expansions || self.class.expansions @conn = Faraday.new(base_url, headers:) do |conn| conn.response :raise_error conn.request :json conn.response :json conn.adapter :net_http end end def headers { "Authorization" => "Bearer #{@bearer_token}", "Content-Type" => "application/json", "Accept" => "application/json" } end def power_query(query_name) scrub_query(query_name) @conn.post("/ws/schema/query/com.strongmind.#{query_name}?pagesize=0").body["record"] end def special_programs records_as_json = power_query("specialprograms") records_as_json.map { |record| SpecialProgram.new(record) } end def self.expansions { STUDENTS: %w[demographics addresses alerts phones school_enrollment ethnicity_race contact contact_info initial_enrollment schedule_setup fees lunch], SECTIONS: %w[term], TEACHERS: %w[addresses emails phones school_affiliations] } end def valid_power_query_names %w[specialprograms edkey.attendance_get_daily_total_minutes] end def scrub_query(query_name) raise PowerQueryNotValid unless valid_power_query_names.include?(query_name) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
strongmind-platform-sdk-2.16.1 | lib/platform_sdk/power_school/client.rb |