class LibOrderFormGetCheckoutData(object):
    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def order_form_get_checkout_data(self,
                                     bag,
                                     email,
                                     token=None,
                                     hash_id=None):
        """ Add scooter into shopping cart
        Args:
            email (str): buyer email

        Return:
            resp: Return json object

        Examples:
            | Order Form Get Checkout Data | PAYLOAD |
        """
        self.init.auth(token, hash_id)
        data = {
            "Email": email,
        }
        resp = self.init.request(
            'get',
            '/order-form/get-checkout-data/{bag}'.format(bag=bag),
            json=data)
        return resp
Exemplo n.º 2
0
class LibAttachUpdateScooterPairingFlag(object):
    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def update_scooter_pairing_flag_post(self,
                                         order_no,
                                         scooter_allocation_flag,
                                         token=None):
        """ Add scooter into shopping cart
        Args:
            order_no (str): dms_order_no
            scooter_allocation_flag (int): 1 as 自動配車, 2 as 暫不配車
        
        Return:
            resp: Return json object

        Examples:
            | Update Scooter Pairing Flag Post | PAYLOAD |
        """
        self.init.auth(token)
        data = {
            "OrderNo": order_no,
            "ScooterAllocationFlag": scooter_allocation_flag,
        }
        resp = self.init.request('post',
                                 '/attach/update-scooter-pairing-flag',
                                 json=data)
        return resp
Exemplo n.º 3
0
    def __init__(self):
        self.init = LibBase()
        self.variable = LibVar()
        self._env = self.variable.get_var('ENV')

        if self._env != 'prod':
            self.init.sales_portal_cipher_get()
Exemplo n.º 4
0
class LibDiscountImportDiscountCoupons(object):
    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def import_discount_coupons_post(self,
                                     discount_plan_option_id=None,
                                     token=None,
                                     hash_id=None,
                                     coupon_code=None):
        """ Import discount coupons code by admin
        Args:
        Return:
            resp: Return json object

        Examples:
            | Import Discount Coupons Post | PAYLOAD |
        """
        self.init.auth(token, hash_id)
        data = {
            "DiscountPlanOptionsId": discount_plan_option_id,
            "CouponCode": [coupon_code]
        }
        resp = self.init.request('post',
                                 '/discount/import-discount-coupons',
                                 json=data)
        return resp
class LibDiscountGetDiscountList(object):

    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------
    def get_discount_list_post(self, discount_plan_main_id=None,
                               discount_plan_option_id=None, name=None,
                               code=None, offset=None, limit=None,
                               token=None, hash_id=None):
        """ Get info about telecom discount coupons
        Args:
        Return:
            resp: Return json object

        Examples:
            | Get Discount List Post | PAYLOAD |
        """
        self.init.auth(token, hash_id)
        data = {
            "DiscountPlanMainId": discount_plan_main_id,
            "DiscountPlanOptionsId": discount_plan_option_id,
            "Name": name,
            "Code": code,
            "PaginationCriteria": {
                "Offset": offset,
                "Limit": limit
            }
        }
        resp = self.init.request('post', '/discount/get-discount-list', json=data)
        return resp
class LibUtilityGetDpUserData(object):

    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------
    def utility_get_dp_user_data_post(self, email, phone, password=None, token=None):
        """ Add scooter into shopping cart
        Args:
            email (str): buyer email
            phone (str): buyer phone last 4 number

        Return:
            resp: Return json object

        Examples:
            | Utility Get Dp User Data Post | PAYLOAD |
        """
        self.init.auth(token)
        data = {
            "Email": email,
            "Password": password,
            "Phone": phone
        }
        resp = self.init.request('post', '/utility/get-dp-user-data', json=data)
        return resp
Exemplo n.º 7
0
class LibAccountLogin(object):
    def __init__(self):
        self.init = LibBase()
        self.variable = LibVar()
        self._env = self.variable.get_var('ENV')

        if self._env != 'prod':
            self.init.sales_portal_cipher_get()

# ---------------------------------------------------------------------------

    def account_login_post(self,
                           user_id,
                           password,
                           session_id=None,
                           recaptcha_response=None,
                           two_factor_source=0,
                           otp_code=None,
                           remember_device=True,
                           browser_info=None,
                           token=None):
        """login sales portal
        Args:
            user_id (str): sales account
            password (str): sales password
            two_factor_source (int): flag to check use 2FA login or not, default as 0
            otp_code (str): code for 2FA login
            remember_device (bool): flag to check next time login should use 2FA confirmation or not
            browser_info (str): record browser type

        Return:
            resp: Return json object

        Examples:
            | Account Login Post | PAYLOAD |
        """
        data = {
            "UserID": user_id,
            "Password": password,
            "SessionId": session_id,
            "RecaptchaResponse": recaptcha_response,
            "TwoFactorSource": two_factor_source,
            "OtpCode": otp_code,
            "RememberDevice": remember_device,
            "BrowserInfo": browser_info
        }
        resp = self.init.request('post', '/account/login', json=data)
        return resp
class LibScooterList(object):
    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def scooter_list_get(self, token=None, hash_id=None):
        """ Get scooter list with detail information
        Return:
            resp: Return json object

        Examples:
            | Scooter List Get |
        """
        self.init.auth(token, hash_id)

        resp = self.init.request('get', '/scooter/list')
        return resp
class LibUtilityTestOrderOpeningInvoice(object):

    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------
    def utility_test_order_opening_invoice_get(self, order_no, token=None):
        """ Add scooter into shopping cart
        Args:
            OrderNo (str): dms_order_no

        Return:
            resp: Return json object

        Examples:
            | Utility Test Order Opening Invoice Get | PAYLOAD |
        """
        self.init.auth(token)

        resp = self.init.request('get', '/utility/test-order-opening-invoice?OrderNo={}'.format(order_no))
        return resp
class LibUtilityTestOrderInfo(object):
    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def utility_test_order_info_get(self, order_no, token=None):
        """ Get scooter order invoice detail
        Args:
            OrderNo (str): dms_order_no

        Return:
            resp: Return json object

        Examples:
            | Utility Test Order Info Get | PAYLOAD |
        """
        self.init.auth(token)

        resp = self.init.request(
            'get', '/utility/test-order-info?OrderNo={}'.format(order_no))
        return resp
Exemplo n.º 11
0
class LibGetOrderData(object):
    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def order_data_get(self, order_no, token=None):
        """ Get order detail
        Args:
            OrderNo (str): dms_order_no

        Return:
            resp: Return json object

        Examples:
            | Order Data Get | PAYLOAD |
        """
        self.init.auth(token)

        resp = self.init.request(
            'get', '/order-form/get-order-data/{}'.format(order_no))
        return resp
class LibUtilityTestOrderUpdateInvoiceOpened(object):
    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def utility_test_order_update_invoice_opened_post(self,
                                                      order_store_id,
                                                      invoice_name,
                                                      order_no,
                                                      total_amt,
                                                      tc_order_no,
                                                      invoice_no,
                                                      token=None):
        """ Make invoice status from 待開立 to 已開立
        Args:
            OrderNo (str): dms_order_no

        Return:
            resp: Return json object

        Examples:
            | Utility Test Order Update Invoice Opened Post | PAYLOAD |
        """
        self.init.auth(token)
        today = datetime.datetime.today()
        today_str = today.strftime("%Y/%m/%d")
        time_str = today.strftime("%H:%M:%S")

        data = {
            "result": {
                "details": [{
                    "data": {
                        "dealer_id":
                        "1500",
                        "order_store_id":
                        order_store_id,
                        "plan_order_store_id":
                        "",
                        "order_type":
                        "01",
                        "order_name":
                        invoice_name,
                        "order_no":
                        order_no,
                        "order_line":
                        "002",
                        "order_date":
                        today_str,
                        "order_time":
                        "00:00",
                        "total_amt":
                        total_amt,
                        "trans_type":
                        "W1",
                        "receipt_type":
                        "P1",
                        "sell_invoice":
                        invoice_no,
                        "sell_invoice_tax_amt":
                        5951,
                        "inv_day":
                        today_str,
                        "inv_time":
                        time_str,
                        "comp_id":
                        "00000064",
                        "eui_vehicle_no":
                        "",
                        "eui_random_code":
                        "4560",
                        "eui_print":
                        "1",
                        "eui_print_trans":
                        "0",
                        "eui_donate_no":
                        "",
                        "eui_donate_status":
                        "0",
                        "eui_vehicle_type_no":
                        "",
                        "tc_order_no":
                        tc_order_no,  #SP20200302D00000025
                        "order_products": [{
                            "product_id": "GSACK-000-VG",
                            "product_name": "GA7CK",
                            "tax_flag": "1",
                            "qty": 1,
                            "ori_price": 131980,
                            "ori_amt": 131980,
                            "price": 131980,
                            "amt": 131980,
                            "tax_amt": 6285
                        }, {
                            "product_id": "TES000001",
                            "product_name": "GA7CK-餘額",
                            "tax_flag": "1",
                            "qty": 1,
                            "ori_price": -7000,
                            "ori_amt": -7000,
                            "price": -7000,
                            "amt": -7000,
                            "tax_amt": -333
                        }],
                        "tender_detail": [{
                            "tender_no": "10",
                            "tender_price": total_amt,
                            "extra_price": 0,
                            "sec_no": "",
                            "credit_card_detail": {
                                "tx_amount": total_amt,
                                "card_no": "",
                                "periods": 0,
                                "bonus_use_point": 0,
                                "bonus_point": 0,
                                "bonus_dis_amt": 0
                            }
                        }]
                    }
                }]
            }
        }

        resp = self.init.request('post',
                                 '/utility/test-order-update-invoice-opened',
                                 json=data)
        return resp
Exemplo n.º 13
0
class LibShoppingCartScooterAddToCart(object):

    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------
    def _get_product_information_payload(self, product_name):
        """ Get scooter detail information payload
        Args:
            product_name (str): default product_list

        Returns:
            dict: The return value
        """
        products = {
            "Gogoro VIVA":
            [
                shopping_cart_gogoroviva
            ],
            "Gogoro S2 Café Racer":
            [
                shopping_cart_gogoros2caferacer
            ],
            "Gogoro S2 Café Racer+Anti slip mat":
            [
                shopping_cart_gogoros2caferacer,
                shopping_cart_anti_slip_mat
            ],
            "Gogoro S2 Café Racer+Light sensor":
            [
                shopping_cart_gogoros2caferacer,
                shopping_cart_light_sensor
            ],
            "Gogoro 2 Delight":
            [
                shopping_cart_gogoro2delight
            ],
            "Gogoro 2 Delight+Anti slip mat":
            [
                shopping_cart_gogoro2delight,
                shopping_cart_anti_slip_mat
            ],
            "Gogoro 2 Delight+Light sensor":
            [
                shopping_cart_gogoro2delight,
                shopping_cart_light_sensor
            ],
            "Gogoro 2 Rumbler":
            [
                shopping_cart_gogoro2rumbler
            ],
            "Gogoro 2 Rumbler+Anti slip mat":
            [
                shopping_cart_gogoro2rumbler,
                shopping_cart_anti_slip_mat
            ],
            "Gogoro 2 Rumbler+Light sensor":
            [
                shopping_cart_gogoro2rumbler,
                shopping_cart_light_sensor
            ]
        }
        return products[product_name]

    def shopping_cart_scooter_add_to_cart_post(self, product_name='Gogoro S2 Café Racer', t_shirt=None, badge=None,
                                                badge_type='A', student_plan='N', payment_method=1, token=None):
        """ Add scooter into shopping cart
        Args:
            product_no (str): scooter type code
            product_main_id (str): scooter model id
            product_color_id (str): scooter color id
            order_type (int): 1 is scooter (default)
            payment_method (int): 1 is cash, 2 is loan

        Returns:
            resp: Return json object
            hash_id: Return cart information in cookies

        Examples:
            | Shopping Cart Scooter Add To Cart Post | PAYLOAD |
        """
        self.init.auth(token)
        product = self._get_product_information_payload(product_name)

        data = {
            "Product": product,
            "TShirt": t_shirt,
            "Badge": badge,
            "BadgeType": badge_type,
            "StudentPlan": student_plan,
            "PaymentMethod": payment_method
        }
        data = self.init.dict_to_json_string(data)
        data = {
            "jsonData": data
        }
        print(data)
        resp = self.init.request('post', '/shopping-cart/scooter-add-to-cart', json=data)

        print(resp.headers['Set-Cookie'])
        hash_id = re.findall("HashId=[\w\S]+", resp.headers['Set-Cookie'])[0]

        return resp, hash_id
class LibScooterAutoPairing(object):
    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def get_scooter_pair_result_detail_post(self,
                                            order_no,
                                            start_date,
                                            end_date,
                                            company_id=None,
                                            department_id=None,
                                            allocation_failure_reason=0,
                                            offset=0,
                                            limit=200,
                                            token=None,
                                            hash_id=None):
        """ Get assign scooter order scooter pairing result from group admin
        Args:
            order_no   (str): dms_order_no
            start_date (str): Example Format
            - 2020-03-16T07:57:02.197Z
            - 2020-03-18
            end_date   (str): Same format with start_date, to describe the interval of pairing result

        Return:
            resp: Return json object

        Examples:
            | Get Scooter Pair Result Detail Post | PAYLOAD |
        """
        self.init.auth(token, hash_id)
        data = {
            "OrderNo": order_no,
            "CompanyId": company_id,
            "DepartmentId": department_id,
            "IsDraft": True,
            "AllocationFailureReason": allocation_failure_reason,
            "StartDate": start_date,
            "EndDate": end_date,
            "PaginationCriteria": {
                "Offset": offset,
                "Limit": limit
            }
        }
        resp = self.init.request(
            'post',
            '/scooter-auto-pairing/get-scooter-pair-result-detail',
            json=data)
        return resp

    def get_scooter_pair_result_master_post(self,
                                            start_date,
                                            end_date,
                                            company_id=None,
                                            pairing_id=None,
                                            offset=0,
                                            limit=200,
                                            token=None,
                                            hash_id=None):
        """ Get whole scooter pairing result from group admin
        Args:
            start_date (str): Example Format
            - 2020-03-16T07:57:02.197Z
            - 2020-03-18
            end_date   (str): Same format with start_date, to describe the interval of pairing result

        Return:
            resp: Return json object

        Examples:
            | Get Scooter Pair Result Master Post | PAYLOAD |
        """
        self.init.auth(token, hash_id)
        data = {
            "StartDate": start_date,
            "EndDate": end_date,
            "CompanyId": company_id,
            "Id": pairing_id,
            "IsDraft": True,
            "PaginationCriteria": {
                "Offset": offset,
                "Limit": limit
            }
        }
        resp = self.init.request(
            'post',
            '/scooter-auto-pairing/get-scooter-pair-result-master',
            json=data)
        return resp
Exemplo n.º 15
0
class LibShoppingCartModifyOrder(object):
    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def _get_loan_payment(self, payment_type='2'):
        """ Get scooter payment detail information payload
        Args:
            payment_type (str): 2 is cash, 3 is loan

        Returns:
            dict: The return value
        """
        loan_payments = {"2": {}, "3": loan}
        return loan_payments[payment_type]

    def _get_scooter_information_payload(self, scooter_model='Gogoro VIVA'):
        """ Get scooter detail information payload
        Args:
            scooter_model (str): default with Gogoro VIVA

        Returns:
            dict: The return value
        """
        products = {
            "Accessories": [
                accessory_keychain, accessory_mat, agency_serivce_fee,
                gogoros2caferacer
            ],
            "Gogoro VIVA": [agency_serivce_fee, gogoroviva],
            "Gogoro S2 Cafe Racer": [agency_serivce_fee, gogoros2caferacer],
            "Legal Entity": [gogoros2caferacer_discount],
            "Legal_Entity+Gogoro 2 Delight+Anti slip mat":
            [accessory_mat_discount, gogoro2delight_discount],
            "Legal_Entity+Gogoro 2 Delight+Light sensor":
            [light_sensor_discount, gogoro2delight_discount],
            "Legal_Entity+Gogoro 2 Rumbler+Light sensor":
            [light_sensor_discount, gogoro2rumbler_discount],
            "Legal_Entity+GogoroS2CaféRacer+Anti slip mat":
            [accessory_mat_discount, gogoros2caferacer_discount]
        }
        return products[scooter_model]

    def shopping_cart_modify_order_post(self,
                                        order_no,
                                        order_type,
                                        sales_channel_no,
                                        owner_email,
                                        owner_name,
                                        owner_gender,
                                        owner_profile_id,
                                        owner_mobile,
                                        owner_birthday,
                                        owner_city,
                                        owner_district,
                                        owner_zipcode,
                                        owner_address,
                                        licensing_location,
                                        licensing_location_id,
                                        license_type,
                                        payment_type,
                                        is_payment_change,
                                        document_fee_payer,
                                        scooter_model,
                                        agency_fees=-1,
                                        is_receive_award=-1,
                                        token=None,
                                        hash_id=None):
        """ Update scooter order information in shopping cart
        Args:
        Returns:
            resp: Return json object
        Examples:
            | Shopping Cart Modify Order Post | PAYLOAD |
        """
        self.init.auth(token, hash_id)

        products = [documentation_fee]
        products += self._get_scooter_information_payload(scooter_model)
        payments = self._get_loan_payment(payment_type)

        data = {
            "Bag":
            1,
            "UserId":
            None,
            "OrderNo":
            order_no,
            "OrderType":
            order_type,
            "SalesChannelNo":
            sales_channel_no,
            "SalesChannelName":
            None,
            "SalesStoreNo":
            None,
            "SalesStoreName":
            None,
            "DiscountPlanId":
            None,
            "EmployeeNo":
            None,
            "CheckEmployeeNo":
            None,
            "Recommended":
            None,
            "Remark":
            None,
            "Invoice": {
                "Numbers": None,
                "GUINumbers": None,
                "Donation": None,
                "DonationNumbers": None,
                "Date": None
            },
            "Discount": [],
            "ProjectActivity": [{
                "ProjectCode": "EVT217",
                "ProjectName": "購買 Gogoro 全車系贈送 Gogoro 極輕都會風雨衣",
                "ProjectDescription": "購買 Gogoro 全車系贈送 Gogoro 極輕都會風雨衣",
                "Remark": None,
                "Product": [],
                "Delivery": {}
            }],
            "Buyer": {
                "Email": None,
                "Name": None,
                "Gender": -1,
                "Mobile": None,
                "City": None,
                "CityId": None,
                "District": None,
                "DistrictId": None,
                "ZipCode": None,
                "Address": None
            },
            "Owner": {
                "Email": owner_email,
                "Name": owner_name,
                "Gender": owner_gender,
                "IDCard": owner_profile_id,
                "Mobile": owner_mobile,
                "Birthday": owner_birthday,
                "City": owner_city,
                "CityId": None,
                "District": owner_district,
                "DistrictId": None,
                "ZipCode": owner_zipcode,
                "Address": owner_address,
                "CivilServants": 0,
                "PurchaseMethod": 0
            },
            "Driver": {
                "Name": owner_name,
                "Email": owner_email
            },
            "Deliveries": {},
            "DeliveryConditions": {
                "Type": -1,
                "StoreId": None
            },
            "Scooter": {
                "PDIStoreId": None,
                "PairingAccount": None,
                "PairingUserId": None,
                "SingingDay": None,
                "SubsidyType": -1,
                "SubsidyApplication": -1,
                "SubsidyCounty": None,
                "BeDeprecatedSamePerson": -1,
                "Subsidy": {
                    "TesSubsidyTypeId": 1,
                    "LocalSubsidyTypeId": 2003,
                    "IsTES": True,
                    "IsEPA": True,
                    "IsEPB": True
                },
                "Licensing": {
                    "LicensingStatus": 1,
                    "LicensingLocation": licensing_location,
                    "LicensingLocationId": licensing_location_id,
                    "InsuredYears": 2,
                    "Stamp": 1,
                    "ChooseLicensing": 0,
                    "ChooseRemark": None,
                    "AgencyFees": agency_fees
                },
                "LicenseType": license_type
            },
            "Payment": {
                "Type": payment_type,
                "IsPaymentChange": is_payment_change,
                "cash": {},
                "loan": payments
            },
            "Contract": {
                "InvoicesGUINumbers": None,
                "InvoicesTitle": None
            },
            "Recommend": {},
            "IsReceiveAward":
            is_receive_award,
            "DocumentFeePayer":
            document_fee_payer,
            "ProductList": [{
                "Id": "00000000-0000-0000-0000-000000000000",
                "Name": "",
                "Type": 0,
                "Descriptions": None,
                "Product": products
            }]
        }
        print(data)
        resp = self.init.request('post',
                                 '/shopping-cart/modify-order',
                                 json=data)
        return resp
Exemplo n.º 16
0
 def __init__(self):
     self.init = LibBase()
class LibShoppingCartCheckout(object):

    def __init__(self):
        self.init = LibBase()

# ---------------------------------------------------------------------------

    def _get_licensing_payload(self, licensing_location, licensing_location_id, agency_fee, plate_type='gogoro_plate'):
        """ Get sales portal's licensing payload
        Args:
            plate_type (str): gogoro_plate is 代領牌, self_plate is 自領牌

        Returns:
            dict: The return value
        """
        licensing = {
            "gogoro_plate": {
                "LicensingStatus": 1,
                "LicensingLocation": licensing_location,
                "LicensingLocationId": licensing_location_id,
                "InsuredYears": 2,
                "Stamp": 1,
                "ChooseLicensing": 0,
                "ChooseRemark": None,
                "AgencyFees": agency_fee
            },
            "self_plate": {
                "LicensingStatus": 2,
                "LicensingLocation": licensing_location,
                "LicensingLocationId": licensing_location_id,
                "InsuredYears": 0,
                "Stamp": 0,
                "ChooseLicensing": 0,
                "ChooseRemark": None,
                "AgencyFees": 0
            }
        }
        return licensing[plate_type]

    def _get_payment_type(self, payment_type='cash'):
        """ Get sales portal's payment type and information
        Args:
            payment_type (str): cash is 現金, loan is 貸款, credit_card is 信用卡刷卡

        Return:
            dict: The return value
        """
        payment = {
            "cash": {
                "Type": 2,
                "CreditCard": {},
                "Cash": {},
                "Loan": {},
                "Receivables": {},
                "IsPaymentChange": 0
            },
            "loan": {
                "Type": 3,
                "IsPaymentChange": 0,
                "Loan": {
                    "Amount": 52380,
                    "DownPayment": 1000,
                    "LoanId": "80607612",
                    "LoanCompany": "遠信國際租賃股份有限公司",
                    "Interest": 1,
                    "CoSigner": 0,
                    "IsBorrowerSameOwner": True,
                    "Period": 6,
                    "InterestRate": 2.5,
                    "PeriodAmount": 8954,
                    "PeriodIndex": 0
                }
            },
            "card": {
                "Type": 1,
                "CreditCard": {
                    "Type": 3,
                    "Amount": 109200,
                    "Period": 0,
                    "Month": "12",
                    "Year": "2028",
                    "SecurityCode": "541",
                    "CardNo": 4938170188888994
                }
            }
        }
        return payment[payment_type]

    def _get_scooter_payload(self, pdi_store_id, pairing_account, pairing_user_guid, sing_date,
                                subsidy_city, tes_subsidy_type_id, local_subsidy_type_id, license_type,
                                licensing, subsidy_type, is_tes, is_epa, is_epb, scooter_type='normal'):
        """ Get sales portal's scooter payload
        Args:
            scooter_type (str): normal is 一般購車, legal_entity is 法人贈車

        Returns:
            dict: The return value
        """
        if local_subsidy_type_id:
            local_subsidy_type_id = int(local_subsidy_type_id)
        scooter = {
            "normal": {
                "PDIStoreId": pdi_store_id,
                "PairingAccount": pairing_account,
                "PairingUserId": pairing_user_guid,
                "SingingDay": sing_date,
                "SubsidyType": subsidy_type,
                "SubsidyApplication": 2,
                "SubsidyCounty": subsidy_city,
                "BeDeprecatedSamePerson": 1,
                "Subsidy": {
                    "TesSubsidyTypeId": int(tes_subsidy_type_id),
                    "LocalSubsidyTypeId": local_subsidy_type_id,
                    "IsTES": is_tes,
                    "IsEPA": is_epa,
                    "IsEPB": is_epb
                },
                "Licensing": licensing,
                "LicenseType": license_type
            },
            "legal_entity":   {
                "PDIStoreId": pdi_store_id,
                "PairingAccount": pairing_account,
                "PairingUserId": pairing_user_guid,
                "SingingDay": sing_date,
                "SubsidyType": 1,
                "SubsidyApplication": 1,
                "SubsidyCounty": "",
                "BeDeprecatedSamePerson": 1,
                "Subsidy": {
                    "TesSubsidyTypeId": 2,
                    "LocalSubsidyTypeId": None,
                    "IsTES": is_tes,
                    "IsEPA": is_epa,
                    "IsEPB": is_epb
                },
                "Licensing": licensing,
                "LicenseType": license_type
            }
        }
        return scooter[scooter_type]

    def shopping_cart_checkout_post(self, user_id, employee_no, buyer_email, buyer_name, buyer_gender, buyer_phone, buyer_city,
                                        buyer_district, buyer_zipcode, buyer_address, owner_email, owner_name, owner_gender,
                                        owner_profile_id, owner_phone, owner_birthday, owner_city, owner_district,
                                        owner_zipcode, owner_address, driver_name, driver_email, sales_channel_no, 
                                        sales_channel_name, invoice_number, invoice_date, store_id, pdi_store_id,
                                        pairing_user_guid, sing_date, subsidy_city, tes_subsidy_type_id, local_subsidy_type_id,
                                        licensing_location, licensing_location_id, agency_fee, license_type, order_type,
                                        scooter_type='normal', plate_type='1', document_payer=1, payment_type='cash',
                                        subsidy_type=2, is_tes=True, is_epa=True, is_epb=True, token=None, hash_id=None):
        """ Add scooter into shopping cart
        Args:
            user_id (str): buyer guid
            employee_no (str): sales portal account
            store_id (str): department code
            pdi_store_id (str): department code
            pairing_user_guid (str): driver guid
            sing_date (str): driver birthday, format is YYYY-MM-dd
            tes_subsidy_type_id (int): reference mapping table
            local_subsidy_type_id (int): reference mapping table
            order_type (int): 1 = scooter order , 2 = legal entity order

        Returns:
            resp: Return json object

        Examples:
            | Shopping Cart Checkout Post | PAYLOAD |
        """
        self.init.auth(token, hash_id)
        licensing = self._get_licensing_payload(licensing_location, licensing_location_id, agency_fee, plate_type)
        payment = self._get_payment_type(payment_type)
        scooter = self._get_scooter_payload(pdi_store_id, driver_email, pairing_user_guid, sing_date, subsidy_city,
                                            tes_subsidy_type_id, local_subsidy_type_id, license_type, licensing,
                                            subsidy_type, is_tes, is_epa, is_epb, scooter_type)
        data = {
            "Bag": 1,
            "UserId": user_id,
            "OrderNo": None,
            "OrderType": order_type,
            "CustomerSource": 1,
            "SalesChannelNo": sales_channel_no,
            "SalesChannelName": sales_channel_name,
            "SalesStoreNo": None,
            "SalesStoreName": None,
            "DiscountPlanId": None,
            "EmployeeNo": employee_no,
            "CheckEmployeeNo": None,
            "Recommended": None,
            "Remark": None,
            "Invoice": {
                "Numbers": invoice_number,
                "GUINumbers": None,
                "Donation": None,
                "DonationNumbers": None,
                "Date": invoice_date
            },
            "Discount": [],
            "ProjectActivity": [
                {
                    "ProjectCode": "EVT217",
                    "ProjectName": "購買 Gogoro 全車系贈送 Gogoro 極輕都會風雨衣",
                    "ProjectDescription": "購買 Gogoro 全車系贈送 Gogoro 極輕都會風雨衣",
                    "Remark": None,
                    "Product": [],
                    "Delivery": {}
                },
                {
                    "ProjectCode": "EVT250",
                    "ProjectName": "Gogoro 3系列全新改款送藍牙耳機與安全帽",
                    "ProjectDescription": "Gogoro 3系列全新改款送藍牙耳機與安全帽",
                    "Remark": None,
                    "Product": [],
                    "Delivery": {}
                }
            ],
            "Buyer": {
                "Email": buyer_email,
                "Name": buyer_name,
                "Gender": int(buyer_gender),
                "Mobile": buyer_phone,
                "City": buyer_city,
                "CityId": None,
                "District": buyer_district,
                "DistrictId": None,
                "ZipCode": buyer_zipcode,
                "Address": buyer_address
            },
            "Owner": {
                "Email": owner_email,
                "Name": owner_name,
                "Gender": int(owner_gender),
                "IDCard": owner_profile_id,
                "Mobile": owner_phone,
                "Birthday": owner_birthday,
                "City": owner_city,
                "CityId": None,
                "District": owner_district,
                "DistrictId": None,
                "ZipCode": owner_zipcode,
                "Address": owner_address,
                "CivilServants": 0,
                "PurchaseMethod": 0
            },
            "Driver": {
                "Name": driver_name,
                "Email": driver_email
            },
            "Deliveries": {},
            "DeliveryConditions": {
                "Type": 2,
                "StoreId": store_id
            },
            "Scooter": scooter,
            "Payment": payment,
            "Contract": {},
            "Recommend": {},
            "IsReceiveAward": -1,
            "TestRide": 1,
            "DocumentFeePayer": document_payer
        }
        resp = self.init.request('post', '/shopping-cart/checkout', json=data)
        return resp