orgazone/orgajs

Relvin Gonzalez

Frontend Engineer
Software Engineer
Web Developer
JavaScript
#
Orgajs
Api for using orga.zone in your own apps.

Installation

Using Bower:
That's it! But you have to have a free account on apps.orga.zone to use the API! Please refer to the docs on docs.orga.zone:
Register for free there
Login and upload an empty index.html with your own AppName appname.orga.zone that you will need
Create your first user for the App with this AppName on https://apps.orga.zone/en/apiv2/gui-register.php?appname=APPNAME

Usage

Object creation

First, create an object of Orgajs and name it whatever you want. In this case we will name it orgajs.

Login

Then, we need to log in to the system:
Where you can specify a callback function to be run after the user has logged in. You could,for example, redirect to another page or call another method to run in sequence.
You can also, at this point, save this orgajs object to your localstorage and keep reusing it throughout the session.
The "data" field on the callback function holds whatever the api returns. It could be an error or success message, data requested, file, etc.
And that's it ! After this you may use any of the available methods to interact with the Api.
Remember to handle any errors, or expired sessions on your own. One way would be to check if the error returned 401 or 403 and if it did, then login the user again which will generate a new token.
##API For Optional arguments, you may use '' for Strings or 0 for numbers

Create Methods

Methods Arguments Description pushData - Push general data sortstring {
} Optional sort string sortint {
} Optional sort number formid {
} Optional Administration form ID. collection {
} Optional Name of collection data {
} Required Object that has the data to be pushed. For example, "field1":"A string in field1","field2":"Another string with RAND(1,1000) = 763","field3":"field3 has a value here" aCallback {
} Required Function to be called after api call has returned. uploadFile - Upload files up to 150 MB. The file is stored relatively to the app directory: for example: apps.orga.zone/up/ex3/files/NEWFILE.jpg. Allowed file types are: gif, jpg, png, doc, docx, ppt, pptx, xls, xlsx, zip, tgz and ics. sortint {
} Optional sort number parent {
} Optional sorter collection {
} Optional Name of collection formid {
} Optional Administration form ID. objid {
} Optional sorter file {
} Required sorter filedata {
} Optional object or array of file data. Ex : filename, date, creator, etc. aCallback {
} Required Function to be called after api call has returned.

Read Methods

Methods Arguments Description login - Logs in the user using given email and password aCallback {
} required Function to be called after api call has returned showUser - Shows information about the current user aCallback {
} required Function to be called after api call has returned getUser - gets information about a user with given email email {
} required Email of the user to search for aCallback {
} required Function to be called after api call has returned inviteUser - Invite user to the app to {
} required Email of the user you want to invite destination {
} required The destination link should be on your subdomain and we append the value ?to=email to the URL aCallback {
} required Function to be called after api call has returned getStatus - Get the primary key of last entry, total amount of entries and use optional filter sortstring {
} Optional sort string aCallback {
} Required Function to be called after api call has returned. getData - Get general data sortstring {
} Optional sort string sortint {
} Optional sort number collection {
} Optional Name of collection data {
} required Object that has the data to be searched for. For example, "field1":"A string in field1","field2":"Another string with RAND(1,1000) = 763","field3":"field3 has a value here" or "keyword" aCallback {
} required Function to be called after api call has returned. requestById - When you push data up, you will get an UNIQUE ID as an big integer value. You can use this value to retrieve one specific entry. id {
} required sort number aCallback {
} required Function to be called after api call has returned. getFile - Download a file filename {
} required name of file to be downloaded (Ex. tarifa.xlsx) aCallback {
} required Function to be called after api call has returned. searchFiles - You may filter out the files from different collections, sorting strings, etc.: All filters are optional sortstring {
} Optional sort string sortint {
} Optional sort number parent {
} Optional sorter formid {
} Optional Administration form ID. collection {
} Optional Name of collection objid {
} Optional sorter filedata {
} Optional object or array of file data. Ex : filename, date, creator, etc. aCallback {
} Required Function to be called after api call has returned. sendEmail - Function to send email. to {
} required Email of the person to send email to subject {
} required subject of the email message {
} required Message to be sent aCallback {
} Required Function to be called after api call has returned.

Update Methods

Methods Arguments Description updateUser - Update the current logged in user. firstname {
} required new firstname to use lastname {
} required new lastname to use nickname {
} required new nickname to use aCallback {
} Required Function to be called after api call has returned. updateEntry - Updates 1 entry in the APIv2 table, where appdata equals the primary key. sortstring {
} Optional sort string sortint {
} Optional sort int data {
} required Object or array with primary key and field to be updated. Example: Array("OZINDEX"=>"20150526202249-5303", "field1" => "...", "field2" => "...", "field3" => "...") aCallback {
} Required Function to be called after api call has returned. updateBy - Update entries by other column in WHERE clause. Updates entries in the APIv2 table, where appdata equals the self selected key column data {
} required Array("MYCOLUMN"=>"OZOBJID", "MYVALUE" => "TESTING", "field2" => "...", "field3" => "...")with MYCOLUMN is the identifier of the entry to update and my value the search value. MYCOLUMN and MYVALUE must be the first two entries of the appdata object! aCallback {
} Required Function to be called after api call has returned.

Delete Methods

Methods Arguments Description deleteEntry - Deletes 1 entry from the APIv2 table, where data equals the primary key. The "sorter" fields are optional, but could limit the delete sortstring {
} Optional sort string sortint {
} Optional sort int data {
} required primary key of the entry to be deleted aCallback {
} Required Function to be called after api call has returned. deleteFile - Delete a file filename {
} required name of file to be deleted (Ex. tarifa.xlsx) aCallback {
} required Function to be called after api call has returned.

Links

Partner With Relvin
View Services

More Projects by Relvin