Code Monkey home page Code Monkey logo

4d-google-workspace's Introduction

4d-google-workspace

A 4D component for accessing and working on your google workspace services.

This component is designed for 4D v19R5 or later.

This component is designed for use with the Service Account method of accessing Google Docs. This technique allows your app to operate from a server, to not require periodic re-authorization, and have access to all google services for all accounds for your domain. If you are trying to set up an app that will be for individual users and not an entire domain, you would use one of several other configurations.

Steps

  1. Setup your app in Google.

  2. I prefer submoduing this repo so updates to the code base trigger notifications in the repos that use it. I usually put them into a folder like Submodules in the parent project, or Resources/Submodules, etc. I do that because 4D does not like to have submodules directly in the Components folder, but it will be ok with having aliases/shortcuts in that folder.

  3. Copy/Alias/Shortcut google-workspace.4dbase (which is technically just a folder with the suffix .4dbase.) to the parent project's Components folder.

    • The Components folder and the Project folder should be at the same level.

    • I have included both the .4dbase file and the Source folder in the repo for completeness/ease-of-use. If you have not used a component before, you can also turn the Source folder into a component, and use that, instead:

      1. Duplicate the Source folder

      2. Rename the copied Source folder to something like google.4dbase. You now have a component. Copy/alias/shortcut that, if you like.

    • If this has worked, when you go into your parent project, in the 4D Explorer, you should see google-workspace and its methods and classes in the Component Methods section.

Notes

  • The classes are available via the cs.google namespace

  • Check out the aTest method for a very basic sample.

  • Documentation for the classes is available in the 4D Explorer and in the Source folder.

  • Use caution with turning any of the objects (Auth, for instance) into shared objects, as they must be modified. Auth needs to have the token object updated periodically, for example.

Reference

4d-google-workspace's People

Contributors

macmikey avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

4d-google-workspace's Issues

token timeout

  • test - might come over as an error call. should set up a daemon to run for a while until we fail

error handling

i am calling my own personal error handlers, but that won't make for a good component since i save the records in a table, and components can't have regular 4d tables.
i think the user is going to want to be able to send output to their own error handlers if they are going to submodule and throw in the components folder.

reduce network activity

know the current status of the sheet, current range, etc., before loading, again
possibly use developer metadata api

batchUpdate

I am really beating around the bush on implementing a more general version of this
there are many different sheet requests that should probably be managed via properties being changed and then sent back

singleton Auth

Class constructor
	$class:=OB Class(This)
	$me:=$class.me
	If ($me=Null)
		$me:=OB Copy(This; ck shared; $class)
		Use ($class)
			$class.me:=$me
			$class.new:=Formula(This.me)
		End use 
	End if   //$instance=null

collapse code

it looks like a lot of this code is going to be similar

  1. handle params /build query string - probably could do with a specifier as to what the different pieces are
  2. build the url
  3. do the query and return something

does object layout match google's?

especially for values for a sheet, i think we added a separate property tree.
i think what we should do, instead is add a reference to the current sheet, and leave the object intact, so the dev can modify the object directly, and the code for future development of the class is clearer and more straightforward (and it's easier to communicate with the google API)

reverse order

make it easier to insert on top and push down
might also want to be able to just add to the top, i.e. a "reverse append" - but it isn't really a reverse append b/c we'd want to maintain the existing header rows, and insert under them.

sheet names getting borked

getSheetnames() works until i duplicate the sheet? set values for the sheet?
then the structure breaks and the function doesn't work b/c the props have changed.

find blank row

like when trying to find the bottom of a table
useful when trying to read data

Here's doing it one way

$blankRowNumber:=$dataRow  // starting to look on $dataRow
$done:=False
For each ($rowData; $values.values; $dataRow) Until ($done)
    While ($rowData.length<=$commentCol)
        $rowData.push("")
    End while   //($rowData.length<=($commentCol+1))
						
    If ((String($rowData[$dateCol])#"") |\
        (String($rowData[$psCol])#"") |\
        (String($rowData[$shipCol])#"") |\
        (String($rowData[$recCol])#""))  //skip comments column b/c it might be undefined.
        $blankRowNumber:=$blankRowNumber+1
    Else 
        $done:=True
    End if   // ((String($rowData[$dateCol])="") & (String($rowData[$psCol])="") & (String($rowData[$shipCol])="") & (String($rowData[$recCol])="") & (String($rowData[$commentCol])=""))
End for each   //($rowData;$values.values) Until ($done)

error handling

  • failed auth
  • failed call to google
  • add via asserts and error routines?
  • 404, address invalid (1)

combine create sheet from template and move it into one function

$s := cs.spreadsheet.new ( $auth )
$properties := New object ( "title" ; "test spreadsheet" )
$s.spreadsheet := New object ( "properties" ; $properties )
$templateSS := cs.spreadsheet.new ( $auth ; $templateURL )
$templateSS.load ( "TEMPLATE" ; True ) // in the TEMPLATE sheet, load the grid data, which includes the cell metadata
$s.spreadsheet.sheets := $templateSS.sheetData.sheets // deep-copies the TEMPLATE sheet into the new spreadsheet
$success := $s.createSpreadsheet ()
ASSERT ($success)
// spreadsheet is at the root folder. Now, move it.

$ssID:=$s._spreadsheetId
$ssf := cs.google.driveFile.new ( $auth ; $ssID )  // the spreadsheet file
$fs := cs.google.driveFiles.new ( $auth ; "inspection logs" ; "folder" )  // find the folder with the name "inspection logs"
$numMatches := $fs.files.length
ASSERT ( $numMatches = 1 )

$folderID := $fs.getID()
ASSERT ( $folderID # Null )

$success := $ssf.moveTo ( $folderID )
ASSERT($success)

update props in docs

  • appendValues
  • createSpreadsheet
  • copySheetToSpreadsheet
  • duplicateSheet
  • entitySelectionToCollection
  • findSheetWithName
  • getSheetNames
  • getValues
  • load
  • parseError
  • renameSheet
  • setValues

calendar api

  • select cal
  • create cal
  • list events
  • add event
  • delete event
  • authenticate…
  • modify event
  • calendar list vs. calendar get
  • other calendar methods
  • other event methods
  • support paging

deconflict drive_file s

  • break it with a non-unique name
  • develop a tool to deconfilct
    might be able to do it by passing a path - if more than one match, error, and then dev can throw a path in, which we can traverse to deconflict.

padrows()

in the api description, google says that, in effect, rows will not be padded to get the right number of columns. either add code to the fetch or add separate code to get the collection to the dimension specified.
should we go both rows and columns?

add getEvent()

pull a paticular event from the calendar. how we get it isn't relelvant, that's up to the calendar to either have the events preloaded or to grab it from the server.

simpler use

  • pass an entity selection
  • it's already pretty straightforward to use a collection, but you have to assign the object .values, first.

overwrite existing values

if i throw a subset over the wall, all the other data in the sheet should disappear
especially if i specify the full range

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.