Exemplo n.º 1
0
    def create_personal_transfer(source_account_id, payee_id,
                                 ransaction_amount, access_token):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")
        payload = "{\"sourceAccountId\":\"%s\",\"" \
                  "transactionAmount\":%d,\"" \
                  "transferCurrencyIndicator\":\"SOURCE_ACCOUNT_CURRENCY\",\"" \
                  "payeeId\":\"%s\",\"" \
                  "chargeBearer\":\"BENEFICIARY\",\"" \
                  "paymentMethod\":\"GIRO\",\"" \
                  "fxDealReferenceNumber\":\"%s\",\"" \
                  "transferPurpose\":\"CASH_DISBURSEMENT\"}"

        headers = {
            'authorization': "Bearer %s" % access_token,
            'uuid': str(uuid.uuid1()),
            'client_id': Global.get_client_id(),
            'content-type': "application/json",
            'accept': "application/json"
        }

        conn.request(
            "POST",
            "/gcb/api/v1/moneyMovement/personalDomesticTransfers/preprocess",
            payload, headers)

        res = conn.getresponse()
        data = res.read()

        print(data.decode("utf-8"))
Exemplo n.º 2
0
    def get_access_token_by_authorization_code_grant(code, uri):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")

        payload = "grant_type=authorization_code&code=%s&redirect_uri=%s" % (
            code, uri)

        headers = {
            'authorization': "Basic %s" % Global.get_pressed_id_secret_pair(),
            'content-type': "application/x-www-form-urlencoded",
            'accept': "application/json"
        }

        conn.request("POST", "/gcb/api/authCode/oauth2/token/hk/gcb", payload,
                     headers)

        res = conn.getresponse()
        data = res.read()

        json_str = data.decode("utf-8")
        dict = json.loads(json_str)

        if "access_token" not in dict.keys():
            print(json_str)
            return "error"
        else:
            access_token = dict["access_token"]
            refresh_token = dict["refresh_token"]
            ret_dic = {
                "access_token": access_token,
                "refresh_token": refresh_token
            }
            print(ret_dic)
            return ret_dic
Exemplo n.º 3
0
    def get_access_token_by_client_credentials_grant(scope):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")

        payload = "grant_type=client_credentials&scope=%s" % scope

        headers = {
            'authorization': "Basic %s" % Global.get_pressed_id_secret_pair(),
            'content-type': "application/x-www-form-urlencoded",
            'accept': "application/json"
        }

        conn.request("POST", "/gcb/api/clientCredentials/oauth2/token/hk/gcb",
                     payload, headers)

        res = conn.getresponse()
        data = res.read()

        json_str = data.decode("utf-8")
        dict = json.loads(json_str)
        if "access_token" not in dict.keys():
            print(json_str)
            return "error"
        else:
            token = dict["access_token"]
            return token
Exemplo n.º 4
0
    def revoke_access(revoke_token, token_type_hint):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")

        payload = "token=%s&token_type_hint=%s" % (revoke_token,
                                                   token_type_hint)

        headers = {
            'authorization': "Basic %s" % Global.get_pressed_id_secret_pair(),
            'content-type': "application/x-www-form-urlencoded",
            'accept': "application/json"
        }

        conn.request("POST", "/gcb/api/authCode/oauth2/revoke", payload,
                     headers)

        res = conn.getresponse()
        data = res.read()

        json_str = data.decode("utf-8")
        dict = json.loads(json_str)

        if "status" not in dict.keys() or dict["status"] != "success":
            print(json_str)
            return "error"
        else:
            return "success"
Exemplo n.º 5
0
    def get_authorization_code(scope, country_code, business_code, locale,
                               state, redirect_uri):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")
        headers = {'accept': "application/json"}

        conn.request("GET",
                     "/gcb/api/authCode/oauth2/authorize?response_type=code&"
                     "client_id=%s&"
                     "scope=%s&"
                     "countryCode=%s&"
                     "businessCode=%s&"
                     "locale=%s&"
                     "state=%s&"
                     "redirect_uri=%s" %
                     (Global.get_client_id(), scope, country_code,
                      business_code, locale, state, redirect_uri),
                     headers=headers)

        res = conn.getresponse()
        print(res)
        data = res.read()

        # print(data.decode("utf-8"))
        print(data)
        return res
Exemplo n.º 6
0
    def get_cards_info(card_function):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")

        headers = {
            'authorization': "Bearer %s" % Global.get_access_token(),
            'client_id': Global.get_client_id(),
            'uuid': str(uuid.uuid1()),
            'accept': "application/json"
        }

        conn.request("GET",
                     "/gcb/api/v1/cards?cardFunction=%s" % card_function,
                     headers=headers)

        res = conn.getresponse()
        data = res.read()

        print(data.decode("utf-8"))
Exemplo n.º 7
0
    def insurance_booking(access_token):

        # 调用insurance_source_account_eligibility,如果可以预定则预定,否则不能预定
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")
        payload = "{\"policyDetails\":{\"insuranceProductCode\":\"PR001- PAGOS PROTEGIDOS BASICO\",\"" \
                  "insuranceProductCurrencyCode\":\"SGD\",\"insurancePolicyNumber\":\"83748374389\",\"" \
                  "insurancePolicyStatus\":\"CONFIRMED\",\"insuranceSumAssuredAmount\":25000.12,\"" \
                  "insurancePremiumPaymentFrequency\":\"MONTHLY\",\"policyTermType\":\"MONTHS\",\"" \
                  "policyTerm\":120,\"premiumPaymentTermType\":\"MONTHS\",\"premiumPaymentTerm\":180,\"" \
                  "policyBillingMode\":\"INTERNAL\",\"applicationDate\":\"2018-10-01'\",\"" \
                  "insurancePolicyEffectiveDate\":\"2018-11-01\",\"basePremiumAmount\":1000.21,\"" \
                  "addOnPremiumAmount\":100.52,\"totalPremiumAmount\":1110.73,\"" \
                  "policyMaturityDate\":\"2028-11-01'\",\"legalAgreementFlag\":true,\"" \
                  "firstPremiumDueDate\":\"2018-10-05'\"},\"offerDetails\":{\"waveId\":987654321,\"" \
                  "campaignId\":123456789,\"offerId\":111000125},\"riderDetails\":{\"riderCode\":\"TP1\",\"" \
                  "riderSumAssuredAmount\":25000.11,\"riderTermType\":\"MONTHS\",\"riderTerm\":60,\"" \
                  "riderEffectiveDate\":1546214400000},\"applicant\":{\"name\":{\"salutation\":\"MR.\",\"" \
                  "givenName\":\"Javier\",\"middleName\":\"Perez\",\"surname\":\"de Cuellar\"},\"" \
                  "identificationDocumentDetails\":{\"idType\":\"PASSPORT\",\"" \
                  "idNumber\":\"Passport- 443431, CIN- 123123123\"},\"demographics\":{\"gender\":\"MALE\",\"" \
                  "dateOfBirth\":\"1980-01-01\",\"maritalStatus\":\"SINGLE\",\"nationality\":\"SG\"},\"" \
                  "employmentDetails\":{\"occupationCode\":\"ACCOUNTANT\",\"businessNature\":\"BANKING\"},\"" \
                  "ownershipType\":\"OWNER\",\"additionalData\":{\"relationshipWithPrimary\":\"HUSBAND\"},\"" \
                  "email\":{\"emailAddress\":\"[email protected]\"},\"" \
                  "address\":{\"addressLine1\":\"40A Orchard Road\",\"addressLine2\":\"#99-99 Macdonald House\",\"" \
                  "addressLine3\":\"Orchard Avenue 2\",\"addressLine4\":\"Street 65\",\"cityName\":\"Singapore\",\"" \
                  "state\":\"SINGAPORE\",\"postalCode\":520189},\"phone\":{\"phoneCountryCode\":\"65\"}},\"" \
                  "initialPaymentDetails\":{\"sourceAccountId\":\"aa\"},\"" \
                  "premiumSourceAccount\":{\"sourceAccountId\":\"aa\"},\"" \
                  "beneficiary\":{\"identificationDocumentDetails\":{\"idType\":\"PASSPORT\",\"" \
                  "idNumber\":\"Passport- 443431, CIN- 123123123\"},\"name\":{\"salutation\":\"MR.\",\"" \
                  "givenName\":\"Javier\",\"middleName\":\"Perez\",\"surname\":\"de Cuellar\"},\"" \
                  "demographics\":{\"gender\":\"MALE\",\"dateOfBirth\":\"1980-01-01\",\"" \
                  "maritalStatus\":\"SINGLE\",\"nationality\":\"SG\"},\"" \
                  "employmentDetails\":{\"occupationCode\":\"ACCOUNTANT\",\"" \
                  "businessNature\":\"BANKING\"},\"additionalData\":{\"relationshipWithPrimary\":\"HUSBAND\"}},\"" \
                  "questionnaire\":{\"questionId\":1,\"answerText\":\"Yes or No\",\"remarks\":\"Health Declartion1\"}}"

        headers = {
            'authorization': "Bearer %s" % access_token,
            'uuid': str(uuid.uuid1()),
            'client_id': Global.get_client_id(),
            'clientdetails': "REPLACE_THIS_VALUE",
            'content-type': "application/json",
            'accept': "application/json"
        }

        conn.request("POST", "/gcb/api/v1/insurance/bookings", payload,
                     headers)

        res = conn.getresponse()
        data = res.read()

        print(data.decode("utf-8"))
        print('ss')
Exemplo n.º 8
0
    def get_valid_values(value):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")

        headers = {
            'authorization': "Bearer %s" % Global.get_2_foot_token(),
            'uuid': str(uuid.uuid1()),
            'client_id': Global.get_client_id(),
            'accept': "application/json"
        }

        conn.request("GET",
                     "/gcb/api/v1/apac/utilities/referenceData/%s" % value,
                     headers=headers)

        res = conn.getresponse()
        data = res.read()

        json_str = data.decode("utf-8")

        print(json_str)
Exemplo n.º 9
0
    def metadata_inquiry(api_uri, api_method):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")

        headers = {
            'authorization': "Bearer %s" % Global.get_2_foot_token(),
            'uuid': str(uuid.uuid1()),
            'client_id': Global.get_client_id(),
            'accept': "application/json"
        }

        conn.request("GET",
                     "/gcb/api/v1/utilities/metaData?apiUri=%s&apiMethod=%s" %
                     (api_uri, api_method),
                     headers=headers)

        res = conn.getresponse()
        data = res.read()

        json_str = data.decode("utf-8")
        # dict = json.loads(json_str)
        print(json_str)
Exemplo n.º 10
0
    def refresh_access_token():
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")

        payload = "grant_type=refresh_token&refresh_token=%s" % Global.get_refresh_token(
        )

        headers = {
            'authorization': "Basic %s" % Global.get_pressed_id_secret_pair(),
            'content-type': "application/x-www-form-urlencoded",
            'accept': "application/json"
        }

        conn.request("POST", "/gcb/api/authCode/oauth2/refresh", payload,
                     headers)

        res = conn.getresponse()
        data = res.read()

        json_str = data.decode("utf-8")
        dict = json.loads(json_str)

        print(data.decode("utf-8"))
Exemplo n.º 11
0
    def insurance_source_account_eligibility(access_token):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")
        headers = {
            'authorization': "Bearer %s" % access_token,
            'uuid': str(uuid.uuid1()),
            'client_id': Global.get_client_id(),
            'clientdetails': "REPLACE_THIS_VALUE",
            'accept': "application/json"
        }

        conn.request("GET",
                     "/gcb/api/v1/insurance/bookings/sourceAccounts",
                     headers=headers)

        res = conn.getresponse()
        data = res.read()

        print(data.decode("utf-8"))
Exemplo n.º 12
0
    def confirm_personal_transfer(control_flow_id, access_token):
        conn = http.client.HTTPSConnection("sandbox.apihub.citi.com")
        payload = "{\"controlFlowId\":\"%s\"}" % control_flow_id

        headers = {
            'authorization': "Bearer %s" % access_token,
            'uuid': str(uuid.uuid1()),
            'client_id': Global.get_client_id(),
            'content-type': "application/json",
            'accept': "application/json"
        }

        conn.request("POST",
                     "/gcb/api/v1/moneyMovement/personalDomesticTransfers",
                     payload, headers)

        res = conn.getresponse()
        data = res.read()

        print(data.decode("utf-8"))