diff --git a/dnsimple/struct/account.py b/dnsimple/struct/account.py index 5bf1909..d9b8fbe 100644 --- a/dnsimple/struct/account.py +++ b/dnsimple/struct/account.py @@ -15,6 +15,8 @@ class Account(Struct): """The account ID in DNSimple""" email = None """The account email""" + name = None + """The account name""" plan_identifier = None """The identifier of the plan the account is subscribed to""" created_at = None diff --git a/dnsimple/struct/domain_push.py b/dnsimple/struct/domain_push.py index cc94458..e197780 100644 --- a/dnsimple/struct/domain_push.py +++ b/dnsimple/struct/domain_push.py @@ -10,17 +10,20 @@ class DomainPushInput(dict): """Represents the data to send to the DNSimple API to initiate a push""" - def __init__(self, new_account_email=None, contact_id=None): + def __init__(self, new_account_email=None, new_account_identifier=None, contact_id=None): """ Creates a new DomainPushInput :param new_account_email: str - The target account email address (Required when initiating a push) + Deprecated: Use new_account_identifier instead. + The target account email address + :param new_account_identifier: str + The target domain push identifier (Required when initiating a push) :param contact_id: int A contact that belongs to the target DNSimple account. The contact will be used as new registrant for the domain, if the domain is registered with DNSimple (Required when accepting a push) """ - dict.__init__(self, new_account_email=new_account_email, contact_id=contact_id) + dict.__init__(self, new_account_email=new_account_email, new_account_identifier=new_account_identifier, contact_id=contact_id) def to_json(self): return json.dumps(omitempty(self)) diff --git a/tests/fixtures/v2/api/accounts/success-account.http b/tests/fixtures/v2/api/accounts/success-account.http index c3dc4dc..2d8e0f9 100644 --- a/tests/fixtures/v2/api/accounts/success-account.http +++ b/tests/fixtures/v2/api/accounts/success-account.http @@ -17,4 +17,4 @@ x-permitted-cross-domain-policies: none x-xss-protection: 1; mode=block strict-transport-security: max-age=31536000 -{"data":[{"id":123,"email":"john@example.com","plan_identifier":"dnsimple-personal","created_at":"2011-09-11T17:15:58Z","updated_at":"2016-06-03T15:02:26Z"}]} +{"data":[{"id":123,"email":"john@example.com","name":"John","plan_identifier":"dnsimple-personal","created_at":"2011-09-11T17:15:58Z","updated_at":"2016-06-03T15:02:26Z"}]} diff --git a/tests/fixtures/v2/api/accounts/success-user.http b/tests/fixtures/v2/api/accounts/success-user.http index ee9fe42..949c73c 100644 --- a/tests/fixtures/v2/api/accounts/success-user.http +++ b/tests/fixtures/v2/api/accounts/success-user.http @@ -17,5 +17,5 @@ x-permitted-cross-domain-policies: none x-xss-protection: 1; mode=block strict-transport-security: max-age=31536000 -{"data":[{"id":123,"email":"john@example.com","plan_identifier":"dnsimple-personal","created_at":"2011-09-11T17:15:58Z","updated_at":"2016-06-03T15:02:26Z"},{"id":456,"email":"ops@company.com","plan_identifier":"teams-v1-monthly","created_at":"2012-03-16T16:02:54Z","updated_at":"2016-06-14T11:23:16Z"}]} +{"data":[{"id":123,"email":"john@example.com","name":"John","plan_identifier":"dnsimple-personal","created_at":"2011-09-11T17:15:58Z","updated_at":"2016-06-03T15:02:26Z"},{"id":456,"email":"ops@company.com","name":"Ops Company","plan_identifier":"teams-v1-monthly","created_at":"2012-03-16T16:02:54Z","updated_at":"2016-06-14T11:23:16Z"}]} diff --git a/tests/fixtures/v2/api/listAccounts/success-account.http b/tests/fixtures/v2/api/listAccounts/success-account.http index c3dc4dc..2d8e0f9 100644 --- a/tests/fixtures/v2/api/listAccounts/success-account.http +++ b/tests/fixtures/v2/api/listAccounts/success-account.http @@ -17,4 +17,4 @@ x-permitted-cross-domain-policies: none x-xss-protection: 1; mode=block strict-transport-security: max-age=31536000 -{"data":[{"id":123,"email":"john@example.com","plan_identifier":"dnsimple-personal","created_at":"2011-09-11T17:15:58Z","updated_at":"2016-06-03T15:02:26Z"}]} +{"data":[{"id":123,"email":"john@example.com","name":"John","plan_identifier":"dnsimple-personal","created_at":"2011-09-11T17:15:58Z","updated_at":"2016-06-03T15:02:26Z"}]} diff --git a/tests/fixtures/v2/api/listAccounts/success-user.http b/tests/fixtures/v2/api/listAccounts/success-user.http index cbd017c..3eeb423 100644 --- a/tests/fixtures/v2/api/listAccounts/success-user.http +++ b/tests/fixtures/v2/api/listAccounts/success-user.http @@ -17,4 +17,4 @@ x-permitted-cross-domain-policies: none x-xss-protection: 1; mode=block strict-transport-security: max-age=31536000 -{"data":[{"id":123,"email":"john@example.com","plan_identifier":"dnsimple-personal","created_at":"2011-09-11T17:15:58Z","updated_at":"2016-06-03T15:02:26Z"},{"id":456,"email":"ops@company.com","plan_identifier":"teams-v1-monthly","created_at":"2012-03-16T16:02:54Z","updated_at":"2016-06-14T11:23:16Z"}]} +{"data":[{"id":123,"email":"john@example.com","name":"John","plan_identifier":"dnsimple-personal","created_at":"2011-09-11T17:15:58Z","updated_at":"2016-06-03T15:02:26Z"},{"id":456,"email":"ops@company.com","name":"Ops Company","plan_identifier":"teams-v1-monthly","created_at":"2012-03-16T16:02:54Z","updated_at":"2016-06-14T11:23:16Z"}]} diff --git a/tests/fixtures/v2/api/whoami/success-account.http b/tests/fixtures/v2/api/whoami/success-account.http index 24b6dc1..8c7650d 100644 --- a/tests/fixtures/v2/api/whoami/success-account.http +++ b/tests/fixtures/v2/api/whoami/success-account.http @@ -12,4 +12,4 @@ x-request-id: 15a7f3a5-7ee5-4e36-ac5a-8c21c2e1fffd x-runtime: 0.141588 strict-transport-security: max-age=31536000 -{"data":{"user":null,"account":{"id":1,"email":"example-account@example.com","plan_identifier":"teams-v1-monthly","created_at":"2015-09-18T23:04:37Z","updated_at":"2016-06-09T20:03:39Z"}}} +{"data":{"user":null,"account":{"id":1,"email":"example-account@example.com","name":"Example Account","plan_identifier":"teams-v1-monthly","created_at":"2015-09-18T23:04:37Z","updated_at":"2016-06-09T20:03:39Z"}}} diff --git a/tests/fixtures/v2/api/whoami/success.http b/tests/fixtures/v2/api/whoami/success.http index 24b6dc1..8c7650d 100644 --- a/tests/fixtures/v2/api/whoami/success.http +++ b/tests/fixtures/v2/api/whoami/success.http @@ -12,4 +12,4 @@ x-request-id: 15a7f3a5-7ee5-4e36-ac5a-8c21c2e1fffd x-runtime: 0.141588 strict-transport-security: max-age=31536000 -{"data":{"user":null,"account":{"id":1,"email":"example-account@example.com","plan_identifier":"teams-v1-monthly","created_at":"2015-09-18T23:04:37Z","updated_at":"2016-06-09T20:03:39Z"}}} +{"data":{"user":null,"account":{"id":1,"email":"example-account@example.com","name":"Example Account","plan_identifier":"teams-v1-monthly","created_at":"2015-09-18T23:04:37Z","updated_at":"2016-06-09T20:03:39Z"}}} diff --git a/tests/service/accounts_test.py b/tests/service/accounts_test.py index 65d2dd8..4c1699b 100644 --- a/tests/service/accounts_test.py +++ b/tests/service/accounts_test.py @@ -16,6 +16,7 @@ def test_list_accounts(self): accounts = self.accounts.list_accounts().data self.assertEqual(1, len(accounts)) self.assertIsInstance(accounts[0], Account) + self.assertEqual('John', accounts[0].name) @responses.activate def test_list_users(self): diff --git a/tests/service/domains_pushes_test.py b/tests/service/domains_pushes_test.py index 581e01b..a3d4d23 100644 --- a/tests/service/domains_pushes_test.py +++ b/tests/service/domains_pushes_test.py @@ -22,6 +22,16 @@ def test_initiate_push(self): self.assertEqual('2016-08-11T10:16:03Z', push.updated_at) self.assertIsNone(push.accepted_at) + @responses.activate + def test_initiate_push_with_account_identifier(self): + responses.add(DNSimpleMockResponse(method=responses.POST, + path='/2020/domains/1/pushes', + fixture_name='initiatePush/success')) + push = self.domains.initiate_push(2020, 1, DomainPushInput(new_account_identifier='abc123')).data + + self.assertEqual(1, push.id) + self.assertEqual(2020, push.account_id) + @responses.activate def test_list_pushes(self): responses.add(DNSimpleMockResponse(method=responses.GET,