Beispiel #1
0
    def get_estimate(self, response):
        """This method parses the given response and returns Estimate object.

        Args:
            response(dict): Response containing json object for estimate.

        Returns:
            instance: Estimate object.

        """
        estimate = Estimate()
        resp = response['estimate']
        estimate.set_estimate_id(resp['estimate_id'])
        estimate.set_estimate_number(resp['estimate_number'])
        estimate.set_date(resp['date'])
        estimate.set_reference_number(resp['reference_number'])
        estimate.set_status(resp['status'])
        estimate.set_customer_id(resp['customer_id'])
        estimate.set_customer_name(resp['customer_name'])
        estimate.set_contact_persons(resp['contact_persons'])
        estimate.set_currency_id(resp['currency_id'])
        estimate.set_currency_code(resp['currency_code'])
        estimate.set_exchange_rate(resp['exchange_rate'])
        estimate.set_expiry_date(resp['expiry_date'])
        estimate.set_discount(resp['discount'])
        estimate.set_is_discount_before_tax(resp['is_discount_before_tax'])
        estimate.set_discount_type(resp['discount_type'])
        line_items = resp['line_items']
        for value in line_items:
            line_item = LineItem()
            line_item.set_item_id(value['item_id'])
            line_item.set_line_item_id(value['line_item_id'])
            line_item.set_name(value['name'])
            line_item.set_description(value['description'])
            line_item.set_item_order(value['item_order'])
            line_item.set_bcy_rate(value['bcy_rate'])
            line_item.set_rate(value['rate'])
            line_item.set_quantity(value['quantity'])
            line_item.set_unit(value['unit'])
            line_item.set_discount(value['discount'])
            line_item.set_tax_id(value['tax_id'])
            line_item.set_tax_name(value['tax_name'])
            line_item.set_tax_type(value['tax_type'])
            line_item.set_tax_percentage(value['tax_percentage'])
            line_item.set_item_total(value['item_total'])
            estimate.set_line_items(line_item)
        estimate.set_shipping_charge(resp['shipping_charge'])
        estimate.set_adjustment(resp['adjustment'])
        estimate.set_adjustment_description(resp['adjustment_description'])
        estimate.set_sub_total(resp['sub_total'])
        estimate.set_total(resp['total'])
        estimate.set_tax_total(resp['tax_total'])
        estimate.set_price_precision(resp['price_precision'])
        taxes = resp['taxes']
        for value in taxes:
            tax = Tax()
            tax.set_tax_name(value['tax_name'])
            tax.set_tax_amount(value['tax_amount'])
            estimate.set_taxes(tax)
        billing_address = resp['billing_address']
        billing_address_object = Address()
        billing_address_object.set_address(billing_address['address'])
        billing_address_object.set_city(billing_address['city'])
        billing_address_object.set_state(billing_address['state'])
        billing_address_object.set_zip(billing_address['zip'])
        billing_address_object.set_country(billing_address['country'])
        billing_address_object.set_fax(billing_address['zip'])
        estimate.set_billing_address(billing_address_object)

        shipping_address = resp['shipping_address']
        shipping_address_object = Address()
        shipping_address_object.set_address(shipping_address['address'])
        shipping_address_object.set_city(shipping_address['city'])
        shipping_address_object.set_state(shipping_address['state'])
        shipping_address_object.set_zip(shipping_address['zip'])
        shipping_address_object.set_country(shipping_address['country'])
        shipping_address_object.set_fax(shipping_address['zip'])
        estimate.set_shipping_address(shipping_address_object)

        estimate.set_notes(resp['notes'])
        estimate.set_terms(resp['terms'])
        custom_fields = resp['custom_fields']
        for value in custom_fields:
            custom_field = CustomField()
            custom_field.set_index(value['index'])
            custom_field.set_show_on_pdf(value['show_on_pdf'])
            custom_field.set_value(value['value'])
            custom_field.set_label(value['label'])
            estimate.set_custom_fields(custom_field)
        estimate.set_template_id(resp['template_id'])
        estimate.set_template_name(resp['template_name'])
        estimate.set_created_time(resp['created_time'])
        estimate.set_last_modified_time(resp['last_modified_time'])
        estimate.set_salesperson_id(resp['salesperson_id'])
        estimate.set_salesperson_name(resp['salesperson_name'])
        return estimate
Beispiel #2
0
    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_contact(self, resp):
        """This method parses the given response and creates a contact object.

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

        Returns:
            instance: Contact object.
 
        """
        contact = Contact()
        response = resp['contact']
        contact.set_contact_id(response['contact_id'])
        contact.set_contact_name(response['contact_name'])
        contact.set_company_name(response['company_name'])
        contact.set_contact_salutation(response['contact_salutation'])
        contact.set_price_precision(response['price_precision'])
        contact.set_has_transaction(response['has_transaction'])
        contact.set_contact_type(response['contact_type'])
        contact.set_is_crm_customer(response['is_crm_customer'])
        contact.set_primary_contact_id(response['primary_contact_id'])
        contact.set_payment_terms(response['payment_terms'])
        contact.set_payment_terms_label(response['payment_terms_label'])
        contact.set_currency_id(response['currency_id'])
        contact.set_currency_code(response['currency_code'])
        contact.set_currency_symbol(response['currency_symbol'])
        contact.set_outstanding_receivable_amount(response[\
            'outstanding_receivable_amount'])
        contact.set_outstanding_receivable_amount_bcy(response[\
            'outstanding_receivable_amount_bcy'])
        contact.set_outstanding_payable_amount(response[\
            'outstanding_payable_amount'])
        contact.set_outstanding_payable_amount_bcy(response[\
            'outstanding_payable_amount_bcy'])
        contact.set_unused_credits_receivable_amount(response[\
            'unused_credits_receivable_amount'])
        contact.set_unused_credits_receivable_amount_bcy(response[\
            'unused_credits_receivable_amount_bcy'])
        contact.set_unused_credits_payable_amount(response[\
            'unused_credits_payable_amount'])
        contact.set_unused_credits_payable_amount_bcy(response[\
            'unused_credits_payable_amount_bcy'])
        contact.set_status(response['status'])
        contact.set_payment_reminder_enabled(response[\
            'payment_reminder_enabled'])

        for value in response['custom_fields']:
            custom_field = CustomField()
            custom_field.set_index(value['index'])
            custom_field.set_value(value['value'])
            custom_field.set_label(value['label'])
            contact_person.set_custom_fields(custom_field)
    
        billing_address = Address()
        billing_address.set_address(response['billing_address']['address'])
        billing_address.set_city(response['billing_address']['city'])
        billing_address.set_state(response['billing_address']['state'])
        billing_address.set_zip(response['billing_address']['zip'])
        billing_address.set_country(response['billing_address']['country'])
        billing_address.set_fax(response['billing_address']['fax'])
        contact.set_billing_address(billing_address)
    
        shipping_address = Address()
        shipping_address.set_address(response['shipping_address']['address'])
        shipping_address.set_city(response['shipping_address']['city'])
        shipping_address.set_state(response['shipping_address']['state'])
        shipping_address.set_zip(response['shipping_address']['zip'])
        shipping_address.set_country(response['shipping_address']['country'])
        shipping_address.set_fax(response['shipping_address']['fax'])
        contact.set_shipping_address(shipping_address)

        contact_persons = []
        for value in response['contact_persons']:
            contact_person = ContactPerson()
            contact_person.set_contact_person_id(value['contact_person_id'])
            contact_person.set_salutation(value['salutation'])
            contact_person.set_first_name(value['first_name'])
            contact_person.set_last_name(value['last_name'])
            contact_person.set_email(value['email'])
            contact_person.set_phone(value['phone'])
            contact_person.set_mobile(value['mobile'])
            contact_person.set_is_primary_contact(value['is_primary_contact'])
            contact_persons.append(contact_person)
        contact.set_contact_persons(contact_persons)
  
        default_templates = DefaultTemplate()
        default_templates.set_invoice_template_id(response[
            'default_templates']['invoice_template_id'])
        default_templates.set_invoice_template_name(response[\
            'default_templates']['invoice_template_name'])
        default_templates.set_estimate_template_id(response[\
            'default_templates']['estimate_template_id'])
        default_templates.set_estimate_template_name(response[\
            'default_templates']['estimate_template_name'])
        default_templates.set_creditnote_template_id(response[\
            'default_templates']['creditnote_template_id'])
        default_templates.set_creditnote_template_name(response[\
            'default_templates']['creditnote_template_name'])
        default_templates.set_invoice_email_template_id(response[\
            'default_templates']['invoice_email_template_id'])
        default_templates.set_invoice_email_template_name(response[\
            'default_templates']['invoice_email_template_name'])
        default_templates.set_estimate_email_template_id(response[\
            'default_templates']['estimate_email_template_id'])
        default_templates.set_estimate_email_template_name(response[\
            'default_templates']['estimate_email_template_name']) 
        default_templates.set_creditnote_email_template_id(response[\
            'default_templates']['creditnote_email_template_id'])
        default_templates.set_creditnote_email_template_name(response[\
            'default_templates']['creditnote_email_template_name'])
    
        contact.set_default_templates(default_templates)
        contact.set_notes(response['notes'])
        contact.set_created_time(response['created_time'])
        contact.set_last_modified_time(response['last_modified_time'])
        return contact
    def get(self,response):
        """This method parses the given response and returns Invoice object.

        Args:
            response(dict): Request containing json obect for invoices.

        Returns:
            instance: Invoice object.

        """
        invoice = response['invoice']
        invoice_object = Invoice()
        invoice_object.set_invoice_id(invoice['invoice_id'])
        invoice_object.set_invoice_number(invoice['invoice_number'])
        invoice_object.set_date(invoice['date'])
        invoice_object.set_status(invoice['status'])
        invoice_object.set_payment_terms(invoice['payment_terms'])
        invoice_object.set_payment_terms_label(invoice['payment_terms_label'])
        invoice_object.set_due_date(invoice['due_date'])
        invoice_object.set_payment_expected_date(invoice[\
        'payment_expected_date'])
        invoice_object.set_last_payment_date(invoice['last_payment_date'])
        invoice_object.set_reference_number(invoice['reference_number'])
        invoice_object.set_customer_id(invoice['customer_id'])
        invoice_object.set_customer_name(invoice['customer_name'])
        invoice_object.set_contact_persons(invoice['contact_persons'])
        invoice_object.set_currency_id(invoice['currency_id'])
        invoice_object.set_currency_code(invoice['currency_code'])
        invoice_object.set_exchange_rate(invoice['exchange_rate'])
        invoice_object.set_discount(invoice['discount'])
        invoice_object.set_is_discount_before_tax(invoice[\
        'is_discount_before_tax'])
        invoice_object.set_discount_type(invoice['discount_type'])
        invoice_object.set_recurring_invoice_id(invoice[\
        'recurring_invoice_id'])
        line_items = invoice['line_items']
        for value in line_items:
            line_item = LineItem()
            line_item.set_line_item_id(value['line_item_id'])
            line_item.set_item_id(value['item_id'])
            line_item.set_project_id(value['project_id'])
            line_item.set_time_entry_ids(value['time_entry_ids'])
            line_item.set_expense_id(value['expense_id'])
            line_item.set_expense_receipt_name(value['expense_receipt_name'])
            line_item.set_name(value['name'])
            line_item.set_description(value['description'])
            line_item.set_item_order(value['item_order'])
            line_item.set_bcy_rate(value['bcy_rate'])
            line_item.set_rate(value['rate'])
            line_item.set_quantity(value['quantity'])
            line_item.set_unit(value['unit'])
            line_item.set_discount(value['discount'])
            line_item.set_tax_id(value['tax_id'])
            line_item.set_tax_name(value['tax_name'])
            line_item.set_tax_type(value['tax_type'])
            line_item.set_tax_percentage(value['tax_percentage'])
            line_item.set_item_total(value['item_total'])
            invoice_object.set_line_items(line_item)
        invoice_object.set_shipping_charge(invoice['shipping_charge'])
        invoice_object.set_adjustment(invoice['adjustment'])
        invoice_object.set_adjustment_description(invoice[\
        'adjustment_description'])
        invoice_object.set_sub_total(invoice['sub_total'])
        invoice_object.set_tax_total(invoice['tax_total'])
        invoice_object.set_total(invoice['total'])
        taxes = invoice['taxes']
        for value in taxes:
            tax = Tax()
            tax.set_tax_name(value['tax_name'])
            tax.set_tax_amount(value['tax_amount'])
            invoice_object.set_taxes(tax)
        invoice_object.set_payment_reminder_enabled(invoice[\
        'payment_reminder_enabled'])
        invoice_object.set_payment_made(invoice['payment_made'])
        invoice_object.set_credits_applied(invoice['credits_applied'])
        invoice_object.set_tax_amount_withheld(invoice['tax_amount_withheld'])
        invoice_object.set_balance(invoice['balance'])
        invoice_object.set_write_off_amount(invoice['write_off_amount'])
        invoice_object.set_allow_partial_payments(invoice[\
        'allow_partial_payments'])
        invoice_object.set_price_precision(invoice['price_precision'])
        payment_gateways = invoice['payment_options']['payment_gateways']
        for value in payment_gateways:
            payment_gateway = PaymentGateway()
            payment_gateway.set_configured(value['configured'])
            payment_gateway.set_additional_field1(value['additional_field1'])
            payment_gateway.set_gateway_name(value['gateway_name'])
            invoice_object.set_payment_options(payment_gateway)
        invoice_object.set_is_emailed(invoice['is_emailed'])
        invoice_object.set_reminders_sent(invoice['reminders_sent'])
        invoice_object.set_last_reminder_sent_date(invoice[\
        'last_reminder_sent_date'])
        billing_address = invoice['billing_address']
        billing_address_object = Address()
        billing_address_object.set_address(billing_address['address'])
        billing_address_object.set_city(billing_address['city'])
        billing_address_object.set_state(billing_address['state'])
        billing_address_object.set_zip(billing_address['zip'])
        billing_address_object.set_country(billing_address['country'])
        billing_address_object.set_fax(billing_address['fax'])
        invoice_object.set_billing_address(billing_address_object)
     
        shipping_address = invoice['shipping_address']
        shipping_address_object = Address()
        shipping_address_object.set_address(shipping_address['address'])
        shipping_address_object.set_city(shipping_address['city'])
        shipping_address_object.set_state(shipping_address['state'])
        shipping_address_object.set_zip(shipping_address['zip'])
        shipping_address_object.set_country(shipping_address['country'])
        shipping_address_object.set_fax(shipping_address['fax'])
        invoice_object.set_shipping_address(shipping_address_object)
        invoice_object.set_notes(invoice['notes'])
        invoice_object.set_terms(invoice['terms'])
        custom_fields = invoice['custom_fields']
        for value in custom_fields:
            custom_field = CustomField() 
            custom_field.set_index(value['index'])
            custom_field.set_show_on_pdf(value['show_on_pdf'])
            custom_field.set_value(value['value'])
            custom_field.set_label(value['label'])
            invoice_object.set_custom_fields(custom_field)
        invoice_object.set_template_id(invoice['template_id'])
        invoice_object.set_template_name(invoice['template_name'])
        invoice_object.set_created_time(invoice['created_time'])
        invoice_object.set_last_modified_time(invoice['last_modified_time'])
        invoice_object.set_attachment_name(invoice['attachment_name'])
        invoice_object.set_can_send_in_mail(invoice['can_send_in_mail'])
        invoice_object.set_salesperson_id(invoice['salesperson_id'])
        invoice_object.set_salesperson_name(invoice['salesperson_name'])
  
        return invoice_object
Beispiel #5
0
    def get_contact(self, resp):
        """This method parses the given response and creates a contact object.

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

        Returns:
            instance: Contact object.

        """
        contact = Contact()
        response = resp['contact']
        contact.set_contact_id(response['contact_id'])
        contact.set_contact_name(response['contact_name'])
        contact.set_company_name(response['company_name'])
        contact.set_contact_salutation(response['contact_salutation'])
        contact.set_price_precision(response['price_precision'])
        contact.set_has_transaction(response['has_transaction'])
        contact.set_contact_type(response['contact_type'])
        contact.set_is_crm_customer(response['is_crm_customer'])
        contact.set_primary_contact_id(response['primary_contact_id'])
        contact.set_payment_terms(response['payment_terms'])
        contact.set_payment_terms_label(response['payment_terms_label'])
        contact.set_currency_id(response['currency_id'])
        contact.set_currency_code(response['currency_code'])
        contact.set_currency_symbol(response['currency_symbol'])
        contact.set_outstanding_receivable_amount(response[\
            'outstanding_receivable_amount'])
        contact.set_outstanding_receivable_amount_bcy(response[\
            'outstanding_receivable_amount_bcy'])
        contact.set_outstanding_payable_amount(response[\
            'outstanding_payable_amount'])
        contact.set_outstanding_payable_amount_bcy(response[\
            'outstanding_payable_amount_bcy'])
        contact.set_unused_credits_receivable_amount(response[\
            'unused_credits_receivable_amount'])
        contact.set_unused_credits_receivable_amount_bcy(response[\
            'unused_credits_receivable_amount_bcy'])
        contact.set_unused_credits_payable_amount(response[\
            'unused_credits_payable_amount'])
        contact.set_unused_credits_payable_amount_bcy(response[\
            'unused_credits_payable_amount_bcy'])
        contact.set_status(response['status'])
        contact.set_payment_reminder_enabled(response[\
            'payment_reminder_enabled'])

        for value in response['custom_fields']:
            custom_field = CustomField()
            custom_field.set_index(value['index'])
            custom_field.set_value(value['value'])
            custom_field.set_label(value['label'])
            contact.set_custom_fields(custom_field)

        billing_address = Address()
        billing_address.set_address(response['billing_address']['address'])
        billing_address.set_city(response['billing_address']['city'])
        billing_address.set_state(response['billing_address']['state'])
        billing_address.set_zip(response['billing_address']['zip'])
        billing_address.set_country(response['billing_address']['country'])
        billing_address.set_fax(response['billing_address']['fax'])
        contact.set_billing_address(billing_address)

        shipping_address = Address()
        shipping_address.set_address(response['shipping_address']['address'])
        shipping_address.set_city(response['shipping_address']['city'])
        shipping_address.set_state(response['shipping_address']['state'])
        shipping_address.set_zip(response['shipping_address']['zip'])
        shipping_address.set_country(response['shipping_address']['country'])
        shipping_address.set_fax(response['shipping_address']['fax'])
        contact.set_shipping_address(shipping_address)

        contact_persons = []
        for value in response['contact_persons']:
            contact_person = ContactPerson()
            contact_person.set_contact_person_id(value['contact_person_id'])
            contact_person.set_salutation(value['salutation'])
            contact_person.set_first_name(value['first_name'])
            contact_person.set_last_name(value['last_name'])
            contact_person.set_email(value['email'])
            contact_person.set_phone(value['phone'])
            contact_person.set_mobile(value['mobile'])
            contact_person.set_is_primary_contact(value['is_primary_contact'])
            contact_persons.append(contact_person)
        contact.set_contact_persons(contact_persons)

        default_templates = DefaultTemplate()
        default_templates.set_invoice_template_id(
            response['default_templates']['invoice_template_id'])
        default_templates.set_invoice_template_name(response[\
            'default_templates']['invoice_template_name'])
        default_templates.set_estimate_template_id(response[\
            'default_templates']['estimate_template_id'])
        default_templates.set_estimate_template_name(response[\
            'default_templates']['estimate_template_name'])
        default_templates.set_creditnote_template_id(response[\
            'default_templates']['creditnote_template_id'])
        default_templates.set_creditnote_template_name(response[\
            'default_templates']['creditnote_template_name'])
        default_templates.set_invoice_email_template_id(response[\
            'default_templates']['invoice_email_template_id'])
        default_templates.set_invoice_email_template_name(response[\
            'default_templates']['invoice_email_template_name'])
        default_templates.set_estimate_email_template_id(response[\
            'default_templates']['estimate_email_template_id'])
        default_templates.set_estimate_email_template_name(response[\
            'default_templates']['estimate_email_template_name'])
        default_templates.set_creditnote_email_template_id(response[\
            'default_templates']['creditnote_email_template_id'])
        default_templates.set_creditnote_email_template_name(response[\
            'default_templates']['creditnote_email_template_name'])

        contact.set_default_templates(default_templates)
        contact.set_notes(response['notes'])
        contact.set_created_time(response['created_time'])
        contact.set_last_modified_time(response['last_modified_time'])
        return contact
    def get(self, response):
        """This method parses the given response and returns Invoice object.

        Args:
            response(dict): Request containing json obect for invoices.

        Returns:
            instance: Invoice object.

        """
        invoice = response['invoice']
        invoice_object = Invoice()
        invoice_object.set_invoice_id(invoice['invoice_id'])
        invoice_object.set_invoice_number(invoice['invoice_number'])
        invoice_object.set_date(invoice['date'])
        invoice_object.set_status(invoice['status'])
        invoice_object.set_payment_terms(invoice['payment_terms'])
        invoice_object.set_payment_terms_label(invoice['payment_terms_label'])
        invoice_object.set_due_date(invoice['due_date'])
        invoice_object.set_payment_expected_date(invoice[\
        'payment_expected_date'])
        invoice_object.set_last_payment_date(invoice['last_payment_date'])
        invoice_object.set_reference_number(invoice['reference_number'])
        invoice_object.set_customer_id(invoice['customer_id'])
        invoice_object.set_customer_name(invoice['customer_name'])
        invoice_object.set_contact_persons(invoice['contact_persons_details'])
        invoice_object.set_currency_id(invoice['currency_id'])
        invoice_object.set_currency_code(invoice['currency_code'])
        invoice_object.set_exchange_rate(invoice['exchange_rate'])
        invoice_object.set_discount(invoice['discount'])
        invoice_object.gst_no = invoice['gst_no']
        invoice_object.set_is_discount_before_tax(invoice[\
        'is_discount_before_tax'])
        invoice_object.set_discount_type(invoice['discount_type'])
        invoice_object.set_recurring_invoice_id(invoice[\
        'recurring_invoice_id'])
        line_items = invoice['line_items']
        for value in line_items:
            line_item = LineItem()
            line_item.set_line_item_id(value['line_item_id'])
            line_item.set_item_id(value['item_id'])
            line_item.set_project_id(value['project_id'])
            line_item.set_time_entry_ids(value['time_entry_ids'])
            line_item.set_expense_id(value['expense_id'])
            line_item.set_expense_receipt_name(value['expense_receipt_name'])
            line_item.set_name(value['name'])
            line_item.set_description(value['description'])
            line_item.set_item_order(value['item_order'])
            line_item.set_bcy_rate(value['bcy_rate'])
            line_item.set_rate(value['rate'])
            line_item.set_quantity(value['quantity'])
            line_item.set_unit(value['unit'])
            line_item.set_discount(value['discount'])
            line_item.set_tax_id(value['tax_id'])
            line_item.set_tax_name(value['tax_name'])
            line_item.set_tax_type(value['tax_type'])
            line_item.set_tax_percentage(value['tax_percentage'])
            line_item.set_hsn_or_sac(value['hsn_or_sac'])
            line_item.set_item_total(value['item_total'])
            invoice_object.set_line_items(line_item)
        invoice_object.set_shipping_charge(invoice['shipping_charge'])
        invoice_object.set_adjustment(invoice['adjustment'])
        invoice_object.set_adjustment_description(invoice[\
        'adjustment_description'])
        invoice_object.set_sub_total(invoice['sub_total'])
        invoice_object.set_tax_total(invoice['tax_total'])
        invoice_object.set_total(invoice['total'])
        taxes = invoice['taxes']
        for value in taxes:
            tax = Tax()
            tax.set_tax_name(value['tax_name'])
            tax.set_tax_amount(value['tax_amount'])
            invoice_object.set_taxes(tax)
        invoice_object.set_payment_reminder_enabled(invoice[\
        'payment_reminder_enabled'])
        invoice_object.set_payment_made(invoice['payment_made'])
        invoice_object.set_credits_applied(invoice['credits_applied'])
        invoice_object.set_tax_amount_withheld(invoice['tax_amount_withheld'])
        invoice_object.set_balance(invoice['balance'])
        invoice_object.set_write_off_amount(invoice['write_off_amount'])
        invoice_object.set_allow_partial_payments(invoice[\
        'allow_partial_payments'])
        invoice_object.set_price_precision(invoice['price_precision'])
        payment_gateways = invoice['payment_options']['payment_gateways']
        for value in payment_gateways:
            payment_gateway = PaymentGateway()
            payment_gateway.set_configured(value['configured'])
            payment_gateway.set_additional_field1(value['additional_field1'])
            payment_gateway.set_gateway_name(value['gateway_name'])
            invoice_object.set_payment_options(payment_gateway)
        invoice_object.set_is_emailed(invoice['is_emailed'])
        invoice_object.set_reminders_sent(invoice['reminders_sent'])
        invoice_object.set_last_reminder_sent_date(invoice[\
        'last_reminder_sent_date'])
        billing_address = invoice['billing_address']
        billing_address_object = Address()
        billing_address_object.set_address(billing_address['address'])
        billing_address_object.set_city(billing_address['city'])
        billing_address_object.set_state(billing_address['state'])
        billing_address_object.set_zip(billing_address['zip'])
        billing_address_object.set_country(billing_address['country'])
        billing_address_object.set_fax(billing_address['fax'])
        invoice_object.set_billing_address(billing_address_object)

        shipping_address = invoice['shipping_address']
        shipping_address_object = Address()
        shipping_address_object.set_address(shipping_address['address'])
        shipping_address_object.set_city(shipping_address['city'])
        shipping_address_object.set_state(shipping_address['state'])
        shipping_address_object.set_zip(shipping_address['zip'])
        shipping_address_object.set_country(shipping_address['country'])
        shipping_address_object.set_fax(shipping_address['fax'])
        invoice_object.set_shipping_address(shipping_address_object)
        invoice_object.set_notes(invoice['notes'])
        invoice_object.set_terms(invoice['terms'])
        custom_fields = invoice['custom_fields']
        for value in custom_fields:
            custom_field = CustomField()
            custom_field.set_index(value['index'])
            custom_field.set_show_on_pdf(value['show_on_pdf'])
            custom_field.set_value(value['value'])
            custom_field.set_label(value['label'])
            invoice_object.set_custom_fields(custom_field)
        invoice_object.set_template_id(invoice['template_id'])
        invoice_object.set_template_name(invoice['template_name'])
        invoice_object.set_created_time(invoice['created_time'])
        invoice_object.set_last_modified_time(invoice['last_modified_time'])
        invoice_object.set_attachment_name(invoice['attachment_name'])
        invoice_object.set_can_send_in_mail(invoice['can_send_in_mail'])
        invoice_object.set_salesperson_id(invoice['salesperson_id'])
        invoice_object.set_salesperson_name(invoice['salesperson_name'])

        return invoice_object
    def get_estimate(self, response):
        """This method parses the given response and returns Estimate object.

        Args:
            response(dict): Response containing json object for estimate.

        Returns:
            instance: Estimate object.

        """
        estimate = Estimate()
        resp = response['estimate']
        estimate.set_estimate_id(resp['estimate_id'])
        estimate.set_estimate_number(resp['estimate_number'])
        estimate.set_date(resp['date'])
        estimate.set_reference_number(resp['reference_number'])
        estimate.set_status(resp['status'])
        estimate.set_customer_id(resp['customer_id'])
        estimate.set_customer_name(resp['customer_name'])
        estimate.set_contact_persons(resp['contact_persons'])
        estimate.set_currency_id(resp['currency_id'])
        estimate.set_currency_code(resp['currency_code'])
        estimate.set_exchange_rate(resp['exchange_rate'])
        estimate.set_expiry_date(resp['expiry_date'])
        estimate.set_discount(resp['discount'])
        estimate.set_is_discount_before_tax(resp['is_discount_before_tax'])
        estimate.set_discount_type(resp['discount_type'])
        line_items = resp['line_items']
        for value in line_items:
            line_item = LineItem()
            line_item.set_item_id(value['item_id'])
            line_item.set_line_item_id(value['line_item_id'])
            line_item.set_name(value['name'])
            line_item.set_description(value['description'])
            line_item.set_item_order(value['item_order'])
            line_item.set_bcy_rate(value['bcy_rate'])
            line_item.set_rate(value['rate'])
            line_item.set_quantity(value['quantity'])
            line_item.set_unit(value['unit'])
            line_item.set_discount(value['discount'])
            line_item.set_tax_id(value['tax_id'])
            line_item.set_tax_name(value['tax_name'])
            line_item.set_tax_type(value['tax_type'])
            line_item.set_tax_percentage(value['tax_percentage'])
            line_item.set_item_total(value['item_total'])
            estimate.set_line_items(line_item)
        estimate.set_shipping_charge(resp['shipping_charge'])
        estimate.set_adjustment(resp['adjustment'])
        estimate.set_adjustment_description(resp['adjustment_description'])
        estimate.set_sub_total(resp['sub_total'])
        estimate.set_total(resp['total'])
        estimate.set_tax_total(resp['tax_total'])
        estimate.set_price_precision(resp['price_precision'])
        taxes = resp['taxes']
        for value in taxes:
            tax = Tax()
            tax.set_tax_name(value['tax_name'])
            tax.set_tax_amount(value['tax_amount'])
            estimate.set_taxes(tax)
        billing_address = resp['billing_address']
        billing_address_object = Address()
        billing_address_object.set_address(billing_address['address'])
        billing_address_object.set_city(billing_address['city'])
        billing_address_object.set_state(billing_address['state'])
        billing_address_object.set_zip(billing_address['zip']) 
        billing_address_object.set_country(billing_address['country'])   
        billing_address_object.set_fax(billing_address['zip'])
        estimate.set_billing_address(billing_address_object)

        shipping_address = resp['shipping_address']
        shipping_address_object = Address()
        shipping_address_object.set_address(shipping_address['address'])
        shipping_address_object.set_city(shipping_address['city'])
        shipping_address_object.set_state(shipping_address['state'])
        shipping_address_object.set_zip(shipping_address['zip']) 
        shipping_address_object.set_country(shipping_address['country'])   
        shipping_address_object.set_fax(shipping_address['zip'])
        estimate.set_shipping_address(shipping_address_object)

        estimate.set_notes(resp['notes'])
        estimate.set_terms(resp['terms'])
        custom_fields = resp['custom_fields']
        for value in custom_fields:
            custom_field = CustomField()
            custom_field.set_index(value['index'])
            custom_field.set_show_on_pdf(value['show_on_pdf'])
            custom_field.set_value(value['value'])
            custom_field.set_label(value['label'])
            estimate.set_custom_fields(custom_field)
        estimate.set_template_id(resp['template_id'])
        estimate.set_template_name(resp['template_name'])
        estimate.set_created_time(resp['created_time'])
        estimate.set_last_modified_time(resp['last_modified_time'])
        estimate.set_salesperson_id(resp['salesperson_id'])
        estimate.set_salesperson_name(resp['salesperson_name'])
        return estimate