def main(): args = sys.argv check_args(args, 1) account_id = args[1] msf = LibMtSalesForce() soql = "SELECT Id From Contact Where AccountId='%s'" % (account_id) response = msf.query(soql) p(response) return response
def main(): args = sys.argv check_args(args, 2) msf = LibMtSalesForce() id = args[1] session_id__c = args[2] api_path = 'sobjects/Account/%s?_HttpMethod=PATCH' % (id) payload = {"SessionId__c": session_id__c} response = msf.http_request(api_path, method='POST', data=payload) return response.content.decode() # byte->string
def main(): args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT Id,Name,MstDisease__c,Other__c FROM AccountDisease__c WHERE AccountDisease2Account__c='%s'" % ( args[1]) response = msf.query(soql) p(response) return response
def main(): args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT Id,Name,MstCategory__c,Other__c,IsPrimary__c FROM AccountCategory__c WHERE AccountCategory2Address__c='%s'" % ( args[1]) response = msf.query(soql) p(response) return response
def main(): args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT Id,AddressClass__c,EmpDepartment__c,MstWorkClassId__c,EmpName__c,EmpClass__c,Zip__c,Pref__c,City__c,Address__c,Tel__c,isShippingAddressOfMT__c,shisetsu_code__c,checkFlag__c FROM Address__c WHERE AccountId__c='%s'" % ( args[1]) response = msf.query(soql) p(response) return response
def main(): args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "Select CreatedDate, AccountPoint2Account__c, Point_i__c, Comment_c__c FROM AccountPoint__c WHERE IsDeleted = FALSE AND AccountPoint2Account__c = '%s' AND CreatedDate >= 2018-04-01T00:00:00+09:00 order by CreatedDate" % ( args[1]) response = msf.query(soql) p(response) return response
def main(): """ SOQLのテスト実行用。データの確認もこれが手っ取りばやい """ msf = LibMtSalesForce() # soql = "SELECT Name FROM CodeMaster__c WHERE Id='%s'" %(id) # soql = "SELECT Name, CodeKind__c FROM CodeMaster__c" soql = "SELECT id FROM AccountSymptom__c" response = msf.query(soql) p(response) return response
def main(): """ CodeMasterからID指定でNameを取得 """ args = sys.argv check_args(args, 1) id = args[1] msf = LibMtSalesForce() soql = "SELECT Name FROM CodeMaster__c WHERE Id='%s'" % (id) response = msf.query(soql) p(response) return response
def main(): """ 指定Accountの症状取得 """ args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT (SELECT Name, MstSymptom__c, Other__c FROM AccountAccountSymptoms__r) " \ "FROM Account WHERE Id ='%s'" % (args[1]) response = msf.query(soql) p(response) return response
def main(): """ 指定Accountの勤務先取得 """ args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT (SELECT Name, AddressClass__c, MstWorkClassId__c, EmpName__c, EmpClass__c, Zip__c, Pref__c, City__c, Address__c, Building__c, Tel__c FROM AccountAddresses__r) " \ "FROM Account WHERE Id ='%s'" % (args[1]) response = msf.query(soql) p(response) return response
def main(): """ 指定Account項目一通り取得 """ args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT Id, MstMemberClassId__c, Name, LastName__c, FirstName__c, Kana__c, KanaSei__c, KanaMei__c, MailAddr__c, Sex__c, Birthday__c, Nickname__c, MstLicenseId__c, LicenseNumber__c, LicenseYear__c, MstUniversityId__c, UniversityOther__c, StudentMstUniversityId__c, StudentUniversityOther__c, StudentGraduationDay__c, StudentInternHospital__c, StudentWorkingForm__c, StudentHospitalDepartment__c, ImsMonitor__c, MailStatus__c, ResearchStatus__c, ConfStatus__c, MtPostFlag__c, PaidStatus__c, MtwMemberFlag__c, MtNumber__c, DcfNumber__c, DeliveryIds__c, Point__c, OptinStatus__c " \ "FROM Account WHERE Id = '%s' AND deleteFlag__c = FALSE " % (args[1]) response = msf.query(soql) p(response) return response
def main(): """ 指定Accountのオプトイン情報取得 001N000001HsLSUIA3 """ args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT (SELECT Id, OptinCP2CP__c FROM AccountOptinCPs__r) " \ "FROM Account WHERE Id ='%s'" % (args[1]) response = msf.query(soql) p(response) return response
def main(): """ 指定Accountのカテゴリー取得 """ args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT (SELECT Name, MstCategory__c, Other__c, IsPrimary__c FROM AccountAccountCategories__r) " \ "FROM Account WHERE Id ='%s'" % (args[1]) response = msf.query(soql) p(response) return response
def main(): """ Object名を指定して/sobjects/オブジェクト名/' のsf_apiを実行する。 """ args = sys.argv check_args(args, 2) object_name = args[1] id = args[2] # idが不要な場合もある..? msf = LibMtSalesForce() api_path = 'sobjects/%s/%s' % (object_name, id) payload = {} response = msf.http_request(api_path, method='GET', data=payload) return response.content.decode() # byte->string
def main(): """ """ # TODO: パラメータでjson取得 file = open('./data/post_sobject.json', 'r') data = json.load(file) args = sys.argv check_args(args, 1) object_name = args[1] msf = LibMtSalesForce() api_path = 'sobjects/%s/' % (object_name) response = msf.http_request(api_path, method='POST', data=data) p(response) return response.content.decode() # byte->string
def main(): """ 指定Accountの専門医取得 001N000001HsLSUIA3 """ args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT (SELECT Name, MstSpeciality__c, Other__c FROM AccountAccountSpecialities__r) " \ "FROM Account WHERE Id ='%s'" % (args[1]) response = msf.query(soql) p(response) return response
def main(): """ optin_signup apexはOptinStatus__cをtrueにして、その後の値を返す """ args = sys.argv check_args(args, 1) account_id = args[1] msf = LibMtSalesForce() api_path = 'optin/signup/pm/?id=%s' % (account_id) payload = {} response = msf.apexecute(api_path, method='GET', data=payload) p(response) return response
def main(): """ AccountIDを指定して、Account情報を取得する """ # https://cs6.salesforce.com/services/apexrest/account/with_relations/?id=001N000001HsLSUIA3 args = sys.argv check_args(args, 1) account_id = args[1] msf = LibMtSalesForce() api_path = 'account/with_relations?id=%s' % (account_id) payload = {} response = msf.apexecute(api_path, method='GET', data=payload) p("Debug:") p(response) return response
def main(): """ codeKindを指定してCodeMasterを取得する # code_kindの例 akasatana position work_division """ args = sys.argv check_args(args, 1) msf = LibMtSalesForce() soql = "SELECT Id, CodeKind__c, Code__c, Kubun__c, Name, ValueKana__c, ValueEng__c FROM CodeMaster__c " \ "WHERE CodeKind__c = '%s'" % (args[1]) response = msf.query(soql) p(response) return response
def main(): """ SalesforceのLightning Platform REST API にリクエスト Excel 5行目 """ # https://cs6.salesforce.com/services/data/v28.0/sobjects/Account/001N000001HsLSUIA3?_HttpMethod=PATCH args = sys.argv check_args(args, 2) # init account_id = args[1] session_id = args[1] msf = LibMtSalesForce() # main api_path = 'sobjects/Account/%s?_HttpMethod=PATCH' % (account_id) data = {'SessionId__c': session_id} response = msf.http_request(api_path, 'POST', data) return response
def main(): """ Account作成 """ # TODO: パラメータでjson取得 # dev ダミーデータ file = open('./data/post_apex_account_create.json', 'r') data = json.load(file) # args = sys.argv # check_args(args, 0) msf = LibMtSalesForce() api_path = 'account/create_with_relations/' payload = data response = msf.apexecute(api_path, method='POST', data=data) p(response) # 001N000001ypTXaIAM return response
def main(): """ """ # TODO: パラメータでjson取得 # dev ダミーデータ file = open('./data/post_apex_question.json', 'r') data = json.load(file) # args = sys.argv # check_args(args, 0) msf = LibMtSalesForce() api_path = 'simple_questionnaire/question/updater/' payload = data response = msf.apexecute(api_path, method='POST', data=data) p(response) return response
def main(): """ Pointの更新 id:001N000001HsLSUIA3 displacement:-100 // 変更する値 (現在のポイントから-100)とか bikou: Amazon """ args = sys.argv check_args(args, 3) msf = LibMtSalesForce() api_path = 'accountpoint/?id=%s&displacement=%s&bikou=%s' % ( args[1], args[2], args[3]) payload = {} response = msf.apexecute(api_path, method='GET', data=payload) p(response) return response
def main(): """ AccountIDを指定して、該当ユーザーの主たる勤務先のIDを取得する """ # dummy_id :001N000001HsLSUIA3 args = sys.argv check_args(args, 1) account_id = args[1] msf = LibMtSalesForce() soql = \ "SELECT (SELECT Id, AddressClass__c FROM " \ "AccountAddresses__r WHERE AddressClass__c = '主たる勤務先') " \ "FROM Account WHERE Id = '%s'" % (account_id) response = msf.query(soql) account_id = response['records'][0]['AccountAddresses__r']['records'][0][ 'Id'] p(account_id) return account_id
def main(): """ 主たる勤務先の情報を取得する? (excel10行目) """ # dummy_id :001N000001HsLSUIA3 args = sys.argv check_args(args, 1) account_category2_address = args[1] msf = LibMtSalesForce() soql = "SELECT Id,Name,MstCategory__c,Other__c,IsPrimary__c FROM AccountCategory__c" \ "WHERE AccountCategory2Address__c='%s' AND IsPrimary__c = true" % ( account_category2_address) response = msf.query(soql) account_id = response['records'][0]['AccountAddresses__r']['records'][0][ 'Id'] p(account_id) return account_id
def main(): p("main") msf = LibMtSalesForce() p(msf.query("SELECT Id, Name FROM Organization"))