def get_contact_persons(self, response): """This method parses the given repsonse and creates contact persons list object. Args: response(dict): Response containing json object for contact persons list. Returns: instance: Contact person list object. """ resp = response['contact_persons'] contact_person_list = ContactPersonList() for value in resp: 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_person_list.set_contact_persons(contact_person) page_context_object = PageContext() page_context = response['page_context'] page_context_object.set_page(page_context['page']) page_context_object.set_per_page(page_context['per_page']) page_context_object.set_has_more_page(page_context['has_more_page']) page_context_object.set_sort_column(page_context['sort_column']) page_context_object.set_sort_order(page_context['sort_order']) contact_person_list.set_page_context(page_context_object) return contact_person_list
def get_contact_person(self, resp): """This method parses the given response and creates a contact person object. Args: resp(dict): Response containing json object for contact person. Returns: instance: Contact person object. """ contact_person = ContactPerson() response = resp['contact_person'] contact_person.set_contact_id(response['contact_id']) contact_person.set_contact_person_id(response['contact_person_id']) contact_person.set_salutation(response['salutation']) contact_person.set_first_name(response['first_name']) contact_person.set_last_name(response['last_name']) contact_person.set_email(response['email']) contact_person.set_phone(response['phone']) contact_person.set_mobile(response['mobile']) contact_person.set_is_primary_contact(response['is_primary_contact']) return contact_person
print("get contact using id = '" + first_contact.contact_id + "' : " + test_contact.contact_id + " | " + test_contact.contact_name) # to create contact contact = Contact() contact.set_company_name('Wayne Enterprises') contact.set_contact_name('Bruce Wayne') contact.set_email('*****@*****.**') contact.set_payment_terms(15) contact.set_payment_terms_label('Net 15') contact.set_currency_id("276200000000044013") contact.set_notes('thank you') con_per = [] cp = ContactPerson() cp.set_first_name('nivetha') cp.set_salutation('ms') con_per.append(cp) v = ContactPerson() v.set_first_name('varunaa') v.set_salutation('mr') v.set_is_primary_contact(True) con_per.append(v) #contact.set_contact_persons(con_per) baddress = Address() baddress.set_address('45, suite street') baddress.set_city('California')
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
# to get a contact print contact_api.get(contact_id) # to create contact contact = Contact() contact.set_contact_name('anin') contact.set_payment_terms(15) contact.set_payment_terms_label('Net 15') contact.set_currency_id(currency_id) contact.set_notes('thank you') con_per = [] cp = ContactPerson() cp.set_first_name('nivetha') cp.set_salutation('ms') con_per.append(cp) v = ContactPerson() v.set_first_name('varunaa') v.set_salutation('mr') v.set_is_primary_contact(True) con_per.append(v) contact.set_contact_persons(con_per) baddress = Address() baddress.set_address('45, suite street') baddress.set_city('California')
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
contact_person_id = contact_person_api.get_contact_persons( contact_id).get_contact_persons()[0].get_contact_person_id() #list contact persons print contact_person_api.get_contact_persons(contact_id) #get contact person details print contact_person_api.get(contact_person_id) # create contact person d = ContactPerson() d.set_salutation('Mr') d.set_first_name('bata') d.set_last_name('kumar') d.set_email('*****@*****.**') d.set_phone('999887') d.set_mobile('9998887766') d.set_contact_id(contact_id) print contact_person_api.create(d) # update contact person d.set_salutation('Ms') d.set_first_name('anuja') d.set_last_name('kavya') d.set_email('*****@*****.**') d.set_phone('999887')
contact_person_id = contact_person_api.get_contact_persons(contact_id).get_contact_persons()[0].get_contact_person_id() #list contact persons print contact_person_api.get_contact_persons(contact_id) #get contact person details print contact_person_api.get(contact_person_id) # create contact person d = ContactPerson() d.set_salutation('Mr') d.set_first_name('bata') d.set_last_name('kumar') d.set_email('*****@*****.**') d.set_phone('999887') d.set_mobile('9998887766') d.set_contact_id(contact_id) print contact_person_api.create(d) # update contact person d.set_salutation('Ms') d.set_first_name('anuja') d.set_last_name('kavya') d.set_email('*****@*****.**') d.set_phone('999887')