示例#1
0
    def get_autoreminder(self, resp):
        """Get auto reminder.

        Args:
            resp(dict): Response containing json object for auto reminders 
                object.

        Returns:
            instance: Auto reminders object.

        """
        autoreminder = resp['autoreminder']
        autoreminder_obj = Autoreminder()
        autoreminder_obj.set_autoreminder_id(autoreminder['autoreminder_id'])
        autoreminder_obj.set_is_enabled(autoreminder['is_enabled'])
        autoreminder_obj.set_notification_type(autoreminder['type'])
        autoreminder_obj.set_address_type(autoreminder['address_type'])
        autoreminder_obj.set_number_of_days(autoreminder['number_of_days'])
        autoreminder_obj.set_subject(autoreminder['subject'])
        autoreminder_obj.set_body(autoreminder['body'])
        placeholders_obj = PlaceHolder()
        placeholders = resp['placeholders']
        for value in placeholders['Invoice']:
            invoice = Invoice()
            invoice.set_name(value['name'])
            invoice.set_value(value['value'])
            placeholders_obj.set_invoice(invoice)
        for value in placeholders['Customer']:
            customer = Customer()
            customer.set_name(value['name'])
            customer.set_value(value['value'])
            placeholders_obj.set_customer(customer)
        for value in placeholders['Organization']:
            organization = Organization()
            organization.set_value(value['value'])
            organization.set_name(value['name'])
            placeholders_obj.set_organization(organization)
        autoreminder_obj.set_placeholders(placeholders)
        return autoreminder_obj
示例#2
0
    def preference_list(self, resp):
        """This method parses the given response and returns preferneces 
            object.

        Args:
            resp(dict): Response containing json obejct for preferences.

        Returns:
            instance: Prefenreces object.

        Raises:
            Books Exception: If status is not '200' or '201'.

        """
        preferences = resp['preferences']
        preferences_list = PreferenceList()
        preference_obj = Preference()
        preference_obj.set_convert_to_invoice(preferences[\
        'convert_to_invoice'])
        preference_obj.set_attach_pdf_for_email(preferences[\
        'attach_pdf_for_email'])
        preference_obj.set_estimate_approval_status(preferences[\
        'estimate_approval_status'])
        preference_obj.set_notify_me_on_online_payment(preferences[\
        'notify_me_on_online_payment'])
        preference_obj.set_send_payment_receipt_acknowledgement(preferences[\
        'send_payment_receipt_acknowledgement'])
        preference_obj.set_auto_notify_recurring_invoice(preferences[\
        'auto_notify_recurring_invoice'])
        preference_obj.set_snail_mail_include_payment_stub(preferences[\
        'snail_mail_include_payment_stub'])
        preference_obj.set_is_show_powered_by(
            preferences['is_show_powered_by'])
        preference_obj.set_attach_expense_receipt_to_invoice(preferences[\
        'attach_expense_receipt_to_invoice'])
        preference_obj.set_is_estimate_enabled(preferences[\
        'is_estimate_enabled'])
        preference_obj.set_is_project_enabled(
            preferences['is_project_enabled'])
        preference_obj.set_is_purchaseorder_enabled(preferences[\
        'is_purchaseorder_enabled'])
        preference_obj.set_is_salesorder_enabled(preferences[\
        'is_salesorder_enabled'])
        preference_obj.set_is_pricebooks_enabled(preferences[\
        'is_pricebooks_enabled'])
        preference_obj.set_attach_payment_receipt_with_acknowledgement(\
        preferences['attach_payment_receipt_with_acknowledgement'])
        for value in preferences['auto_reminders']:
            auto_reminder = Autoreminder()
            auto_reminder.set_payment_reminder_id(value['payment_reminder_id'])
            auto_reminder.set_is_enabled(value['is_enabled'])
            auto_reminder.set_notification_type(value['notification_type'])
            auto_reminder.set_address_type(value['address_type'])
            auto_reminder.set_number_of_days(value['number_of_days'])
            auto_reminder.set_subject(value['subject'])
            auto_reminder.set_body(value['body'])
            preference_obj.set_auto_reminders(auto_reminder)
        terms = preferences['terms']
        terms_obj = Term()
        terms_obj.set_invoice_terms(terms['invoice_terms'])
        terms_obj.set_estimate_terms(terms['estimate_terms'])
        terms_obj.set_creditnote_terms(terms['creditnote_terms'])
        preference_obj.set_terms(terms_obj)
        address_formats_obj = AddressFormat()
        address_formats = preferences['address_formats']
        address_formats_obj.set_organization_address_format(address_formats[\
        'organization_address_format'])
        address_formats_obj.set_customer_address_format(address_formats[\
        'customer_address_format'])
        preference_obj.set_address_formats(address_formats_obj)
        preferences_list.set_preferences(preference_obj)
        custom_fields = resp['customfields']
        custom_fields_obj = CustomField()
        for value in custom_fields['invoice']:
            invoice = Invoice()
            invoice.set_index(value['index'])
            invoice.set_show_in_all_pdf(value['show_in_all_pdf'])
            invoice.set_label(value['label'])
            custom_fields_obj.set_invoice(invoice)
        for value in custom_fields['contact']:
            contact = Contact()
            contact.set_index(value['index'])
            contact.set_show_in_all_pdf(vlaue['show_in_all_pdf'])
            contact.set_label(value['label'])
            custom_fields_obj.set_contact(contact)
        for value in custom_fields['estimate']:
            estimate = Estimate()
            estimate.set_index(value['index'])
            estimate.set_show_in_all_pdf(value['show_in_all_pdf'])
            estimate.set_label(value['label'])
            custom_fields_obj.set_estimate(estimate)
        preferences_list.set_custom_fields(custom_fields_obj)
        placeholders_address_format = resp['placeholders_address_format']
        placeholders_address_format_obj = PlaceholderAddressFormat()
        for value in placeholders_address_format['organization']:
            organization = Organization()
            organization.set_value(value['value'])
            organization.set_name(value['name'])
            placeholders_address_format_obj.set_organization(organization)
        for value in placeholders_address_format['customer']:
            customer = Customer()
            customer.set_name(value['name'])
            customer.set_value(value['value'])
            placeholders_address_format_obj.set_customer(customer)
        preferences_list.set_placeholders_address_format(\
        placeholders_address_format_obj)
        return preferences_list
示例#3
0
    def get_autoreminders(self, resp):
        """This method parses the given response and returns autoreminders list.
        
        Args:
            resp(dict): Response containing json object for autoreminders.

        Returns:
            instance: Reminder list object.

        """
        autoreminders = AutoReminderList()
        for value in resp['autoreminders']:
            autoreminders_obj = Autoreminder()
            autoreminders_obj.set_autoreminder_id(value['autoreminder_id'])
            autoreminders_obj.set_is_enabled(value['is_enabled'])
            autoreminders_obj.set_notification_type(value['type'])
            autoreminders_obj.set_address_type(value['address_type'])
            autoreminders_obj.set_number_of_days(value['number_of_days'])
            autoreminders_obj.set_subject(value['subject'])
            autoreminders_obj.set_body(value['body'])
            autoreminders_obj.set_order(value['order'])
            autoreminders.set_auto_reminders(autoreminders_obj)
        return autoreminders
示例#4
0
#Delete opening balance

print settings_api.delete_opening_balance()
"""

#Auto payment reminder
auto_payment_reminder_id = settings_api.list_auto_payment_reminder().get_auto_reminders()[0].get_autoreminder_id()
#List auto payment reminder
"""
print settings_api.list_auto_payment_reminder()
"""
#Get an auto payment reminder
print settings_api.get_auto_payment_reminder(auto_payment_reminder_id)
"""
#Update an auto reminder
autoreminder = Autoreminder()
autoreminder.set_is_enabled(True)
autoreminder.set_notification_type('days_after_due_date')
autoreminder.set_address_type('remind_me')
autoreminder.set_number_of_days(3)
autoreminder.set_subject('hai')
autoreminder.set_body('Reminder')
print settings_api.update_auto_reminder(reminder_id, autoreminder)

"""
#List manual reminders
reminder_id = settings_api.list_manual_reminders().get_manual_reminders()[0].get_manualreminder_id()
"""
print settings_api.list_manual_reminders()
"""
#Get a manual reminder