<commit_before>/**
 * Copyright (c) 2014 by Center Open Middleware. All Rights Reserved.
 * Titanium Appcelerator 3.2.0GA
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 *
 *   getAuthorization
 *      Request authorization if permission is AUTHORIZATION_UNKNOWN
 *      Return [AUTHORIZATION_AUTHORIZED | AUTHORIZATION_RESTRICTED]
 *
 *   getContactList
 *      Optional Search with Object with property 'value' like name, middlename, combination, etc
 *      Return Contact Array
 *
 *   createContact
 *      Parameters of Contact
 *         address:  {Object}
 *                   keys = home, work or other
 *                   values = {Object Array}
 *                           keys = CountryCode, Street, City, County, State, Country, ZIP
 *                           values = {String}
 *         birthday: {String} Date Format ISO8601 (2013-09-23T22:03:46.000+0000)
 *         date:     {Object}
 *                   keys = anniversary or other
 *                   values = {String Array} Date Format ISO8601
 *         email:    {Object}
 *                   keys = home, work or other
 *                   values = {String Array}
 *         im:       {Object}
 *                   keys = home, work or other
 *                   values = {Object Array}
 *                           keys = service, username
 *                           - service = AIM, Facebook, GaduGadu, GoogleTalk, ICQ, MSN, QQ, Skype or Yahoo
 *                           - username = {String}
 *         image:    {String} Base64 Representation of Ti.Blob
 *         name:     {String} Concatenation of firstname and middlename
 *         surname:  {String} Representation of lastname
 *         nick:     {String} Representation of nickname
 *         note:     {String}
 *         phone:    {Object}
 *                   keys = home, work, other, mobile, pager, workFax, homeFax or main
 *                   values = {String}
 *         organization = {String}
 *         website:  {Object}
 *                   keys = homepage, home, work or other
 *                   values = {String Array}
 *      Return Contact Object
 *
 *   deleteContact
 *      Search with parameter (name, middlename, lastname or combination)
 *      Return status code [0 = Success, 1 = Not Found, 2 = Multiple Contacts Found]
 *
 *   saveChanges
 *
 */

"use strict";

var Contacts = (function() {

    var _device = (Ti.Platform.getOsname() === 'ipad' ||
                   Ti.Platform.getOsname() === 'iphone') ? 'ios' : 'android',
    _version = parseInt(Ti.Platform.getVersion().split('.')[0], 10),
    _self = {
        'tempContacts': []
    };

    /** Get Authorization Property
     * Condition AUTHORIZATION_UNKNOWN -> RequestAuthorization
     * @return : AUTHORIZATION_AUTHORIZED or AUTHORIZATION_RESTRICTED */
    _self.getAuthorization = function() {
        var auth = Ti.Contacts.getContactsAuthorization();
        if(auth === Ti.Contacts.AUTHORIZATION_UNKNOWN){
            Ti.Contacts.requestAuthorization(function (){
                return 'AUTHORIZATION_AUTHORIZED';
            });
        }
        auth = (auth === Ti.Contacts.AUTHORIZATION_AUTHORIZED) ?
            'AUTHORIZATION_AUTHORIZED' : 'AUTHORIZATION_RESTRICTED';
        return auth;
    };<commit_msg>[API.Contacts] getAuthorization fix always return authorized<commit_after>/**
 * Copyright (c) 2014 by Center Open Middleware. All Rights Reserved.
 * Titanium Appcelerator 3.2.0GA
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 *
 *   getAuthorization
 *      Request authorization if permission is AUTHORIZATION_UNKNOWN
 *      Return [AUTHORIZATION_AUTHORIZED | AUTHORIZATION_RESTRICTED] in callback
 *
 *   getContactList
 *      Optional Search with Object with property 'value' like name, middlename, combination, etc
 *      Return Contact Array
 *
 *   createContact
 *      Parameters of Contact
 *         address:  {Object}
 *                   keys = home, work or other
 *                   values = {Object Array}
 *                           keys = CountryCode, Street, City, County, State, Country, ZIP
 *                           values = {String}
 *         birthday: {String} Date Format ISO8601 (2013-09-23T22:03:46.000+0000)
 *         date:     {Object}
 *                   keys = anniversary or other
 *                   values = {String Array} Date Format ISO8601
 *         email:    {Object}
 *                   keys = home, work or other
 *                   values = {String Array}
 *         im:       {Object}
 *                   keys = home, work or other
 *                   values = {Object Array}
 *                           keys = service, username
 *                           - service = AIM, Facebook, GaduGadu, GoogleTalk, ICQ, MSN, QQ, Skype or Yahoo
 *                           - username = {String}
 *         image:    {String} Base64 Representation of Ti.Blob
 *         name:     {String} Concatenation of firstname and middlename
 *         surname:  {String} Representation of lastname
 *         nick:     {String} Representation of nickname
 *         note:     {String}
 *         phone:    {Object}
 *                   keys = home, work, other, mobile, pager, workFax, homeFax or main
 *                   values = {String}
 *         organization = {String}
 *         website:  {Object}
 *                   keys = homepage, home, work or other
 *                   values = {String Array}
 *      Return Contact Object
 *
 *   deleteContact
 *      Search with parameter (name, middlename, lastname or combination)
 *      Return status code [0 = Success, 1 = Not Found, 2 = Multiple Contacts Found]
 *
 *   saveChanges
 *
 */

"use strict";

var Contacts = (function() {

    var _device = (Ti.Platform.getOsname() === 'ipad' ||
                   Ti.Platform.getOsname() === 'iphone') ? 'ios' : 'android',
    _version = parseInt(Ti.Platform.getVersion().split('.')[0], 10),
    _self = {
        'tempContacts': []
    };

    /** Get Authorization Property
     * @param {Function} callback
     * @return {String} state */
    _self.getAuthorization = function(callback) {
        var auth = Ti.Contacts.getContactsAuthorization();
        if(auth === Ti.Contacts.AUTHORIZATION_UNKNOWN){
            Ti.Contacts.requestAuthorization(function(){
                auth = (auth === Ti.Contacts.AUTHORIZATION_AUTHORIZED) ?
                    'AUTHORIZATION_AUTHORIZED' : 'AUTHORIZATION_RESTRICTED';
                callback(auth);
            });
        }
        else{
            auth = (auth === Ti.Contacts.AUTHORIZATION_AUTHORIZED) ?
                'AUTHORIZATION_AUTHORIZED' : 'AUTHORIZATION_RESTRICTED';
            callback(auth);
        }
        auth = null;
    };
{'fraction_non_alphanumeric': 0.09711286089238845, 'fraction_numerical': 0.012831729367162438, 'mean_word_length': 1.8722780569514237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4413429', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1825, 'n_words': 530}