Skip to content

Implement 10 new API endpoint methods for individual item retrieval#6

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-5
Draft

Implement 10 new API endpoint methods for individual item retrieval#6
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-5

Conversation

Copilot AI commented Jul 25, 2025

Copy link
Copy Markdown
Contributor

This PR implements 10 new API endpoint methods that complement the existing collection endpoints by allowing retrieval of specific individual items, following the same pattern established in PR #4.

New Methods Added

Individual item retrieval endpoints:

  • get_activity(semestry, activity_code) - Individual activity by code (GET /activity/{c})
  • get_activitygroup(semestry, activitygroup_code) - Individual activity group by code (GET /activitygroup/{c})
  • get_activitytemplate(semestry, activitytemplate_code) - Individual activity template by code (GET /activitytemplate/{c})
  • get_activitytype(semestry, activitytype_code) - Individual activity type by code (GET /activitytype/{c})
  • get_assessmenttype(semestry, assessmenttype_code) - Individual assessment type by code (GET /assessmenttype/{c})
  • get_building(semestry, building_code, campus_code) - Individual building by building and campus codes (GET /building/{b}/{c})
  • get_campus(semestry, campus_code) - Individual campus by code (GET /campus/{c})
  • get_capability(semestry, capability_code) - Individual capability by code (GET /capability/{c})
  • get_contactrequirement(semestry, contactrequirement_code) - Individual contact requirement by code (GET /contactrequirement/{c})
  • get_course(semestry, course_code) - Individual course by course code (GET /course/{cc})

Implementation Details

All new methods follow the established patterns in the codebase:

  • Complete roxygen2 documentation with proper parameter descriptions
  • Consistent error handling with descriptive error messages
  • Authentication using the same header format (Authorization: k{api_key})
  • 30-second default timeout with configurable parameter
  • JSON response parsing using jsonlite::fromJSON()

Files Modified

  • NAMESPACE: Updated to export all 10 new functions (50 total exports)
  • TODO.md: Marked 10 endpoints as implemented with [x] checkboxes
  • R/: Added 10 new module files following established naming convention

Usage Example

# Authenticate with Semestry
semestry <- authenticate("your_api_key", "https://your-semestry-instance.com")

# Get a specific activity by code
activity <- get_activity(semestry, "MATH101_LEC")

# Get a specific building on a campus
building <- get_building(semestry, "MAIN_HALL", "NORTH_CAMPUS")

# Get course details
course <- get_course(semestry, "CS101")

This significantly expands the package's API coverage by providing granular access to individual items while maintaining full backward compatibility with existing collection endpoints.

Fixes #5.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: tin900 <113692500+tin900@users.noreply.github.com>

@tin900 tin900 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include optional query parameters for the functions. See the documentation. @copilot

Copilot AI changed the title [WIP] Implement 10 new methods Implement 10 new API endpoint methods for individual item retrieval Jul 25, 2025
Copilot AI requested a review from tin900 July 25, 2025 14:30
…ints

Co-authored-by: tin900 <113692500+tin900@users.noreply.github.com>

Copilot AI commented Jul 25, 2025

Copy link
Copy Markdown
Contributor Author

Include optional query parameters for the functions. See the documentation. @copilot

I've added optional query parameters support to all 10 individual item endpoint functions. Each function now accepts a ... parameter that allows passing any query parameters to the API (e.g., fields, format, include, etc.). The implementation follows the same pattern used in existing timetable functions and maintains full backward compatibility.

Usage example:

# With query parameters
activity <- get_activity(semestry, "MATH101_LEC", fields = "code,name", format = "detailed")
building <- get_building(semestry, "MAIN_HALL", "NORTH_CAMPUS", include = "rooms")

Commit: 87c7409

@tin900 tin900 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Not like this. Write functions arguments for the query parameters. So the bames of the params in the args, but default =NULL. See other fucntions in this package how we do that. Check against the api documentation which params

…ll 10 individual item endpoint functions

Co-authored-by: tin900 <113692500+tin900@users.noreply.github.com>

Copilot AI commented Jul 25, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Not like this. Write functions arguments for the query parameters. So the bames of the params in the args, but default =NULL. See other fucntions in this package how we do that. Check against...

I've updated all 10 individual item endpoint functions to use explicit parameter names instead of the generic ... parameter. Each function now has fields = NULL and format = NULL parameters following the same pattern used in existing timetable functions like get_timetable_student().

All function signatures are now:

  • get_activity(semestry, activity_code, fields = NULL, format = NULL, timeout = 30)
  • get_building(semestry, building_code, campus_code, fields = NULL, format = NULL, timeout = 30)
  • etc.

This provides better IDE support and documentation while maintaining full backward compatibility. Commit: cd902a0

Copilot AI requested a review from tin900 July 25, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement 10 new methods

2 participants