SalesforceRestClient.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file SalesforceRestClient.qm Qore user module for calling Salesforce.com REST services
/* SalesforceRestClient.qm Copyright (C) 2016 - 2017 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// this module requires Qore 0.8.13 or better
// require type definitions everywhere
// enable all warnings
// don't use "$" for vars, members, and methods, assume local variable scope
// do not ignore argument errors
namespace SalesforceRestClient {
const BulkJobQuery = "query";
const BulkJobInsert = "insert";
const BulkJobUpdate = "update";
const BulkJobUpsert = "upsert";
const BulkJobDelete = "delete";
const BulkJobOperations = (
BulkJobQuery: True,
BulkJobInsert: True,
BulkJobUpdate: True,
BulkJobUpsert: True,
BulkJobDelete: True,
);
const BulkJobCsv = "CSV";
const BulkJobJson = "JSON";
const BulkJobXml = "XML";
const BulkJobZipCsv = "ZIP_CSV";
const BulkJobZipJson = "ZIP_JSON";
const BulkJobZipXml = "ZIP_XML";
const BulkJobContentTypes = (
BulkJobCsv: MimeTypeCsv,
BulkJobJson: MimeTypeJson,
BulkJobXml: MimeTypeXmlApp,
BulkJobZipCsv: "zip/csv",
BulkJobZipJson: "zip/json",
BulkJobZipXml: "zip/xml",
);
class SalesforceRestClient : public RestClient::RestClient {
public:
public :
const Defaults = (
"oauth_url_auth": "https://login.salesforce.com/services/oauth2/authorize",
"oauth_url_token": "https://login.salesforce.com/services/oauth2/token",
"oauth_url_revoke": "https://login.salesforce.com/services/oauth2/revoke",
"api": "auto",
);
const DefaultSendEncoding = "gzip";
const RequiredOptions = (
// the Salesforce.com "consumer key"
"client_id",
// the Salesforce.com "consumer secret"
"client_secret",
// the Salesforce.com username
"username",
// the Salesforce.com password
"password",
);
const AsyncDataloadNs = "http://www.force.com/2009/06/asyncapi/dataload";
const JobInfoAttributes = (
"^attributes^": (
"xmlns": AsyncDataloadNs,
),
);
public:
private :
string oauth_url_auth;
string oauth_url_token;
string oauth_url_revoke;
Mutex m();
string token;
string client_id;
string client_secret;
string username;
string password;
string api;
string api_used;
hash api_hash;
public:
constructor(*hash opts, *softbool do_not_connect) ;
hash patch(string path, auto body, *reference<hash> info, *hash hdr);
hash doRequest(string m, string path, auto body, *reference<hash> info, softbool decode_errors = True, *hash hdr);
hash doBulkRequest(string m, string path, auto body, *reference<hash> info, softbool decode_errors = True, *hash hdr);
hash bulkGet(string path, auto body, *reference<hash> info, *hash hdr);
hash bulkPost(string path, auto body, *reference<hash> info, *hash hdr);
hash bulkJobCreate(string operation, string object, string job_content_type, *reference<hash> info, *hash hdr);
hash bulkJobAddBatch(string jobid, data batch_data, string job_content_type, *reference<hash> info, *hash hdr);
hash bulkJobClose(string jobid, *reference<hash> info, *hash hdr);
login(*reference<hash> info);
logout(*reference<hash> info);
string getApi();
*string getToken();
static string getBulkDate(date d);
static string getGmtDate(date d);
private:
static hash getOptions(*hash opts);
public:
private:
loginIntern(*reference<hash> info);
public:
};
class SalesforceRestConnection : public RestClient::RestConnection {
public:
public :
const Options = RestConnection::Options + (
"api": True,
"client_id": True,
"client_secret": True,
);
const OptionList = Options.keys();
public:
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
private:
SalesforceRestClient getImpl(bool connect = True, *hash rtopts);
public:
hash getOptions();
*hash getDefaultOptions();
string getType();
static SalesforceRestConnection make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
};
};
RestClient::RestClient
ConnectionProvider::AbstractConnection::monitor
bool monitor
SalesforceRestClient::SalesforceRestConnection::constructor
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
creates the SalesforceRestConnection object
date
date date(date dt)
SalesforceRestClient::SalesforceRestClient::oauth_url_revoke
string oauth_url_revoke
Salesforce.com OAuth2 Revoke Token URL.
Definition: SalesforceRestClient.qm.dox.h:316
ConnectionProvider::AbstractConnection::opts
*hash opts
SalesforceRestClient::BulkJobCsv
const BulkJobCsv
Salesforce.com bulk job "CSV" content type.
Definition: SalesforceRestClient.qm.dox.h:187
True
const True
SalesforceRestClient::BulkJobContentTypes
const BulkJobContentTypes
a hash of Salesforce.com bulk job content types; keys are Salesforce.com Bulk REST API Job Content Ty...
Definition: SalesforceRestClient.qm.dox.h:214
SalesforceRestClient::BulkJobXml
const BulkJobXml
Salesforce.com bulk job "XML" content type.
Definition: SalesforceRestClient.qm.dox.h:193
SalesforceRestClient::SalesforceRestConnection::getType
string getType()
returns "rest"
ConnectionProvider::AbstractConnection::name
string name
SalesforceRestClient
the SalesforceRestClient namespace contains all the objects in the SalesforceRestClient module ...
Definition: SalesforceRestClient.qm.dox.h:147
MimeTypeJson
const MimeTypeJson
ConnectionProvider::AbstractConnection::urlh
hash urlh
SalesforceRestClient::SalesforceRestClient::client_id
string client_id
Salesforce.com "consumer key".
Definition: SalesforceRestClient.qm.dox.h:325
SalesforceRestClient::BulkJobZipCsv
const BulkJobZipCsv
Salesforce.com bulk job "ZIP_CSV" content type.
Definition: SalesforceRestClient.qm.dox.h:196
SalesforceRestClient::BulkJobOperations
const BulkJobOperations
a hash of Salesforce.com bulk job operations; keys are Salesforce.com Bulk REST API Job Operations ...
Definition: SalesforceRestClient.qm.dox.h:175
SalesforceRestClient::BulkJobZipXml
const BulkJobZipXml
Salesforce.com bulk job "ZIP_XML" content type.
Definition: SalesforceRestClient.qm.dox.h:202
SalesforceRestClient::SalesforceRestConnection::getImpl
SalesforceRestClient getImpl(bool connect=True, *hash rtopts)
returns a SalesforceRestClient::SalesforceRestClient object
SalesforceRestClient::SalesforceRestConnection::make
static SalesforceRestConnection make(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
static constructor
SalesforceRestClient::BulkJobUpdate
const BulkJobUpdate
Salesforce.com bulk job "update" operation.
Definition: SalesforceRestClient.qm.dox.h:158
SalesforceRestClient::SalesforceRestConnection::getDefaultOptions
*hash getDefaultOptions()
returns default options
SalesforceRestClient::SalesforceRestClient::oauth_url_auth
string oauth_url_auth
Salesforce.com OAuth2 Authorization URL.
Definition: SalesforceRestClient.qm.dox.h:310
SalesforceRestClient::SalesforceRestClient::api_hash
hash api_hash
hash of APIs retrieved from GET /services/data; keyed by API version string; values: "label"...
Definition: SalesforceRestClient.qm.dox.h:343
SalesforceRestClient::BulkJobUpsert
const BulkJobUpsert
Salesforce.com bulk job "upsert" operation.
Definition: SalesforceRestClient.qm.dox.h:161
SalesforceRestClient::BulkJobDelete
const BulkJobDelete
Salesforce.com bulk job "delete" operation.
Definition: SalesforceRestClient.qm.dox.h:164
SalesforceRestClient::BulkJobQuery
const BulkJobQuery
Salesforce.com bulk job "query" operation.
Definition: SalesforceRestClient.qm.dox.h:152
SalesforceRestClient::BulkJobInsert
const BulkJobInsert
Salesforce.com bulk job "insert" operation.
Definition: SalesforceRestClient.qm.dox.h:155
SalesforceRestClient::BulkJobJson
const BulkJobJson
Salesforce.com bulk job "JSON" content type.
Definition: SalesforceRestClient.qm.dox.h:190
SalesforceRestClient::SalesforceRestClient::username
string username
Salesforce.com username.
Definition: SalesforceRestClient.qm.dox.h:331
SalesforceRestClient::SalesforceRestClient::token
string token
Salesforce.com token.
Definition: SalesforceRestClient.qm.dox.h:322
ConnectionProvider::AbstractConnection::desc
string desc
SalesforceRestClient::SalesforceRestConnection
class for Salesforce.com REST connections; returns SalesforceRestClient::SalesforceRestClient objects...
Definition: SalesforceRestClient.qm.dox.h:775
SalesforceRestClient::SalesforceRestClient::client_secret
string client_secret
Salesforce.com "consumer secret".
Definition: SalesforceRestClient.qm.dox.h:328
SalesforceRestClient::SalesforceRestConnection::Options
const Options
SalesforceRestConnection object connection options.
Definition: SalesforceRestClient.qm.dox.h:780
RestClient::RestConnection
ConnectionProvider::AbstractConnection::url
string url
hash
hash hash(object obj)
SalesforceRestClient::SalesforceRestClient::password
string password
Salesforce.com password.
Definition: SalesforceRestClient.qm.dox.h:334
SalesforceRestClient::SalesforceRestClient::api
string api
Salesforce.com REST API version to be used ("auto" = latest version)
Definition: SalesforceRestClient.qm.dox.h:337
SalesforceRestClient::BulkJobZipJson
const BulkJobZipJson
Salesforce.com bulk job "ZIP_JSON" content type.
Definition: SalesforceRestClient.qm.dox.h:199
MimeTypeXmlApp
const MimeTypeXmlApp
MimeTypeCsv
const MimeTypeCsv
SalesforceRestClient::SalesforceRestConnection::getOptions
hash getOptions()
gets options
SalesforceRestClient::SalesforceRestClient::api_used
string api_used
Salesforce.com REST API version currently in use.
Definition: SalesforceRestClient.qm.dox.h:340
SalesforceRestClient::SalesforceRestClient::oauth_url_token
string oauth_url_token
Salesforce.com OAuth2 Get Token URL.
Definition: SalesforceRestClient.qm.dox.h:313