Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP API support #32

Merged
merged 10 commits into from
Nov 8, 2021
Merged

HTTP API support #32

merged 10 commits into from
Nov 8, 2021

Conversation

princejoogie
Copy link
Contributor

Finished all HTTP APIs for #11 and fixed bug of #31

NEW CHANGES

  1. Positional arguments to Object arguments

opted for object arguments because a lot of the remaining apis have optional params which is weird if done with positional arguments. e.g:

// BEFORE: in createRoom POST route, the parameters map, sourceSpace, and reason are optional
// if you want to leave sourceSpace null, then you would need to add an..
// extra comma to surpass that argument; which is not intuitive
await createRoom(name, map, , reason)

// AFTER: if you want to leave sourceSpace null, then just dont pass it along as an argument
// intuitive and better practice
await createRoom({ name, map, reason });
  1. Re-wrote requester and separated each API route

current function _sendRequest only supports get routes.
created an api which contains individual routes per file.
Sample:
image

EXAMPLES

  • examples for each HTTP route is under src/examples/index.ts. this file can be executed directly without compiling with
  • npx ts-node src/examples/index.ts
  • to be able to run successfully, the API_KEY variable should be changed accordingly as well as SPACE_ID_1 and SPACE_ID_2
  • apikeys can be generated at https://gather.town/apiKeys
  • SPACE_ID_2 is used in setMapSample function.

@princejoogie
Copy link
Contributor Author

I can send screenshots of my manual tests per route if needed 🎇

@princejoogie princejoogie changed the title Dev HTTP POST and GET apis Nov 6, 2021
@warengonzaga
Copy link
Owner

I can send screenshots of my manual tests per route if needed 🎇

I was thinking of jest for testing the API wrapper. We did a similar approach on BMC.JS but it is not successful. For the examples folder basically these are the manual tests?

@warengonzaga warengonzaga added feature Issue/Pull Request Label for New Features fix Pull Request Label for any Fixes p2 in review Issue/Pull Request Label for In Review Status labels Nov 7, 2021
@princejoogie
Copy link
Contributor Author

princejoogie commented Nov 7, 2021

I can send screenshots of my manual tests per route if needed 🎇

I was thinking of jest for testing the API wrapper. We did a similar approach on BMC.JS but it is not successful. For the examples folder basically these are the manual tests?

yes it is sort of a manual test. was gonna ask in discussions if we were going to implement jest, but since you mentioned it, ill try to implement it when im free again

@warengonzaga
Copy link
Owner

I can send screenshots of my manual tests per route if needed 🎇

I was thinking of jest for testing the API wrapper. We did a similar approach on BMC.JS but it is not successful. For the examples folder basically these are the manual tests?

yes it is sort of a manual test. was gonna ask in discussions if we were going to implement jest, but since you mentioned it, ill try to implement it when im free again

I'll create an issue regarding automated testing with Jest. Also adding a discussion related to this.

@warengonzaga
Copy link
Owner

Hi, @princejoogie did you change how we use the API? If yes, then how to use it? I'm concerned about documentation.

@princejoogie
Copy link
Contributor Author

Hi, @princejoogie did you change how we use the API? If yes, then how to use it? I'm concerned about documentation.

the only change i made is mentioned in PR description number 1. from positional arguments to object arguments. yes, this change will need to be redocumented in usage.

Copy link
Owner

@warengonzaga warengonzaga left a comment

Choose a reason for hiding this comment

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

Please review my questions on each line. 👌

.env Outdated Show resolved Hide resolved
dist/index.d.ts Show resolved Hide resolved
src/api/ApiBase.ts Show resolved Hide resolved
src/api/createRoom.ts Outdated Show resolved Hide resolved
src/api/getEmailGuestList.ts Outdated Show resolved Hide resolved
src/api/getMap.ts Outdated Show resolved Hide resolved
src/api/setEmailGuestlist.ts Outdated Show resolved Hide resolved
src/api/setMap.ts Outdated Show resolved Hide resolved
src/examples/index.ts Outdated Show resolved Hide resolved
src/types.ts Show resolved Hide resolved
@warengonzaga
Copy link
Owner

Hi, @princejoogie did you change how we use the API? If yes, then how to use it? I'm concerned about documentation.

the only change i made is mentioned in PR description number 1. from positional arguments to object arguments. yes, this change will need to be redocumented in usage.

This is clear to me, basically, the usage now for the API wrapper is OOP?

@warengonzaga warengonzaga linked an issue Nov 8, 2021 that may be closed by this pull request
@warengonzaga
Copy link
Owner

@princejoogie did you rename the createRoom to createSpace ?

@warengonzaga warengonzaga linked an issue Nov 8, 2021 that may be closed by this pull request
3 tasks
@princejoogie
Copy link
Contributor Author

@princejoogie did you rename the createRoom to createSpace ?

image
image
image

Copy link
Owner

@warengonzaga warengonzaga left a comment

Choose a reason for hiding this comment

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

All good, as the last request, add the documentation for POST. Then I'll merge this.

src/examples/index.ts Outdated Show resolved Hide resolved
dist/index.d.ts Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Owner

@warengonzaga warengonzaga left a comment

Choose a reason for hiding this comment

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

These are now approved! I'm happy to merge this now.

@warengonzaga
Copy link
Owner

@princejoogie next time, use imperative sentences to your commit message. Use add instead of added as an example.

@warengonzaga warengonzaga merged commit 8b3ed38 into warengonzaga:dev Nov 8, 2021
@warengonzaga warengonzaga changed the title HTTP POST and GET apis HTTP API support Nov 8, 2021
@warengonzaga warengonzaga removed in review Issue/Pull Request Label for In Review Status p2 labels Nov 8, 2021
@warengonzaga warengonzaga linked an issue Nov 8, 2021 that may be closed by this pull request
@princejoogie princejoogie mentioned this pull request Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issue/Pull Request Label for New Features fix Pull Request Label for any Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update docs for updated HTTP API support support for Gather HTTP API add POST API request
2 participants