luk4s / mautic-rails

Mautic ruby client / wrapper
MIT License
23 stars 23 forks source link

m.segments returns noMethodError #14

Open petebytes opened 4 years ago

petebytes commented 4 years ago

Unable to list, add, remove segments

petebytes commented 4 years ago

@luk4s If you can provide some direction I will work on adding segments. https://developer.mautic.org/#add-contact-to-a-segment

luk4s commented 4 years ago

Hi, basically for add and remove contact to/from segment, implement instance methods in https://github.com/luk4s/mautic-rails/blob/master/app/models/mautic/contact.rb model. For example:

# @param [Integer] segment_id
def add_to_segment(segment_id)
  json = @connection.request(:post, "api//segments/#{segment_id}/contact/#{id}/add", body: {})
  json&.[] "success"
end

For describe REST of segments https://developer.mautic.org/#segments is best way defined new class Mautic::Segment (for example similar to https://github.com/luk4s/mautic-rails/blob/master/app/models/mautic/form.rb). If you are interest in implemtn feature of add contacts to segement or remove them, I think best way is do them as a class methods in Segment model.

so, my suggestions:


Create WIP pull requests, I will help and check it continually (based on time 🙂 )