mercredi 29 novembre 2017

Gibbon After member deleted, I can not add him again

I don't know if this is gem/api related question or implementation, but after deleting a member from a list, I can't add him again. I'm obtaining that

is already a list member. Use PUT to insert or update list members.

I am using the following methods to add members from a list:

class SubscribeToNewsletterService
 def initialize(user)
  @user = user
  @gibbon = Gibbon::Request.new(api_key: ENV['MAILCHIMP_API_KEY'])
  @list_id = ENV['MAILCHIMP_LIST_ID']
end

def call
@gibbon.lists(@list_id).members.create(
  body: {
    email_address: @user.email,
    status: "subscribed",
    merge_fields: {
      FNAME: @user.first_name,
      LNAME: @user.last_name,
     }
   }
 )
 end
end

Aucun commentaire:

Enregistrer un commentaire