# API仕様書
## /api/token:POST
### summary
よくわかってないです
### description
### parameters
### responses
## /api/login
### summary
よくわかってないです
### description
### parameters
### responses
## /api/user/{uuid}:GET
### summary
ユーザー情報を取得
### description
uuidからUserオブジェクトを取得し、情報を返す
### parameters
#### uuid
- in: path
- description: 対象ユーザーのuuid
- required: true
### responses
#### 200
正常に取得が完了
```json
{
"username": "山田 太郎",
"email": "yamada@test.email.com",
"picture_url": "https://api.hupass.hu-jagajaga.com/media/images/social_uuid.jpg"
}
```
#### 403
Admin権限がないか、リクエストユーザーが対象ユーザーではない
#### 404
対象のユーザーデータが存在しない
## /api/search-options:GET
### summary
授業検索時の絞り込み要素一覧を返す
### description
複数選択可能か、択一選択かで`type`ラベルが変わる
複数選択のときは`multiple_choice`、択一選択のときは`choice`
### parameters
なし
### responses
#### 200
```json
[
{
"name": "year",
"label": "年度",
"type": "choice",
"choices": [
[
"",
"---------"
],
[
2024,
2024
]
]
},
{
"name": "semester",
"label": "学期",
"type": "multiple_choice",
"choices": [
[
"1学期",
"1学期"
],
[
"2学期",
"2学期"
]
]
},
{
"name": "faculty",
"label": "学部",
"type": "multiple_choice",
"choices": [
[
"全学教育",
"全学教育"
],
[
"医学部",
"医学部"
]
]
},
{
"name": "period",
"label": "時限",
"type": "multiple_choice",
"choices": [
[
"1-1",
"月1"
],
[
"2-1",
"火1"
]
]
}
]
```
## /api/sort-options:GET
### summary
授業検索時の並び替え要素の一覧を返す
### description
デフォルトの選択肢には`default: true`要素がつけられる
### parameters
なし
### responses
```json
[
{
"name": "relevance",
"label": "関連度順",
"default": true
},
{
"name": "-relevance",
"label": "関連度順(逆順)",
"default": false
},
{
"name": "credit",
"label": "単位数",
"default": false
},
{
"name": "gpa",
"label": "GPA",
"default": false
},
{
"name": "pass_rate",
"label": "合格率",
"default": false
},
{
"name": "A_rate",
"label": "A帯率",
"default": false
},
]
```
## /api/classes:GET
### summary
授業一覧を検索
### description
`/api/search-options/`や`/api/sort-options`の選択肢を使い、フィルター、並べかえを行う
また、時間割id(cls_id)を持っていない授業は検索結果から除外している
### parameters
#### year
- in: query
- description: 開講年度
- required: false
#### semester
- in: query
- description: 開講学期
- required: false
#### faculty
- in: query
- description: 開講学部
- required: false
#### period
- in: query
- description: 開講時間割
- required: false
- schema
- type: array
#### keyword
- in: query
- description: 検索キーワード
- required: false
#### order_by
- in: query
- description: 並べ替え順序
- required: false
### responses
#### 200
正常に検索が完了
```json
{
"links": {
"next": "http://api.hupass.hu-jagajaga.com/api/classes/?keyword=&order_by=relevance&page=2&period=2-1&period=4-1&year=2022",
"previous": null,
"pageless": "http://api.hupass.hu-jagajaga.com/api/classes/?keyword=&order_by=relevance&period=2-1&period=4-1&year=2022"
},
"count": 468,
"total_pages": 16,
"current_page": 1,
"results": [
{
"id": 463,
"subject": "思索と言語",
"theme": "ことばを科学する:人間の再発見",
"is_enrolled": false,
"teacher": "奥 聡 (大学院メディア・コミュニケーション研究院)",
"year": 2022,
"semester": "1学期",
"place": "",
"elig_min": 1,
"elig_max": null,
"elig_dep": "基礎1-53組",
"credit": 2.0,
"sort": "全学教育科目(主題別科目)",
"big_code": "GEN_LIB",
"code": 1200,
"cls_id": 503,
"keywords": [
{
"id": 2308,
"cls": 463,
"keyword": "科学とは何か"
},
{
"id": 2309,
"cls": 463,
"keyword": "音韻"
},
{
"id": 2310,
"cls": 463,
"keyword": "子どもの母語獲得"
},
{
"id": 2311,
"cls": 463,
"keyword": "日英語比較"
},
{
"id": 2312,
"cls": 463,
"keyword": "文法"
},
{
"id": 2313,
"cls": 463,
"keyword": "言語"
},
{
"id": 2314,
"cls": 463,
"keyword": "意味"
}
],
"periods": [
{
"period": 1,
"day": 2
}
],
"faculty": "全学教育",
"moodle_id": null,
"grade_info": {
"id": 36742,
"subject": "思索と言語",
"lecture": "ことばを科学する:人間の再発見",
"group": "基礎1-53組",
"teacher": "奥聡",
"year": "2021",
"semester": "1学期",
"faculty": "全学教育",
"numOfStudents": 55,
"gpa": 3.05,
"ap": 6,
"a": 5,
"am": 8,
"bp": 4,
"b": 14,
"bm": 9,
"cp": 1,
"c": 5,
"d": 0,
"dm": 1,
"f": 2,
"created_at": "2022-02-09T15:44:30+09:00"
},
"urls": {
"syllabus": "http://syllabus01.academic.hokudai.ac.jp/Syllabi/Public/Syllabus/SylDetail.aspx?lct_year=2022&lct_cd=000503&langMode=1",
"moodle": null,
"elms": "https://www.elms.hokudai.ac.jp/group/grouppage?idnumber=p22000503"
}
}
]
}
```
## /api/classes/{id}:GET
### summary
特定の授業情報を取得
### description
### parameters
なし
### responses
#### 200
正常にデータを取得
```json
{
"id": 1,
"subject": "一般教育演習(フレッシュマンセミナー)",
"theme": "日本における哲学と宗教",
"is_enrolled": false,
"teacher": "山畑 倫志 (高等教育推進機構)",
"year": 2022,
"semester": "1学期",
"place": "",
"elig_min": 1,
"elig_max": null,
"elig_dep": "基礎1-52組",
"credit": 2.0,
"sort": "全学教育科目(一般教育演習)",
"big_code": "GEN_LIB",
"code": 1000,
"cls_id": 241,
"keywords": [
{
"id": 1,
"cls": 1,
"keyword": "日本の宗教"
},
{
"id": 2,
"cls": 1,
"keyword": "日本哲学"
},
{
"id": 3,
"cls": 1,
"keyword": "グループワーク"
},
{
"id": 4,
"cls": 1,
"keyword": "異文化コミュニケーション"
}
],
"periods": [
{
"period": 3,
"day": 1
}
],
"faculty": "全学教育",
"moodle_id": null,
"grade_info": null,
"urls": {
"syllabus": "http://syllabus01.academic.hokudai.ac.jp/Syllabi/Public/Syllabus/SylDetail.aspx?lct_year=2022&lct_cd=000241&langMode=1",
"moodle": null,
"elms": "https://www.elms.hokudai.ac.jp/group/grouppage?idnumber=p22000241"
}
}
```
#### 404
指定した授業が存在しない
## /api/myclass:GET
### summary
履修授業の一覧を返す
### description
### parameters
### responses
#### 200
#### 403
## /api/myclass:POST
### summary
履修授業の新規登録
### description
リクエストしたユーザーと、指定された授業を履修授業としてDBに登録し、登録された授業を返す
### requestBody
```json
{
"cls_id": 10 # UnivClassのpk (required)
}
```
### responses
## /api/myclass/{classId}:GET
### summary
ログインユーザーの登録時間割を取得
### description
リクエストしたユーザー情報を取得し、classIdとユーザーが一致するEnrolledClassを返す
### requestBody
```json
{
}
```
### responses
#### 200
正常に処理が完了
```json
{
"id": "test"
}
```
#### 400
pkが空
```json
{
"detail": "pk must not be empty."
}
```
#### 304
存在しないインスタンスを指定した
```json
{
"detail": "instance did not found."
}
```
## /api/myclass:PATCH
### summary
ログインユーザーの登録時間割を一部更新
### description
リクエストしたユーザー情報を取得し、classIdとユーザーが一致するEnrolledClassの内容を変更する
### requestbody
```json
{
"cls_id": 10, # UnivClassのpk (required)
"memo": "メモ", # メモ
"color": "#000000",
"c_subject": "数学",
"c_theme": "テストテーマ",
"c_moodle_id": 12345,
"c_teacher": "テスト先生",
"c_place": "テスト教室",
"c_periods": [
{
"day": 1,
"period": 1,
},
{
"day": 2,
"period": 2,
},
],
}
```
### responses
#### 200
#### 400
#### 304
## /api/general:POST
### summary
必修の授業を返却する
### description
基礎クラス等の情報をもとに必修科目をすべて返す
### requestbody
```json
{
"year": 2023, # 年度 (required)
"department": 2, # 理系: 2, 文系: 1 (required)
"base_class": 60, # 基礎クラス (required)
"second_language": "de", # de, ch, kr, fr, ru, esから1つ指定 (required)
"second_language_subclass": 1, # 理系ドイツ語用 1,2,3 -> A, B, C
"second_language_class": 3, # 二外クラス (required)
"eng1_class": 60, # 英語Ⅰクラス (required)
"eng2_class": 60, # 英語Ⅱクラス (required)
"student_id_last2": 15, # 学生番号下2桁 (required)
"science_exp_class": ["ph", "ch"] # ph, ch, bi, geから2つ指定
}
```
### responses
#### 200
正常に処理が終了
```json
{
"riberal_arts": {
"freshman_seminar": [
6378,
6379
],
"general_subjects": {
"environment_and_people": [
6757,
6758
],
"health_and_society": [
6760,
6761
],
"people_and_culture": [
6762,
6763
],
"special_lecture": [
7517,
7518
],
},
"subject_specific": {
"thoughts_and_languages": thoughts_and_languages,
"historical_perspectives": historical_perspectives,
"arts_and_literature": arts_and_literature,
"perceptions_of_society": perceptions_of_society,
"the_world_of_science_and_technology": the_world_of_science_and_technology,
},
"foreign_languages": {
"english_I": english_I,
"english_II": english_II,
"second_I": second_I,
"second_II": second_II,
},
"foreign_language_seminar": {
"english_skill_focused_seminar": english_skill_focused_seminar,
"english_seminar": english_seminar,
"second_language_seminar": second_language_seminar,
},
"common_subjects": {
"physical_education_A": physical_education_A,
"physical_education_B": physical_education_B,
"introduction_to_informatics_I": introduction_to_informatics_I,
"introduction_to_informatics_II": introduction_to_informatics_II,
"statistics": statistics,
},
},
"fundamental_courses": {
"humanities": {"basics_of_humanities_and_social_sciences": basics_of_humanities_and_social_sciences},
"mathematics": {
"linear_algebra_I": linear_algebra_I,
"linear_algebra_II": linear_algebra_II,
"calculus_I": calculus_I,
"calculus_II": calculus_II,
},
"science": {
"physics_I": physics_I,
"physics_II": physics_II,
"chemistry_I": chemistry_I,
"chemistry_II": chemistry_II,
"biology_I": biology_I,
"biology_II": biology_II,
"basic_earth_and_planetary_science_I": basic_earth_and_planetary_science_I,
"basic_earth_and_planetary_science_II": basic_earth_and_planetary_science_II,
},
"experiment": {
"experiments_of_psychology": experiments_of_psychology,
"laboratory_exercise_in_natural_sciences": laboratory_exercise_in_natural_sciences,
},
},
}
```