humanmade / humanmade/hm-time

Update endpoint ideas

Open
#1 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
5
Forks
2
PR merge metrics
No merged PRs in 30d

Description

From the readme:

> The JSON API is also an important component so we can use this data elsewhere, and I imagine would have endpoints somethign like:
>
> GET /api/time/now
>
> Returns a list of users with their timezones and working hours
>
> The reason I put "now" is if in the future we were to integrate vacatios etc, this endpoint would just reflect the people who are curently working, where as /api/time may return all the users and data with working schedules etc.

The [Extending the API guide](https://github.com/WP-API/WP-API/blob/master/docs/guides/extending.md) is a good reference here.

Here's what I'd envision it looking more like:
- GET `/timezones`: Gives a list of objects, looking something like this:

``` json
[
{
"author": {
"ID": 1,
...
},
"timezone": "Australia/Brisbane",
"current_time": "2013-06-02T05:28:00+10:00"
},
...
]
```

Where:
- `user`: [User entity](https://github.com/WP-API/WP-API/blob/master/docs/schema.md#author), similar to the `author` attributes on posts.
- `timezone`: Standard timezone identifier
- `current_time`: Current time in the user's local time. (Helpers for this in WP-API core)
- GET `/timezones/`: Same as above, but for singular user. i.e. `/timezones/1`
- PUT `/timezones/`: Change timezone for user. Only allow changing the `timezone` key
- POST `/timezones/`: Create a timezone for a user

That's my cursory thinking, just looking at this quickly. :)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.