Sha256: 8069d1bc31c69193a59ad59194f554ca03517aaf1fa812735f346858e1f30a33

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 Bytes

Contents

# frozen_string_literal: true

module PlatformSdk
  module Edfi
    # IdMapper::Client
    class Client
      attr_reader :token, :domain, :conn

      def initialize(base_url, auth_client)
        @base_url ||= base_url
        @auth_client = auth_client

        @conn = Faraday.new(@base_url) do |faraday|
          faraday.headers = headers
          faraday.adapter Faraday.default_adapter
          faraday.response :json, content_type: /\bjson$/
          faraday.response :raise_error
        end
      end

      def get_student_programs(uid)
        response = @conn.get("/ed-fi/v5.1.0/api/data/v3/ed-fi/studentProgramAssociations?studentUniqueId=#{uid}")
        response.body
      end

      private

      def headers
        {
          "Authorization" => "Bearer #{@auth_client.auth_token}",
          "Content-Type" => "application/json",
          "Accept" => "application/json"
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
strongmind-platform-sdk-3.7.0 lib/platform_sdk/edfi/client.rb