Wolves API #20

Closed
opened 2023-09-05 17:16:04 +00:00 by silver · 17 comments
silver commented 2023-09-05 17:16:04 +00:00 (Migrated from gitlab.skynet.ie)

Working with Keith to get an api for wolves to reduce teh need for csv exports/manual authing.

Working with Keith to get an api for wolves to reduce teh need for csv exports/manual authing.
silver commented 2023-09-05 17:16:04 +00:00 (Migrated from gitlab.skynet.ie)

assigned to @silver

assigned to @silver
silver commented 2023-09-05 17:18:47 +00:00 (Migrated from gitlab.skynet.ie)

https://discord.com/channels/689189992417067052/1114882414670516294/1135912373287391303

A general request for all members in a group.

[
  {
    "id_wolves":"wolves id, not MemID as that changes yearly",
    "id_student":"Student id (if teh account has one, can be used to verify almnui once graduated)",
    "email":"email address on wolves (locally we dont recognise this if its a skynet email)",
    "name_first":"First Name",
    "name_second":"Second Name",
    "expiry":"Expiry date of account",
  }
]

May also need to do a request based on groupa dn email (for discord bot maybe?)

Will update after my chat with Keith tomorrow

https://discord.com/channels/689189992417067052/1114882414670516294/1135912373287391303 A general request for all members in a group. ```json [ { "id_wolves":"wolves id, not MemID as that changes yearly", "id_student":"Student id (if teh account has one, can be used to verify almnui once graduated)", "email":"email address on wolves (locally we dont recognise this if its a skynet email)", "name_first":"First Name", "name_second":"Second Name", "expiry":"Expiry date of account", } ] ``` May also need to do a request based on groupa dn email (for discord bot maybe?) Will update after my chat with Keith tomorrow
evanc commented 2023-09-05 18:02:17 +00:00 (Migrated from gitlab.skynet.ie)

If they don't accept that. Just ask for the most basic.

Just a search API based on wolves ID / memID / or email.
Search by Email for initial signups.
image

Search by WolvesID / MemID after getting it from wolves during account creation if a user changes email on wolves/skynet and for following years while a student.

Student ID is not on any alumni accounts so that's useless at linking an alumni. And an alumni account is a new account cause most people sign up using their UL email which expires and can't be signed into after graduating so the wolvesID/memID won't work. But you can use the new account recovery thing for new alumni accounts, and have it linked to the account SSH key so they can set an email and use that to check with wolves then.
image
image

For data returned, you can take all of that data sure. but on a per user basis.

Also I see this box for preferred name on the form, if you can get it from the API and use that instead of the account name for people that would prefer that on sign up.
image

If they don't accept that. Just ask for the most basic. Just a search API based on wolves ID / memID / or email. Search by Email for initial signups. ![image](/uploads/8340342a57684de78ba9d67acb481de9/image.png) Search by WolvesID / MemID after getting it from wolves during account creation if a user changes email on wolves/skynet and for following years while a student. Student ID is not on any alumni accounts so that's useless at linking an alumni. And an alumni account is a new account cause most people sign up using their UL email which expires and can't be signed into after graduating so the wolvesID/memID won't work. But you can use the new account recovery thing for new alumni accounts, and have it linked to the account SSH key so they can set an email and use that to check with wolves then. ![image](/uploads/dd9890cda08e550c55c15c0c0248ffd5/image.png) ![image](/uploads/063ceb13ffd142416e74184939bddeed/image.png) For data returned, you can take all of that data sure. but on a per user basis. Also I see this box for preferred name on the form, if you can get it from the API and use that instead of the account name for people that would prefer that on sign up. ![image](/uploads/14feb5d27d53de0225a54526178fb754/image.png)
silver commented 2023-09-10 20:54:52 +00:00 (Migrated from gitlab.skynet.ie)

made the issue visible to everyone

made the issue visible to everyone
silver commented 2023-09-10 20:55:31 +00:00 (Migrated from gitlab.skynet.ie)

marked this issue as related to compsoc1/skynet/discord-bot#3

marked this issue as related to compsoc1/skynet/discord-bot#3
silver commented 2023-10-06 10:56:33 +00:00 (Migrated from gitlab.skynet.ie)

mentioned in issue compsoc1/compsoc/internal/plans#33

mentioned in issue compsoc1/compsoc/internal/plans#33
silver commented 2023-10-06 11:05:25 +00:00 (Migrated from gitlab.skynet.ie)

marked this issue as related to compsoc1/compsoc/internal/plans#17

marked this issue as related to compsoc1/compsoc/internal/plans#17
silver commented 2023-10-06 13:39:31 +00:00 (Migrated from gitlab.skynet.ie)

marked this issue as related to compsoc1/skynet/discord-bot#5

marked this issue as related to compsoc1/skynet/discord-bot#5
silver commented 2023-10-26 19:35:05 +00:00 (Migrated from gitlab.skynet.ie)

Kieth implmented the API, currently only accessable on 193.1.99.112 as that was the server it was initially tested on.
I'll be able to get started working on it this evening.

<?php

$url = 'https://cp.ulwolves.ie/api/';

$method = 'get_members';

$headers = [
    'X-AM-Identity: api key' // 
];

$curl = curl_init();

curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, $url.$method);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($curl);

curl_close($curl);

if ($result == false) 
	exit('Invalid API Response');

$result_obj = json_decode($result);

if (!isset($result_obj->success))
	exit($result_obj->error);

print '<table>';

print '<tr>';
foreach($result_obj->result[0] as $k=>$v)
	print '<th>'.$k.'</th>';
print '</tr>';

foreach($result_obj->result as $row) {
	print '<tr>';
	foreach($row as $k=>$i)
		print '<td>'.$i.'</td>';
	print '</tr>';
}

print '</table>';

{
  "success": 1,
  "result": [
    {
      "committee": "Computer",
      "wolves_id": "00000",
      "first_name": "First",
      "last_name": "Name",
      "email": "email@example.com",
      "student_id": "00000000",
      "note": null,
      "expiry": "2024-08-31",
      "requested": "2023-08-24 09:18:09",
      "approved": "2023-09-03 19:09:35",
      "sitename": "UL Wolves",
      "domain": "ulwolves.ie"
    },
    {
      "committee": "Computer",
      "wolves_id": "00000",
      "first_name": "First",
      "last_name": "Name",
      "email": "email@example.com",
      "student_id": null,
      "note": null,
      "expiry": "2024-08-31",
      "requested": "2023-08-24 09:18:09",
      "approved": "2023-09-03 19:09:35",
      "sitename": "UL Wolves",
      "domain": "ulwolves.ie"
    }
  ]
}

Kieth implmented the API, currently only accessable on ``193.1.99.112`` as that was the server it was initially tested on. I'll be able to get started working on it this evening. ```php <?php $url = 'https://cp.ulwolves.ie/api/'; $method = 'get_members'; $headers = [ 'X-AM-Identity: api key' // ]; $curl = curl_init(); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_URL, $url.$method); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($curl); curl_close($curl); if ($result == false) exit('Invalid API Response'); $result_obj = json_decode($result); if (!isset($result_obj->success)) exit($result_obj->error); print '<table>'; print '<tr>'; foreach($result_obj->result[0] as $k=>$v) print '<th>'.$k.'</th>'; print '</tr>'; foreach($result_obj->result as $row) { print '<tr>'; foreach($row as $k=>$i) print '<td>'.$i.'</td>'; print '</tr>'; } print '</table>'; ``` ```jaon { "success": 1, "result": [ { "committee": "Computer", "wolves_id": "00000", "first_name": "First", "last_name": "Name", "email": "email@example.com", "student_id": "00000000", "note": null, "expiry": "2024-08-31", "requested": "2023-08-24 09:18:09", "approved": "2023-09-03 19:09:35", "sitename": "UL Wolves", "domain": "ulwolves.ie" }, { "committee": "Computer", "wolves_id": "00000", "first_name": "First", "last_name": "Name", "email": "email@example.com", "student_id": null, "note": null, "expiry": "2024-08-31", "requested": "2023-08-24 09:18:09", "approved": "2023-09-03 19:09:35", "sitename": "UL Wolves", "domain": "ulwolves.ie" } ] } ```
silver commented 2023-10-26 22:00:09 +00:00 (Migrated from gitlab.skynet.ie)

mentioned in commit 1e9b49f459

mentioned in commit 1e9b49f4594dd48ac0905ed3ce7a6f0a7602c716
silver commented 2023-10-26 22:01:02 +00:00 (Migrated from gitlab.skynet.ie)

The database will have to be deleted during the migration, which is grand

The database will have to be deleted during the migration, which is grand
silver commented 2023-10-27 01:32:46 +00:00 (Migrated from gitlab.skynet.ie)

mentioned in merge request !18

mentioned in merge request !18
silver commented 2023-10-27 01:43:38 +00:00 (Migrated from gitlab.skynet.ie)

mentioned in commit d634806808

mentioned in commit d634806808d322a42c0c690d6ba484168f9458a9
silver (Migrated from gitlab.skynet.ie) closed this issue 2023-10-27 01:43:39 +00:00
silver (Migrated from gitlab.skynet.ie) closed this issue 2023-10-27 01:43:39 +00:00
silver commented 2023-10-27 10:14:19 +00:00 (Migrated from gitlab.skynet.ie)

193.1.99.74 got whitelisted.

The api structure got changed to this:
email => contact_email
opt_in_email got added

{
  "success": 1,
  "result": [
    {
      "committee": "Computer",
      "wolves_id": "00000",
      "first_name": "First",
      "last_name": "Name",
      "contact_email": "email@example.com",
      "opt_in_email": "1",
      "student_id": "00000000",
      "note": null,
      "expiry": "2024-08-31",
      "requested": "2023-08-24 09:18:09",
      "approved": "2023-09-03 19:09:35",
      "sitename": "UL Wolves",
      "domain": "ulwolves.ie"
    },
    {
      "committee": "Computer",
      "wolves_id": "00000",
      "first_name": "First",
      "last_name": "Name",
      "contact_email": "email@example.com",
      "opt_in_email": "0",
      "student_id": null,
      "note": null,
      "expiry": "2024-08-31",
      "requested": "2023-08-24 09:18:09",
      "approved": "2023-09-03 19:09:35",
      "sitename": "UL Wolves",
      "domain": "ulwolves.ie"
    }
  ]
}
``193.1.99.74`` got whitelisted. The api structure got changed to this: ``email`` => ``contact_email`` ``opt_in_email`` got added ```json { "success": 1, "result": [ { "committee": "Computer", "wolves_id": "00000", "first_name": "First", "last_name": "Name", "contact_email": "email@example.com", "opt_in_email": "1", "student_id": "00000000", "note": null, "expiry": "2024-08-31", "requested": "2023-08-24 09:18:09", "approved": "2023-09-03 19:09:35", "sitename": "UL Wolves", "domain": "ulwolves.ie" }, { "committee": "Computer", "wolves_id": "00000", "first_name": "First", "last_name": "Name", "contact_email": "email@example.com", "opt_in_email": "0", "student_id": null, "note": null, "expiry": "2024-08-31", "requested": "2023-08-24 09:18:09", "approved": "2023-09-03 19:09:35", "sitename": "UL Wolves", "domain": "ulwolves.ie" } ] } ```
silver commented 2023-10-27 10:17:30 +00:00 (Migrated from gitlab.skynet.ie)

mentioned in commit ee88cbeb55

mentioned in commit ee88cbeb55ea9603323a4a4d4d9b18b9af4e2462
silver commented 2023-10-27 10:36:44 +00:00 (Migrated from gitlab.skynet.ie)

mentioned in commit b0bc6f35c2

mentioned in commit b0bc6f35c2afd9f545d618a4a092e4efdea25299
silver commented 2023-10-27 10:54:03 +00:00 (Migrated from gitlab.skynet.ie)

mentioned in commit compsoc1/skynet/discord-bot@432dd0e4a0a1697ae9911a90f249b36727828ce5

mentioned in commit compsoc1/skynet/discord-bot@432dd0e4a0a1697ae9911a90f249b36727828ce5
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Skynet/ldap_backend#20
No description provided.