]> git.mxchange.org Git - friendica.git/commitdiff
Normalize start_time and end_time parameter names in Friendica API event endpoints
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 24 Jul 2022 09:49:18 +0000 (05:49 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 14 Aug 2022 03:28:20 +0000 (23:28 -0400)
doc/API-Entities.md
doc/API-Friendica.md
src/Module/Api/Friendica/Events/Create.php
src/Module/Api/Friendica/Events/Index.php

index bd84cb70765ba3d4322de6e8556ff7c3bc4489b3..23fc2cec48b3dc9a11bb8e20433e4f0501a793d1 100644 (file)
@@ -410,13 +410,13 @@ Ex: Wed May 23 06:01:13 +0000 2007
 </tr>
 
 <tr>
-<td><code>startTime</code></td>
+<td><code>start_time</code></td>
 <td>String (UTC <code>YYYY-MM-DD HH:II:SS)</code>)</td>
 <td></td>
 </tr>
 
 <tr>
-<td><code>endTime</code></td>
+<td><code>end_time</code></td>
 <td>String (UTC <code>YYYY-MM-DD HH:II:SS)</code>)</td>
 <td>Optional (null date is <code>0001-01-01 00:00:00</code></td>
 </tr>
index a80884baeb45752d3c56bc5c78f9aee9c635c2d6..8460fd4ab6a9f2a80aed4414b2e34d3dbbf793ad 100644 (file)
@@ -32,11 +32,15 @@ Create a new event for the current logged in user.
 
 - `id` : (optional) id of event, event will be amended if supplied
 - `name` : name of the event (required)
-- `startTime` : start of the event (ISO), required
-- `endTime` : (optional) end of the event, event is open end, if not supplied
+- `start_time` : start of the event (ISO), required
+- `end_time` : (optional) end of the event, event is open end, if not supplied
 - `desc` : (optional) description of the event
 - `place` : (optional) location of the event
 - `publish` : (optional) create message for event
+- `allow_cid` : (optional) ACL-formatted list of allowed contact ids if private event
+- `allow_gid` : (optional) ACL-formatted list of disallowed contact ids if private event
+- `deny_cid` : (optional) ACL-formatted list of allowed group ids if private event
+- `deny_gid` : (optional) ACL-formatted list of disallowed group ids if private event
 
 ### POST api/friendica/event_delete
 
index 8a1ebbbf4a9c20c73a9275af31864a948d69c822..eb45b4974c5707bad56a0fe81e7159ae673d2fed 100644 (file)
@@ -45,17 +45,17 @@ class Create extends BaseApi
 
                // params
                $request = $this->getRequest([
-                       'id'        => 0, //if provided, event will be amended
-                       'name'      => '', //summary of the event
-                       'desc'      => '', //description in BBCode
-                       'startTime' => '', //starttime, required
-                       'endTime'   => '', //endtime, required if nofinish false
-                       'place'     => '', //location of the event
-                       'publish'   => 0,  //publish message
-                       'allow_cid' => '', //array of allowed person, if access restricted
-                       'allow_gid' => '', //array of allowed groups, if access restricted
-                       'deny_cid'  => '', //array of denied person, if access restricted
-                       'deny_gid'  => '', //array of denied groups, if access restricted
+                       'id'         => 0, //if provided, event will be amended
+                       'name'       => '', //summary of the event
+                       'desc'       => '', //description in BBCode
+                       'start_time' => '', //start_time, required
+                       'end_time'   => '', //endtime, required if nofinish false
+                       'place'      => '', //location of the event
+                       'publish'    => 0,  //publish message
+                       'allow_cid'  => '', //array of allowed person, if access restricted
+                       'allow_gid'  => '', //array of allowed groups, if access restricted
+                       'deny_cid'   => '', //array of denied person, if access restricted
+                       'deny_gid'   => '', //array of denied groups, if access restricted
                ], $request);
 
                // error if no name specified
@@ -64,33 +64,33 @@ class Create extends BaseApi
                }
 
                // error startDate is not specified
-               if (empty($request['startTime'])) {
+               if (empty($request['start_time'])) {
                        throw new HTTPException\BadRequestException('startDate not specified');
                }
 
-               // nofinish if endTime is not specified
-               if (empty($request['endTime'])) {
+               // nofinish if end_time is not specified
+               if (empty($request['end_time'])) {
                        $finish   = DBA::NULL_DATETIME;
                        $nofinish = true;
                } else {
-                       $finish   = DateTimeFormat::convert($request['endTime'], 'UTC', DI::app()->getTimeZone());
+                       $finish   = DateTimeFormat::convert($request['end_time'], 'UTC', DI::app()->getTimeZone());
                        $nofinish = false;
                }
 
-               $start = DateTimeFormat::convert($request['startTime'], 'UTC', DI::app()->getTimeZone());
+               $start = DateTimeFormat::convert($request['start_time'], 'UTC', DI::app()->getTimeZone());
 
                // create event
                $event = [];
 
-               $event['id']       = $request['id'];
-               $event['uid']      = $uid;
-               $event['type']     = 'event';
-               $event['summary']  = $request['name'];
-               $event['desc']     = $request['desc'];
-               $event['location'] = $request['place'];
-               $event['start']    = $start;
-               $event['finish']   = $finish;
-               $event['nofinish'] = $nofinish;
+               $event['id']         = $request['id'];
+               $event['uid']        = $uid;
+               $event['type']       = 'event';
+               $event['summary']    = $request['name'];
+               $event['desc']       = $request['desc'];
+               $event['location']   = $request['place'];
+               $event['start_time'] = $start;
+               $event['end_time']   = $finish;
+               $event['nofinish']   = $nofinish;
 
                $event['allow_cid'] = $request['allow_cid'];
                $event['allow_gid'] = $request['allow_gid'];
index 257c9f06f45c5eb8cd8f30a8ee4a00d770dd539e..3e930f614b67a78696928b5d0182469d5a3e034e 100644 (file)
@@ -49,23 +49,23 @@ class Index extends BaseApi
                $items = [];
                foreach ($events as $event) {
                        $items[] = [
-                               'id'        => intval($event['id']),
-                               'uid'       => intval($event['uid']),
-                               'cid'       => $event['cid'],
-                               'uri'       => $event['uri'],
-                               'name'      => $event['summary'],
-                               'desc'      => BBCode::convertForUriId($event['uri-id'], $event['desc']),
-                               'startTime' => $event['start'],
-                               'endTime'   => $event['finish'],
-                               'type'      => $event['type'],
-                               'nofinish'  => $event['nofinish'],
-                               'place'     => $event['location'],
-                               'adjust'    => 1,
-                               'ignore'    => $event['ignore'],
-                               'allow_cid' => $event['allow_cid'],
-                               'allow_gid' => $event['allow_gid'],
-                               'deny_cid'  => $event['deny_cid'],
-                               'deny_gid'  => $event['deny_gid']
+                               'id'         => intval($event['id']),
+                               'uid'        => intval($event['uid']),
+                               'cid'        => $event['cid'],
+                               'uri'        => $event['uri'],
+                               'name'       => $event['summary'],
+                               'desc'       => BBCode::convertForUriId($event['uri-id'], $event['desc']),
+                               'start_time' => $event['start'],
+                               'end_time'   => $event['finish'],
+                               'type'       => $event['type'],
+                               'nofinish'   => $event['nofinish'],
+                               'place'      => $event['location'],
+                               'adjust'     => 1,
+                               'ignore'     => $event['ignore'],
+                               'allow_cid'  => $event['allow_cid'],
+                               'allow_gid'  => $event['allow_gid'],
+                               'deny_cid'   => $event['deny_cid'],
+                               'deny_gid'   => $event['deny_gid']
                        ];
                }