Skip to content

rfaisal/tiny-azuresdk-titanium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 

Repository files navigation

AzureSDK for Titanium Mobile Applications

oAuth flow

  1. Verify the identity of the user by the native app, i.e., facebook and get a access_token.
  2. Use the access_token to login.

TODOs

These are the TODO items. Feel free to contribute.

  1. Currently only supports facebook, add other identity providers.
  2. Add support for Admin level access.

Usage

  1. Download WindowsAzure.js and put it in the Resources/lib/ directory.

  2. Initialize :

     var WindowsAzure = require('lib/WindowsAzure');
     var mClient = new WindowsAzure.MobileServiceClient('https://my-azure-app.azure-mobile.net/','my-azure-secret');
    
  3. Login :

     mClient.login(WindowsAzure.MobileServiceAuthenticationProvider.Facebook,'facebook_access_token',
     	function(_error,_user){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//_user.getUserId() and _user.getAuthenticationToken() available
     		}
     	}
     );
    
  4. Look up a table :

     // by the primary id
     // Depricated: this method is depricated since version 1.1.0, use MobileServiceTable.prototype.select instead
     mClient.getTable('my-table-name').lookUp('unique-primary-key',function(_error,_obj){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//_obj.column_name to access each column of the returned row
     		}
     });
     
     mClient.getTable('my-table-name').select(function(_error,_obj){
             if(_error){
     			//handle _error
     		}
     		else{
     			//_obj.column_name to access each column of the returned row
     		}
     }, 
     'unique-primary-key : put null for all rows',
     ['column_name_1','column_name_1'], // put null to return all the columns
     '(column_1 eq some_value)'); // where string, look: http://msdn.microsoft.com/en-us/library/azure/jj677199.aspx
    
  5. Insert to a table :

     mClient.getTable('my-table-name').insert({
     	'column_1': 'column_1_value',
     	'column_2': 'column_2_value'
     },function(_error,_obj){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//_obj.column_name to access each column of the newly inserted row
     		}
     });
    
  6. Update a row of a table :

     mClient.getTable('my-table-name').update('unique-primary-key',
     {
     	'column_1': 'updated_1_value',
     	'column_2': 'updated_2_value'
     },
     function(_error,_obj){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//_obj.column_name to access each column of the updated row
     		}
     });
    
  7. Delete a row from a table by the primary id :

     mClient.getTable('my-table-name').del('unique-primary-key',function(_error,_obj){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//successful
     		}
     });
    
  8. Calling custom API by HTTP GET:

     mClient.invokeGetApi('api_name',{
     		'url_param_1' : 'some value',
     		'url_param_2' : 'other value'
     	},
     	function(_error,_obj){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//_obj is the GET response.
     		}
     	}
     );
    
  9. Calling custom API by HTTP POST:

     mClient.invokePostApi('api_name',{
     		'req_body_1' : 'some value',
     		'req_body_2' : 'this can be a complex object'
     	},
     	function(_error,_obj){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//_obj is the POST response.
     		}
     	}
     );
    
  10. Calling custom API by HTTP PUT:

     mClient.invokePutApi('api_name',{
     		'req_body_1' : 'some value to be updated',
     		'req_body_2' : 'this can be a complex object'
     	},
     	{
     		'url_param_1' : 'ideally an id to uniquely identify the object to update',
     		'url_param_2' : 'some other value'
     	}
     	function(_error,_obj){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//_obj is the PUT response.
     		}
     	}
     );
    
  11. Calling custom API by HTTP PATCH:

     mClient.invokePatchApi('api_name',{
     		'req_body_1' : 'some value to be updated',
     		'req_body_2' : 'this can be a complex object'
     	},
     	{
     		'url_param_1' : 'ideally an id to uniquely identify the object to update',
     		'url_param_2' : 'some other value'
     	}
     	function(_error,_obj){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//_obj is the PATCH response.
     		}
     	}
     );
    
  12. Calling custom API by HTTP DELETE:

     mClient.invokeDeleteApi('api_name',
     	{
     		'url_param_1' : 'ideally an id to uniquely identify the object to delete',
     		'url_param_2' : 'may be u need 2 values to uniquely identify the object'
     	}
     	function(_error,_obj){
     		if(_error){
     			//handle _error
     		}
     		else{
     			//_obj is the DELETE response.
     		}
     	}
     );
    

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors