Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Swift 3,4,5... Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Swift 3,4,5...) GetHarvest - Test Personal Access Token

Demonstrates how to test your GetHarvest Personal Access Token

Chilkat Downloads for the Swift Programming Language

MAC OS X (Cocoa) Objective-C/Swift Libs

iOS Objective-C/Swift Libs

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!
    var success: Bool

    http.setRequestHeader("User-Agent", value: "Harvest API Example")
    http.setRequestHeader("Harvest-Account-ID", value: "ACCOUNT_ID")
    http.setRequestHeader("Authorization", value: "Bearer ACCESS_TOKEN")

    let sbResponseBody = CkoStringBuilder()!
    success = http.quickGetSb("https://api.harvestapp.com/api/v2/users/me.json", sbContent: sbResponseBody)
    if success != true {
        print("\(http.lastErrorText!)")
        return
    }

    let jResp = CkoJsonObject()!
    jResp.loadSb(sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    var respStatusCode: Int = http.lastStatus.intValue
    print("Response Status Code = \(respStatusCode)")

    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(http.lastResponseHeader!)")
        return
    }

    // Sample JSON response:

    // {
    //   "id": 2826142,
    //   "first_name": "Joe",
    //   "last_name": "Johnson",
    //   "email": "joe@example.com",
    //   "telephone": "",
    //   "timezone": "Central Time (US & Canada)",
    //   "weekly_capacity": 126000,
    //   "has_access_to_all_future_projects": false,
    //   "is_contractor": false,
    //   "is_admin": true,
    //   "is_project_manager": false,
    //   "can_see_rates": true,
    //   "can_create_projects": true,
    //   "can_create_invoices": true,
    //   "is_active": true,
    //   "created_at": "2019-06-06T15:57:58Z",
    //   "updated_at": "2019-06-06T15:58:32Z",
    //   "default_hourly_rate": 175.0,
    //   "cost_rate": 60.0,
    //   "roles": [
    //     "role1",
    //     "role2"
    //   ],
    //   "avatar_url": "https://d3s3969qhosaug.cloudfront.net/default-avatars/4d46.png?1559836678"
    // }

    // Sample code for parsing the JSON response...
    // Use the following online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    var id: Int
    var first_name: String?
    var last_name: String?
    var email: String?
    var telephone: String?
    var timezone: String?
    var weekly_capacity: Int
    var has_access_to_all_future_projects: Bool
    var is_contractor: Bool
    var is_admin: Bool
    var is_project_manager: Bool
    var can_see_rates: Bool
    var can_create_projects: Bool
    var can_create_invoices: Bool
    var is_active: Bool
    var created_at: String?
    var updated_at: String?
    var default_hourly_rate: String?
    var cost_rate: String?
    var avatar_url: String?
    var i: Int
    var count_i: Int
    var strVal: String?

    id = jResp.int(of: "id").intValue
    first_name = jResp.string(of: "first_name")
    last_name = jResp.string(of: "last_name")
    email = jResp.string(of: "email")
    telephone = jResp.string(of: "telephone")
    timezone = jResp.string(of: "timezone")
    weekly_capacity = jResp.int(of: "weekly_capacity").intValue
    has_access_to_all_future_projects = jResp.bool(of: "has_access_to_all_future_projects")
    is_contractor = jResp.bool(of: "is_contractor")
    is_admin = jResp.bool(of: "is_admin")
    is_project_manager = jResp.bool(of: "is_project_manager")
    can_see_rates = jResp.bool(of: "can_see_rates")
    can_create_projects = jResp.bool(of: "can_create_projects")
    can_create_invoices = jResp.bool(of: "can_create_invoices")
    is_active = jResp.bool(of: "is_active")
    created_at = jResp.string(of: "created_at")
    updated_at = jResp.string(of: "updated_at")
    default_hourly_rate = jResp.string(of: "default_hourly_rate")
    cost_rate = jResp.string(of: "cost_rate")
    avatar_url = jResp.string(of: "avatar_url")
    i = 0
    count_i = jResp.size(ofArray: "roles").intValue
    while i < count_i {
        jResp.i = i
        strVal = jResp.string(of: "roles[i]")
        i = i + 1
    }


}

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.