/CLI-Send-XML-file-to-Google-Spreadsheet-via-Google-Sheets-API

CLI program to process a local or remote XML file and push the data of that XML file to a Google Spreadsheet via the Google Sheets API (https://developers.google.com/sheets/).

Primary LanguagePHP

CLI-Send-XML-file-to-Google-Spreadsheet-via-Google-Sheets-API 😎😎

This CLI program is built on the LARAVEL FRAMEWORK. The program process a local or remote XML file and push the data of the XML file to a Google Spreadsheet via the Google Sheets API Google Spreadsheet API.

The Google Sheets API use the REST APIs like Sheets API and Charts API to interact programmatically with Google Sheets.

Repo Overview 🥳🥳

The repository contains source code on how to read XML data, format it and send to Googlesheet using the Googlesheet API.

Specifications in the clone include

  • The program reads in a local or remote xml file (configurable as a parameter)

  • Screenshot of read write operation via the CLI

  • Configurable Authentication against Google API with Service Account and Google cloud credentials
  • Writing of errors to logfile
  • Single CLI command to automate the read and write process in less than 5secs
  • Requirements 🔧🔧

  • Register and create a google console developer account set up a project retrieve your client credentials and then create a service account (download details in JSON).
  • Download PHP V7 and above.
  • Install Composer
  • Steps to run locally 🧑‍💻👩‍💻

  • Clone this repository:
  •  git clone https://github.com/LarrySul/CLI-Send-XML-file-to-Google-Spreadsheet-via-Google-Sheets-API/ 
  • Install dependencies:
  •  composer install 
  • Add the API key of your Google developer console and download the service account JSON to the storage directory.
  • Open the CLI in preferred editor and run the command:
  •  php artisan xml-to-google-spreadsheet 

    The command also accepts an optional parameter with the file path either local or remotely. The clone already ships with a default file coffee_feed.xml in the public directory.

     php artisan xml-to-google-spreadsheet coffee_feed.xml 

    Once the command is done you'll get a success message in the CLI 😜

    Screenshot of start sheet

    Coding Style 🚀🚀

  • Which patterns have been used: The coding pattern adopted is the creation pattern type where the business logic is hidden into services and traits.
  • How is your code structured: The code is well structure to use a creational design pattern, inheritance, DRY Principle, typehint of parameter and return type to functional declarations and lot more.
  • Have you applied SOLID and/or CLEAN CODE principles: Yes
  • Are tests available and how have they been set up : Yes, the project has a total of 5 test cases (4 Unit and 1 Feature).

  • Screenshot of end sheet