Sha256: 17da19f57c87084a87fd5c5b985d08f17fa4816662a46054655df968691a1acc

Contents?: true

Size: 1.05 KB

Versions: 76

Compression:

Stored size: 1.05 KB

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)
        begin
          response = @conn.get("/ed-fi/v5.1.0/api/data/v3/ed-fi/studentProgramAssociations?studentUniqueId=#{uid}")
          response.body
        rescue Faraday::ResourceNotFound => e
          puts "Faraday::ResourceNotFound: #{e}"
          []
        end
      end

      private

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

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
strongmind-platform-sdk-3.19.25 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.24 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.23 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.22 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.21 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.20 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.19 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.18 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.17 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.16 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.15 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.14 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.13 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.12 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.11 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.19.10 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.14.2 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.14.1 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.14.0 lib/platform_sdk/edfi/client.rb
strongmind-platform-sdk-3.13.0 lib/platform_sdk/edfi/client.rb