How to use the dnsimple.struct.Contact function in dnsimple

To help you get started, we’ve selected a few dnsimple examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dnsimple / dnsimple-api-examples / python / create_contact.py View on Github external
current credentials via the DNSimple API.
"""
response = client.identity.whoami()

"""
The response object returned by any API method includes a `data` attribute.

Underneath that attribute is an attribute for each data object returned.

In this case, `account` provides access to the contained account object.

Here the account id is extracted for use in future calls:
"""
account_id = response.data.account.id

contact = Contact.new(label=args.label, first_name=args.first_name, last_name=args.last_name, job_title=args.job_title,
                      organization_name=args.organization_name, email=args.email, phone=args.phone,
                      fax=args.fax, address1=args.address1, address2=args.address2, city=args.city,
                      state_province=args.state_province, postal_code=args.postal_code, country=args.country)

response = client.contacts.create_contact(account_id, contact)

print(f'Created contact: {response.data.first_name} with id {response.data.id}')