apility / netflex-calendar-sync
Sync calendar with Netflex Structures
Requires
- apility/netflex-sdk: ^1.0
- tightenco/collect: ^5.8
This package is auto-updated.
Last update: 2024-12-21 02:19:03 UTC
README
A simple library for performing a one way sync from a provider to netflex structures.
Installation
Include the repository from Composer.
$ composer require apility/netflex-calendar-sync
Calendars
Google Calendar
In order to scrape a calendar, Create an Api Key at the google cloud platform Here. This is a generic API key and its not Google Calendar specific. Enable access to the Google Calendar API through the same console.
Open your calendar app, (Google Calendar) and enter settings section for that calendar.
Find the ID of the calendar
Create a calendar instance like this;
/* First option is the calendar ID. Second option is the API key, Third option is an associative array of key values found in the Google API documentation */ $calendar = new GoogleCalendar($openingHourEntry->calendarId, \get_setting("google_calendar_sync_api_key"), [ 'singleEvents' => true, ]);
Google API Explorer/documentation
The items in the calendar is accessable as a Laravel Collection.
$openingHours = $calendar ->map(function($event) { return [ "eventId" => $event->id, "name" => "Ã…pningstid", "start" => Carbon::parse($event->start->dateTime)->format(DateTime::ISO8601), "end" => Carbon::parse($event->end->dateTime)->format(DateTime::ISO8601), "allDay" => false, ]; });
Resolvers
Resolvers are ways to immediately transfer a resolved object into Netflex.
EntrySync Resolver
The entry resolver takes any Netflex\Structure
object and lets you inject any JSON serializeable data into
it. (For example a Laravel Collection).
$resolver = new EntrySync(Models\Calendar::find(10000)); $resolver->syncData($openingHours);