ActiveCampaign / postmark-gem

Official Ruby client library for the Postmark HTTP API

Home Page:https://postmarkapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inflector not properly applied to SubscriptionManagementConfiguration

SirRawlins opened this issue · comments

Started using the new Message Streams API today, and found a bug in the gem.

It seems as if it doesn't properly inflect the nested UnsubscribeHandlingType object between CamelCase and snake_case.

The following code snippet for example:

client.create_message_stream(
    id: 'someid3',
    name: 'Some Stream Name 3',
    message_stream_type: 'Broadcasts',
    subscription_management_configuration: {
        unsubscribe_handling_type: 'Custom',
        #UnsubscribeHandlingType: 'Custom'
    }
)

Fails to set the UnsubscribeHandlingType attribute, instead, the default is used. You must use the CamelCase version as the Hash key to get it working as expected.

This same lack of Inflection can also be seen in the parsed response returned by the create_message_stream request.

 => {:id=>"someid3", :server_id=>XXXXXXX, :name=>"Some Stream Name 3", :description=>nil, :message_stream_type=>"Broadcasts", :created_at=>"2020-10-02T11:54:27.9559365-04:00", :updated_at=>nil, :archived_at=>nil, :expected_purge_date=>nil, :subscription_management_configuration=>{"UnsubscribeHandlingType"=>"Postmark"}} 

I'm guessing this is likely something to do with the to_postmark/to_ruby helper methods not being recursive? And only handling the top-level keys of the Hash?

Happy to help out where I can.