This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import LoggerAPI | |
import KituraRequest | |
import SwiftyJSON | |
struct SlackField { | |
var title: String | |
var value: String | |
var short: Bool = false | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Slack Urls | |
debugSlackUrl = "https://hooks.slack.com/services/..."; | |
eodReportSlack = "https://hooks.slack.com/services/..."; | |
// Zoho Books | |
zohoBooksOrganisationId = "..."; | |
cashCustomerId = ...; | |
creditCardCustomerId = ...; | |
otherCustomerId = ...; | |
zohoBooksPettyCashAccountId = ...; | |
// Zoho Invoice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreLocation | |
extension CLLocationCoordinate2D { | |
func boundingBox(radius: CLLocationDistance) -> (max: CLLocationCoordinate2D, min: CLLocationCoordinate2D) { | |
// 0.0000089982311916 ~= 1m | |
let offset = 0.0000089982311916 * radius | |
let latMax = self.latitude + offset | |
let latMin = self.latitude - offset | |
// 1 degree of longitude = 111km only at equator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Got the code from https://github.com/csi-lk/google-app-script-xero-api | |
var API_END_POINT = 'https://api.xero.com/api.xro/2.0'; | |
var INVOICES_END_POINT = '/Invoices'; | |
// Working method to send a request with a payload | |
function sendRequest(endpoint, method, payload) { | |
var url = 'https://api.xero.com/api.xro/2.0' + endpoint | |
var authHeader = getAuthHeader(method, url); | |
var headers = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var oauth_nonce = createGuid(); | |
var oauth_timestamp = (new Date().getTime()/1000).toFixed(); | |
var signBase = 'GET' + '&' + encodeURIComponent(requestURL) + '&' + | |
encodeURIComponent( complexQuery + '&oauth_consumer_key=' + CONSUMER_KEY + '&oauth_nonce=' + | |
oauth_nonce + '&oauth_signature_method=' + oauth_signature_method + '&oauth_timestamp=' + | |
oauth_timestamp + '&oauth_token=' + CONSUMER_KEY + '&oauth_version=' + oauth_version + '&page=' + pageNo); | |
var hSig = rsa.signString(signBase, hashAlg); | |
var oauth_signature = encodeURIComponent(hextob64(hSig)); |