Problem/Motivation

"Interest labels" and "Preferences" are phased out in favour of "Interests" in the Flexmail REST API.
All Flexmail accounts are being transferred to this new structure at the time of writing. This is being communicated to their clients before doing so.

Proposed resolution

Deprecate the following API methods:

  • getPreferences
  • getContactPreferenceSubscriptions
  • getInterestLabels
  • getContactInterestLabels
  • subscribeContactToPreference

Add new API methods:

  • getInterests
  • getContactInterests
  • subscribeContactToInterest

Remaining tasks

Deprecate the following API methods:

  • getPreferences
  • getContactPreferenceSubscriptions
  • getInterestLabels
  • getContactInterestLabels
  • subscribeContactToPreference

Add new API methods:

  • getInterests
  • getContactInterests
  • subscribeContactToInterest

User interface changes

None.

API changes

See proposed solution.

Data model changes

None.

Issue fork flexmail-3394527

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Fernly created an issue. See original summary.

fernly’s picture

Status: Active » Needs review
StatusFileSize
new14.38 KB

Backwards compatible patch.
The patch marks preference and interest label methods as deprecated (they still work) and adds 3 new API methods:

  1. getInterests (returns new InterestCollection object)
  2. getContactInterests (returns new InterestCollection object)
  3. subscribeContactToInterest
fernly’s picture

Issue summary: View changes
fernly’s picture

StatusFileSize
new14.49 KB

Updated patch with missing doc comment.

daften’s picture

Status: Needs review » Needs work

I have the following remarks when reviewing:

  • The method \Drupal\flexmail\api\value\Value::validateFieldsPresent doesn't seem to be used at the moment.
  • It's also a bit strange that helper static methods are placed in an abstract (base) class. Why is that abstract class needed, shouldn't the helper logic be better off in a Utility class?
  • Secondary, Maybe ValueBase is a better name, if a base class is deemed useful to add base logic to in a later phase?
  • If there is an interface \Drupal\flexmail\api\value\ValueInterface, I'd expect the base class to implement that interface, since based on the name it seems to be something uniform for all value classes.

The logic looks good in general. Could you check the comments above?

Next to that, is there a blog post or more information that can be shared? Since we'll need a follow-up issue to update the flexmail_webform submodule, since there is logic there that depends on the deprecated methods.

fernly’s picture

Status: Needs work » Needs review
StatusFileSize
new20.31 KB

Thanks for the review.

  • \Drupal\flexmail\api\value\Value::validateFieldsPresent is removed. But keep in mind that the Flexmail module can serve as an API module for other modules (which is the case at District09) and doing so, providing functionality which is not necessarily used internally.
  • The abstract class is meant to be used by all other (future) value objects, which all can use its base methods. I don't see the point to make an extra utility class for that. The 2 available methods are static because they are used by another static method in an extending class. The abstract class can contain more common methods in the future applicable to all Flexmail value objects. I made Contact extending ValueBase as well now as it can't break anything.
  • Renaming the abstract class: check.
  • Of course the abstract class should use the ValueInterface: check.

Abstracted some more code into separate (base) classes/interfaces.
Additionally the 3 existing Value objects are made final.

The Flexmail structural change is shown in a small video on https://app.flexmail.eu/auth. Also when you log in, you should get a warning when your segments are still based on sources instead of interests. Rumour has it it's also communicated through a newsletter.

daften’s picture

Status: Needs review » Needs work

Thanks for the updates, some feedback again :)

  • Why not add sameValueTypeAs and maybe even getId in the interface, so you can use the interface as typehint where appropriate? Or doesn't that make sense?
  • You use ValueAbstract::sameValueTypeAs() in the docblock for \Drupal\flexmail\api\value\ValueInterface::sameValueAs, which should be changed to ValueBase::, or if the comment above makes sense and you agree, to ValueInterface::
  • It makes sense about keeping the static classes in there, it just looked a bit weird to have only static classes in there, now it just looks more logical in my mind, since there's other regular methods in there.
  • In the constructors for some classes a comment says "The constructor is protected", maybe that should be private instead of protected, since the method is private?
  • Keeping \Drupal\flexmail\api\value\Value::validateFieldsPresent in there is ok for me, it was just weird to add a method that isn't used. Especially since that's a method that imo should/could be used in the basic API layer. If you feel it's an added value, feel free to add it back in.
fernly’s picture

Status: Needs work » Needs review
StatusFileSize
new20.47 KB

Applied all changes. \Drupal\flexmail\api\value\Value::validateFieldsPresent is not kept for now.

daften’s picture

Looks good to me, I'll give Matthijs a chance to look at it, if he doesn't have time, I'll merge. ping me if it becomes urgent!

matthijs’s picture

Assigned: fernly » matthijs
Priority: Major » Normal
matthijs’s picture

Priority: Normal » Major

matthijs’s picture

Assigned: matthijs » Unassigned
Priority: Major » Normal
daften’s picture

Status: Needs review » Needs work

Marking as needs work based on the feedback!

fernly’s picture

Status: Needs work » Needs review
StatusFileSize
new20.97 KB

Fixed feedback or added responses to remarks in MR. Marking as 'Needs review'.

matthijs’s picture

Status: Needs review » Needs work

Replied in the threads. I would suggest to fix these last 3 issues, then it's RTBC.

daften’s picture

We only need a better solution for the getId method, having an empty id method that should never be used for some valueobjects doesn't seem right. Maybe we can have ValueObjectBase and ValueCollectionBase with a common ValueBase? Or using traits as suggested before?

fernly’s picture

Status: Needs work » Needs review

Moved getId to the final value objects that actually (can) have an ID.

fernly’s picture

StatusFileSize
new21.81 KB

For anyone needing a patch, here a version including the latest MR changes.

fernly’s picture

StatusFileSize
new21.82 KB

Updated patch since MR changes.

fernly’s picture

StatusFileSize
new22.07 KB

Updated patch since MR changes.

Issue #3394527: Fix deprecation notice

  • daften committed 84f104d5 on 2.x authored by Fernly
    Issue #3394527 by Fernly, Matthijs: Add support for "Interest" endpoints...
daften’s picture

Status: Needs review » Fixed
daften’s picture

Merged, thanks for the contribution!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.