Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EmailForward fields #151

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).

## main

- NEW: Added `AliasEmail` to `EmailForward`
- CHANGED: Deprecated `From` and `To` fields in `EmailForward`

## 0.18.1

- HOUSEKEEPING: Bump nunit from 4.0.1 to 4.1.0 (#147)
Expand Down
18 changes: 10 additions & 8 deletions src/dnsimple-test/Services/DomainsEmailForwardsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"deleteEmailForward/success.http";

private DateTime CreatedAt { get; } = DateTime.ParseExact(
"2016-02-04T13:59:29Z", "yyyy-MM-ddTHH:mm:ssZ",
"2017-05-25T19:23:16Z", "yyyy-MM-ddTHH:mm:ssZ",
CultureInfo.CurrentCulture);

private DateTime UpdatedAt { get; } = DateTime.ParseExact(
"2016-02-04T13:59:29Z", "yyyy-MM-ddTHH:mm:ssZ",
"2017-05-25T19:23:16Z", "yyyy-MM-ddTHH:mm:ssZ",
CultureInfo.CurrentCulture);

[SetUp]
Expand All @@ -49,11 +49,13 @@

Assert.Multiple(() =>
{
Assert.That(emailForwards.Count, Is.EqualTo(2));
Assert.That(emailForwards.First().Id, Is.EqualTo(17702));
Assert.That(emailForwards.First().DomainId, Is.EqualTo(228963));
Assert.That(emailForwards.Count, Is.EqualTo(1));
Assert.That(emailForwards.First().Id, Is.EqualTo(24809));
Assert.That(emailForwards.First().DomainId, Is.EqualTo(235146));
Assert.That(emailForwards.First().From, Is.EqualTo(".*@a-domain.com"));

Check warning on line 55 in src/dnsimple-test/Services/DomainsEmailForwardsTest.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.From' is obsolete: 'Deprecated, use AliasEmail or AliasName instead'
Assert.That(emailForwards.First().To, Is.EqualTo("[email protected]"));

Check warning on line 56 in src/dnsimple-test/Services/DomainsEmailForwardsTest.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.To' is obsolete: 'Deprecated, use DestinationEmail instead'
Assert.That(emailForwards.First().AliasEmail, Is.EqualTo(".*@a-domain.com"));
Assert.That(emailForwards.First().DestinationEmail, Is.EqualTo("[email protected]"));
Assert.That(emailForwards.First().CreatedAt, Is.EqualTo(CreatedAt));
Assert.That(emailForwards.First().UpdatedAt, Is.EqualTo(UpdatedAt));
});
Expand All @@ -73,7 +75,7 @@

Assert.Multiple(() =>
{
Assert.That(emailForwards.Data.Count, Is.EqualTo(2));
Assert.That(emailForwards.Data.Count, Is.EqualTo(1));
Assert.That(emailForwards.Pagination.CurrentPage, Is.EqualTo(1));

Assert.That(client.RequestSentTo(), Is.EqualTo(expectedUrl));
Expand All @@ -98,7 +100,7 @@

Assert.Multiple(() =>
{
Assert.That(emailForwards.Data.Count, Is.EqualTo(2));
Assert.That(emailForwards.Data.Count, Is.EqualTo(1));
Assert.That(emailForwards.Pagination.CurrentPage, Is.EqualTo(1));

Assert.That(client.RequestSentTo(), Is.EqualTo(expectedUrl));
Expand Down Expand Up @@ -132,8 +134,8 @@
Assert.That(created.Data.DestinationEmail, Is.EqualTo(record.DestinationEmail));

// Deprecated
Assert.That(created.Data.From, Is.EqualTo(record.From));

Check warning on line 137 in src/dnsimple-test/Services/DomainsEmailForwardsTest.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.From' is obsolete: 'Deprecated, use AliasEmail or AliasName instead'

Check warning on line 137 in src/dnsimple-test/Services/DomainsEmailForwardsTest.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.From' is obsolete: 'Deprecated, use AliasEmail or AliasName instead'
Assert.That(created.Data.To, Is.EqualTo(record.To));

Check warning on line 138 in src/dnsimple-test/Services/DomainsEmailForwardsTest.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.To' is obsolete: 'Deprecated, use DestinationEmail instead'

Check warning on line 138 in src/dnsimple-test/Services/DomainsEmailForwardsTest.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.To' is obsolete: 'Deprecated, use DestinationEmail instead'

Assert.That(client.RequestSentTo(), Is.EqualTo(expectedUrl));
});
Expand Down Expand Up @@ -236,4 +238,4 @@
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ HTTP/1.1 201 Created
Server: nginx
Date: Mon, 25 Jan 2021 13:54:40 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: identity
Connection: keep-alive
X-RateLimit-Limit: 4800
X-RateLimit-Remaining: 4772
Expand All @@ -18,4 +19,4 @@ X-Permitted-Cross-Domain-Policies: none
Content-Security-Policy: frame-ancestors 'none'
Strict-Transport-Security: max-age=31536000

{"data":{"id":41872,"domain_id":235146,"alias_email":"[email protected]","destination_email":"[email protected]","created_at":"2021-01-25T13:54:40Z","updated_at":"2021-01-25T13:54:40Z","from":"[email protected]","to":"[email protected]"}}
{"data":{"id":41872,"domain_id":235146,"alias_email":"[email protected]","destination_email":"[email protected]","created_at":"2021-01-25T13:54:40Z","updated_at":"2021-01-25T13:54:40Z","from":"[email protected]","to":"[email protected]"}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ HTTP/1.1 200 OK
Server: nginx
Date: Mon, 25 Jan 2021 13:56:24 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: identity
Connection: keep-alive
X-RateLimit-Limit: 4800
X-RateLimit-Remaining: 4766
Expand All @@ -18,4 +19,4 @@ X-Permitted-Cross-Domain-Policies: none
Content-Security-Policy: frame-ancestors 'none'
Strict-Transport-Security: max-age=31536000

{"data":{"id":41872,"domain_id":235146,"alias_email":"[email protected]","destination_email":"[email protected]","created_at":"2021-01-25T13:54:40Z","updated_at":"2021-01-25T13:54:40Z","from":"[email protected]","to":"[email protected]"}}
{"data":{"id":41872,"domain_id":235146,"alias_email":"[email protected]","destination_email":"[email protected]","created_at":"2021-01-25T13:54:40Z","updated_at":"2021-01-25T13:54:40Z","from":"[email protected]","to":"[email protected]"}}
20 changes: 10 additions & 10 deletions src/dnsimple-test/fixtures/v2/api/listEmailForwards/success.http
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 04 Feb 2016 14:07:19 GMT
Date: Fri, 17 May 2024 09:07:28 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
X-RateLimit-Limit: 4000
X-RateLimit-Remaining: 3993
X-RateLimit-Reset: 1454596043
ETag: W/"3f10aae0cf0f0b81bdb4f58786ee1750"
X-RateLimit-Limit: 4800
X-RateLimit-Remaining: 4748
X-RateLimit-Reset: 1715936948
X-WORK-WITH-US: Love automation? So do we! https://dnsimple.com/jobs
ETag: W/"a5eed9a071f03e10fc67001ccc647a94"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 6e3aa9d0-cb95-4186-93b0-630da372de86
X-Runtime: 0.026287
Strict-Transport-Security: max-age=31536000
X-Request-Id: e42df983-a8a5-4123-8c74-fb89ab934aba
X-Runtime: 0.025456
Strict-Transport-Security: max-age=63072000

{"data":[{"id":17702,"domain_id":228963,"from":".*@a-domain.com","to":"[email protected]","created_at":"2016-02-04T13:59:29Z","updated_at":"2016-02-04T13:59:29Z"},{"id":17703,"domain_id":228963,"from":"john@a-domain.com","to":"john@example.com","created_at":"2016-02-04T14:07:13Z","updated_at":"2016-02-04T14:07:13Z"}],"pagination":{"current_page":1,"per_page":30,"total_entries":2,"total_pages":1}}
{"data":[{"id":24809,"domain_id":235146,"alias_email":".*@a-domain.com","destination_email":"[email protected]","created_at":"2017-05-25T19:23:16Z","updated_at":"2017-05-25T19:23:16Z","from":".*@a-domain.com","to":"jane.smith@example.com"}],"pagination":{"current_page":1,"per_page":30,"total_entries":1,"total_pages":1}}
3 changes: 3 additions & 0 deletions src/dnsimple/Services/DomainsEmailForwards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
builder.Method(Method.POST);
builder.AddJsonPayload(record);

if (record.To.Trim().Equals("") || record.From.Trim().Equals(""))

Check warning on line 48 in src/dnsimple/Services/DomainsEmailForwards.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.To' is obsolete: 'Deprecated, use DestinationEmail instead'

Check warning on line 48 in src/dnsimple/Services/DomainsEmailForwards.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.From' is obsolete: 'Deprecated, use AliasEmail or AliasName instead'

Check warning on line 48 in src/dnsimple/Services/DomainsEmailForwards.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.To' is obsolete: 'Deprecated, use DestinationEmail instead'

Check warning on line 48 in src/dnsimple/Services/DomainsEmailForwards.cs

View workflow job for this annotation

GitHub Actions / .NET 6.0.x

'EmailForward.From' is obsolete: 'Deprecated, use AliasEmail or AliasName instead'
throw new ArgumentException("AliasName or DestinationEmail cannot be blank");

return new SimpleResponse<EmailForward>(Execute(builder.Request));
Expand Down Expand Up @@ -93,6 +93,7 @@

public string AliasName { get; set; }

[Obsolete("Deprecated, use AliasEmail or AliasName instead")]
public string From
{
get
Expand All @@ -107,9 +108,11 @@
AliasName = value;
}
}
public string AliasEmail { get; set; }

public string DestinationEmail { get; set; }

[Obsolete("Deprecated, use DestinationEmail instead")]
public string To
{
get
Expand Down