def set_payment_method(subscription_code, method): if str(method).upper() not in ('CREDIT_CARD', 'BOLETO'): return response_factory( 400, {'error': 'The payment method must be "CREDIT_CARD" or "BOLETO"'}) return pyrequest( 'PUT', f'{SUBSCRIPTION_PATH}/{subscription_code}/change_payment_method', json={'payment_method': method.upper()}, )
def preferences(url, email_merchant_enabled, customer_enabled): data = { 'notification': { 'webhook': { 'url': url }, 'email': { 'merchant': { 'enabled': email_merchant_enabled }, 'customer': { 'enabled': customer_enabled }, } } } return pyrequest('POST', '/assinaturas/v1/users/preferences', data)
def create(json): return pyrequest('POST', f'{ORDER_URL}/', json)
def remove(coupon_code): return pyrequest('DELETE', f'/assinaturas/v1/subscriptions/{coupon_code}/coupon')
def fetch_all(): return pyrequest('GET', COUPON_PATH)
def create(json): return pyrequest('POST', PLAN_PATH, json)
def fetch(plan_code): return pyrequest('GET', f'{PLAN_PATH}/{plan_code}')
def alter(customer_code, json): return pyrequest('PUT', f'{CUSTOMER_PATH}/{customer_code}', json)
def fetch_all(): return pyrequest('GET', SUBSCRIPTION_PATH)
def fetch(subscription_code): return pyrequest('GET', f'{SUBSCRIPTION_PATH}/{subscription_code}')
def add_credit_card(customer_id, json): return pyrequest('POST', f'{CUSTOMER_URL}/{customer_id}/fundinginstruments', json)
def create(json): return pyrequest('POST', f'{CUSTOMER_URL}/', json)
def remove_credit_card(creditcard_id): return pyrequest('DELETE', f'/v2/fundinginstruments/{creditcard_id}')
def fetch(customer_id): return pyrequest('GET', f'{CUSTOMER_URL}/{customer_id}')
def fetch(code): return pyrequest('GET', f'{ORDER_URL}/{code}')
def change_card(customer_code, json): return pyrequest('PUT', f'{CUSTOMER_PATH}/{customer_code}/billing_infos', json)
def create(json, new_vault=False): return pyrequest('POST', f'{CUSTOMER_PATH}?new_vault={new_vault}', json)
def set_status(subscription_code, status): message = 'The subscription status must be "suspend", "activate" or "cancel"' if str(status).lower() not in ('suspend', 'activate', 'cancel'): return response_factory(400, {'error': message}) return pyrequest('PUT', f'{SUBSCRIPTION_PATH}/{subscription_code}/{status}')
def inactivate(plan_code): return pyrequest('PUT', f'{PLAN_PATH}/{plan_code}/inactivate')
def alter(subscription_code, json): return pyrequest('PUT', f'{SUBSCRIPTION_PATH}/{subscription_code}', json)
def fetch_all(): return pyrequest('GET', PLAN_PATH)
def fetch_all_invoices(subscription_code): return pyrequest('GET', f'{SUBSCRIPTION_PATH}/{subscription_code}/invoices')
def alter(plan_code, json): return pyrequest('PUT', f'{PLAN_PATH}/{plan_code}', json)
def create(json, new_customer=False): return pyrequest('POST', f'{SUBSCRIPTION_PATH}?new_customer={new_customer}', json)
def fetch(coupon_code): return pyrequest('GET', f'{COUPON_PATH}/{coupon_code}')
def fetch(customer_code): return pyrequest('GET', f'{CUSTOMER_PATH}/{customer_code}')
def set_status(coupon_code, status): if str(status).lower() not in ('active', 'inactive'): return response_factory( 400, {'error': 'The coupon status must be "active" or "inactive"'}) return pyrequest('PUT', f'{COUPON_PATH}/{coupon_code}/{status}')
def fetch_all(): return pyrequest('GET', CUSTOMER_PATH)
def create(json): return pyrequest('POST', COUPON_PATH, json)
def fetch_all(): return pyrequest('GET', ORDER_URL)