From 830f08a48d3a2e6ed432a4af1614bc456fc02872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Guti=C3=A9rrez?= Date: Wed, 22 May 2024 15:36:32 +0200 Subject: [PATCH] Update `EmailForward` fields (#389) See https://github.com/dnsimple/dnsimple-developer/issues/315 for reference In this PR: - Add `alias_email` and `destination_email` fields to `EmailForward` - Deprecate `from` and `to` fields in `EmailForward --- CHANGELOG.md | 3 +++ lib/dnsimple/struct/email_forward.rb | 10 +++++++++- .../client/domains_email_forwards_spec.rb | 4 +++- .../createEmailForward/created.http | 3 ++- .../getEmailForward/success.http | 3 ++- .../listEmailForwards/success.http | 20 +++++++++---------- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c909ddbc..bf6d3cbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/). ## main +- NEW: Added `alias_email` and `destination_email` to `EmailForward` +- CHANGED: Deprecated `from` and `to` fields in `EmailForward` + ## 9.0.0 - CHANGED: Minimum Ruby version is now 3.1 diff --git a/lib/dnsimple/struct/email_forward.rb b/lib/dnsimple/struct/email_forward.rb index d14e528f..2928cd79 100644 --- a/lib/dnsimple/struct/email_forward.rb +++ b/lib/dnsimple/struct/email_forward.rb @@ -11,15 +11,23 @@ class EmailForward < Base attr_accessor :domain_id # @return [String] The "local part" of the originating email address. Anything to the left of the @ symbol. + # @deprecated use {#alias_email} instead attr_accessor :from # @return [String] The full email address to forward to. + # @deprecated use {#destination_email} instead attr_accessor :to + # @return [String] The receiving email recipient. + attr_accessor :alias_email + + # @return [String] The email recipient the messages are delivered to. + attr_accessor :destination_email + # @return [String] Then the email forward was last updated in DNSimple. + # @return [String] When the email forward was created in DNSimple. attr_accessor :created_at - # @return [String] Then the email forward was last updated in DNSimple. attr_accessor :updated_at end diff --git a/spec/dnsimple/client/domains_email_forwards_spec.rb b/spec/dnsimple/client/domains_email_forwards_spec.rb index 4488fa74..f5cce580 100644 --- a/spec/dnsimple/client/domains_email_forwards_spec.rb +++ b/spec/dnsimple/client/domains_email_forwards_spec.rb @@ -46,7 +46,7 @@ expect(response).to be_a(Dnsimple::PaginatedResponse) expect(response.data).to be_a(Array) - expect(response.data.size).to eq(2) + expect(response.data.size).to eq(1) response.data.each do |result| expect(result).to be_a(Dnsimple::Struct::EmailForward) @@ -153,6 +153,8 @@ expect(result.domain_id).to eq(235146) expect(result.from).to eq("example@dnsimple.xyz") expect(result.to).to eq("example@example.com") + expect(result.alias_email).to eq("example@dnsimple.xyz") + expect(result.destination_email).to eq("example@example.com") expect(result.created_at).to eq("2021-01-25T13:54:40Z") expect(result.updated_at).to eq("2021-01-25T13:54:40Z") end diff --git a/spec/fixtures.http/createEmailForward/created.http b/spec/fixtures.http/createEmailForward/created.http index ebaaa502..7eb52506 100644 --- a/spec/fixtures.http/createEmailForward/created.http +++ b/spec/fixtures.http/createEmailForward/created.http @@ -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 @@ -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":"example@dnsimple.xyz","destination_email":"example@example.com","created_at":"2021-01-25T13:54:40Z","updated_at":"2021-01-25T13:54:40Z","from":"example@dnsimple.xyz","to":"example@example.com"}} +{"data":{"id":41872,"domain_id":235146,"alias_email":"example@dnsimple.xyz","destination_email":"example@example.com","created_at":"2021-01-25T13:54:40Z","updated_at":"2021-01-25T13:54:40Z","from":"example@dnsimple.xyz","to":"example@example.com"}} diff --git a/spec/fixtures.http/getEmailForward/success.http b/spec/fixtures.http/getEmailForward/success.http index 1733c354..23097f60 100644 --- a/spec/fixtures.http/getEmailForward/success.http +++ b/spec/fixtures.http/getEmailForward/success.http @@ -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 @@ -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":"example@dnsimple.xyz","destination_email":"example@example.com","created_at":"2021-01-25T13:54:40Z","updated_at":"2021-01-25T13:54:40Z","from":"example@dnsimple.xyz","to":"example@example.com"}} +{"data":{"id":41872,"domain_id":235146,"alias_email":"example@dnsimple.xyz","destination_email":"example@example.com","created_at":"2021-01-25T13:54:40Z","updated_at":"2021-01-25T13:54:40Z","from":"example@dnsimple.xyz","to":"example@example.com"}} diff --git a/spec/fixtures.http/listEmailForwards/success.http b/spec/fixtures.http/listEmailForwards/success.http index 4a5a99a3..4dd40749 100644 --- a/spec/fixtures.http/listEmailForwards/success.http +++ b/spec/fixtures.http/listEmailForwards/success.http @@ -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":"jane.smith@example.com","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":"jane.smith@example.com","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}}