def set_organization(self, organization): """Set organization. Args: organization(instance): Organization object. """ self.organization = Organization()
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
def get_manual_reminder(self, resp): """Get manual reminder. Args: resp(dict): Response containing json object for manual reminder. Returns: instance: Manual reminders object. """ manualreminder = resp['manualreminder'] manualreminder_obj = ManualReminder() manualreminder_obj.set_manualreminder_id(manualreminder[\ 'manualreminder_id']) manualreminder_obj.set_type(manualreminder['type']) manualreminder_obj.set_subject(manualreminder['subject']) manualreminder_obj.set_body(manualreminder['body']) manualreminder_obj.set_cc_me(manualreminder['cc_me']) placeholders = resp['placeholders'] placeholders_obj = PlaceHolder() 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_name(value['name']) organization.set_value(value['value']) placeholders_obj.set_organization(organization) manualreminder_obj.set_placeholders(placeholders_obj) return manualreminder_obj
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
def get_organization(self, resp): """This method parses the given response and returns organization object. Args: resp(dict): Response containing json object for organization. """ organization = resp['organization'] organization_obj = Organization() organization_obj.set_organization_id(organization['organization_id']) organization_obj.set_name(organization['name']) organization_obj.set_is_default_org(organization['is_default_org']) organization_obj.set_user_role(organization['user_role']) organization_obj.set_account_created_date(organization[\ 'account_created_date']) organization_obj.set_time_zone(organization['time_zone']) organization_obj.set_language_code(organization['language_code']) organization_obj.set_date_format(organization['date_format']) organization_obj.set_field_separator(organization['field_separator']) organization_obj.set_fiscal_year_start_month(organization[\ 'fiscal_year_start_month']) organization_obj.set_contact_name(organization['contact_name']) organization_obj.set_industry_type(organization['industry_type']) organization_obj.set_industry_size(organization['industry_size']) organization_obj.set_company_id_label(organization['company_id_label']) organization_obj.set_company_id_value(organization['company_id_value']) organization_obj.set_tax_id_label(organization['tax_id_label']) organization_obj.set_tax_id_value(organization['tax_id_value']) organization_obj.set_currency_id(organization['currency_id']) organization_obj.set_currency_code(organization['currency_code']) organization_obj.set_currency_symbol(organization['currency_symbol']) organization_obj.set_currency_format(organization['currency_format']) organization_obj.set_price_precision(organization['price_precision']) address = organization['address'] address_obj = Address() address_obj.set_street_address1(address['street_address1']) address_obj.set_street_address2(address['street_address2']) address_obj.set_city(address['city']) address_obj.set_state(address['state']) address_obj.set_country(address['country']) address_obj.set_zip(address['zip']) organization_obj.set_address(address_obj) organization_obj.set_org_address(organization['org_address']) organization_obj.set_remit_to_address(organization['remit_to_address']) organization_obj.set_phone(organization['phone']) organization_obj.set_fax(organization['fax']) organization_obj.set_website(organization['website']) organization_obj.set_email(organization['email']) organization_obj.set_tax_basis(organization['tax_basis']) for value in organization['custom_fields']: custom_field = CustomField() custom_field.set_value(value['value']) custom_field.set_index(value['index']) custom_field.set_label(value['label']) organization_obj.set_custom_fields(custom_field) organization_obj.set_is_org_active(organization['is_org_active']) organization_obj.set_is_new_customer_custom_fields(organization[\ 'is_new_customer_custom_fields']) organization_obj.set_is_portal_enabled( organization['is_portal_enabled']) organization_obj.set_portal_name(organization['portal_name']) return organization_obj
def get_organizations(self, resp): """This message parses the given response and returns organizations list. Args: resp(dict): Response containing json object for organizations list. Returns: instance: Organizations list object. """ organizations_list = [] for value in resp['organizations']: organization = Organization() organization.set_organization_id(value['organization_id']) organization.set_name(value['name']) organization.set_contact_name(value['contact_name']) organization.set_email(value['email']) organization.set_is_default_org(value['is_default_org']) organization.set_version(value['version']) organization.set_plan_type(value['plan_type']) organization.set_tax_group_enabled(value['tax_group_enabled']) organization.set_plan_name(value['plan_name']) organization.set_plan_period(value['plan_period']) organization.set_language_code(value['language_code']) organization.set_fiscal_year_start_month(value[\ 'fiscal_year_start_month']) organization.set_account_created_date(value[\ 'account_created_date']) organization.set_account_created_date_formatted(value[\ 'account_created_date_formatted']) organization.set_time_zone(value['time_zone']) organization.set_is_org_active(value['is_org_active']) organization.set_currency_id(value['currency_id']) organization.set_currency_code(value['currency_code']) organization.set_currency_symbol(value['currency_symbol']) organization.set_currency_format(value['currency_format']) organization.set_price_precision(value['price_precision']) organizations_list.append(organization) return organizations_list
#Organization organization_id = organizations_api.get_organizations()[0].get_organization_id() # List organizations. print organizations_api.get_organizations() #Get organization print organizations_api.get(organization_id) #Create organization organization = Organization() organization.set_name("Jony and co") address = Address() address.set_street_address1("2/65") address.set_street_address2("vignesh plaza") address.set_city("MDU") address.set_state("TN") address.set_country("India") address.set_zip("322") organization.set_address(address) organization.set_industry_type("") organization.set_industry_size("") organization.set_fiscal_year_start_month("january") organization.set_currency_code("USD") organization.set_time_zone("Asia/Calcutta") organization.set_date_format("dd MMM yyyy")
def __init__(self): """Initialize parameters for placeholders address format.""" self.organization = Organization() self.customer = Customer()