# Fetch Payment Prerequisites

### Get Academic Prerequisites

#### GraphQL API Documentation

Supabase PostgreSQL GraphQL API documentation for fetching academic prerequisites

#### GraphQL Endpoint <https://api.edupaid.2hourlearning.com/functions/v1/graphql>

#### Authentication

The API requires an API key in the Authorization header and a valid JWT token.

#### Prerequisites Query Example

```graphql
query GetAcademicPrerequisites {
  prerequisites(
    filter: { category: { in: ["CASEItemMastery", "CASEItem2X"] } }
  ) {
    edges {
      node {
        id
        name
        category
        academic_year
        description
        certifier
        reporter
      }
    }
  }
}
```

#### Response Fields

**Prerequisites**

* `academic_year`: The academic year for the prerequisite
* `category`: Type of prerequisite (e.g., CASEItemMastery, CASEItem2X)
* `certifier`: Entity responsible for certification
* `description`: Detailed description of the prerequisite
* `name`: Unique 1EdTech CASEItem ID
* `reporter`: Entity responsible for reporting

#### Usage Notes

* The query supports filtering by category using GraphQL filters
* Results are paginated using the edges/node pattern
* Error handling should be implemented for failed requests
* The API requires proper authentication headers
* All requests must be made over HTTPS

### Get Payment Prerequisites For School

GraphQL API Documentation for fetching payment prerequisites for a school

#### GraphQL Endpoint

`https://api.edupaid.2hourlearning.com/functions/v1/graphql`

#### Authentication

The API requires an API key in the `Authorization` header and a valid JWT token.

#### Prerequisites Query Example

```graphql
query GetPaymentPrerequisitesForSchool($schoolId: String!) {
  schoolLearningBlocks {
    id
    name
    academic_year
    grade
    payout
    state {
      id
      name
      code
    }
    prerequisites {
      prerequisites {
        id
        name

      }
    }
  }
}
```

#### Response Fields

**Learning Block**

* `id`: Unique identifier for the learning block
* `name`: Name of the learning block
* `academic_year`: The academic year for the learning block
* `grade`: Grade level (e.g., K, Grade\_1, Grade\_2, etc.)
* `payout`: Payment amount for the learning block
* `state`: State information
  * `id`: State identifier
  * `name`: State name
  * `code`: State code
* `prerequisites`: Array of prerequisites
  * `prerequisites`: Prerequisite details
    * `id`: Prerequisite identifier
    * `name`: Unique identifier for the prerequisite item
    * `category`: Type of prerequisite (e.g., CASEItem2X, CASEItemMastery)
    * `edu_type`: Education type (e.g., VirtualCharterSchool, ESA, MTSS)
    * `quantity`: Required quantity to fulfill the prerequisite
    * `reporter`: Entity responsible for reporting (e.g., StudyReel, Rep)
    * `state_id`: State identifier the prerequisite applies to
    * `certifier`: Entity responsible for certification (e.g., StudyReel, EduPaid, Rep)
    * `frequency`: Frequency of the prerequisite (SpecificDay, Annually, Monthly, Daily)
    * `created_at`: Timestamp of prerequisite creation
    * `updated_at`: Timestamp of last prerequisite update
    * `description`: Human-readable description of the prerequisite
    * `academic_year`: Academic year the prerequisite applies to
    * `fulfill_level`: Level at which prerequisite must be fulfilled (School or Student)
    * `evidence_description`: Description of required evidence for fulfillment

#### Usage Notes

* The query requires a valid `schoolId` parameter
* Results include learning blocks associated with the specified school
* Each learning block includes its associated prerequisites
* Error handling should be implemented for failed requests
* The API requires proper authentication headers
* All requests must be made over HTTPS

### Get Prerequisites For Student

GraphQL API Documentation for fetching payment prerequisites for a student and a school

#### GraphQL Endpoint

```
https://api.edupaid.2hourlearning.com/functions/v1/graphql
```

#### Authentication

The API requires an API key in the `Authorization` header and a valid JWT token.

#### Prerequisites Query Example

```graphql
query GetPaymentPrerequisitesForStudent($schoolId: String!, $studentId: String!) {
  studentLearningBlocks {
    id
    name
    grade
    payout
    academic_year
    state {
      id
      name
      code
    }
    prerequisite_slots {
      prerequisite {
        id
        name
        description
        fulfill_level
        frequency
      }
      date
      month
      token_date
      token
    }
  }
}
```

#### Response Fields

* `studentLearningBlocks`: Array of learning blocks associated with the student
  * `id`: Unique identifier for the learning block
  * `name`: Name of the learning block
  * `grade`: Grade level (e.g., Grade\_4)
  * `payout`: Payment amount for the learning block
  * `academic_year`: Academic year for the learning block (e.g., "2024-2025")
  * `state`: State information
    * `id`: State identifier
    * `code`: State code (e.g., "AZ")
    * `name`: State name (e.g., "Arizona")
  * `prerequisite_slots`: Array of prerequisite slots
    * `prerequisite`: Prerequisite information
      * `id`: Unique identifier for the prerequisite
      * `name`: Identifier name for the prerequisite
      * `frequency`: Frequency of validation (e.g., "Annually")
      * `description`: Human-readable description of the prerequisite
      * `fulfill_level`: Level at which prerequisite must be fulfilled (e.g., "Student")
    * `date`: Date of prerequisite completion (nullable)
    * `month`: Month of prerequisite completion (nullable)
    * `token_date`: Date of token issuance (nullable)
    * `token`: Validation token (nullable)

#### Usage Notes

* The query requires `studentId`  and `schoolId` parameters
* Results include prerequisites associated with each learning block that is associated with the specified student and school
* Error handling should be implemented for failed requests
* The API requires proper authentication headers
* All requests must be made over HTTPS
