Skip to content
This repository was archived by the owner on Oct 13, 2019. It is now read-only.

ImpactMapper/mail_opt_out

Repository files navigation

MailOptOut

Build

CircleCI branch Travis CI

Maintainability

Maintenance Maintainability

Code Quality

Code Climate coverage Coverage Status Code Climate issues Code Climate maintainability Code Climate maintainability (percentage) Code Climate technical debt

Size

GitHub code size in bytes GitHub repo size in bytes

Usage

Gem Gem

Activity

GitHub All Releases GitHub last commit (master) GitHub Release Date

Documentation

Inline docs License Version

Security

Libraries.io dependency status for latest release

Simple Mail Opt In/Out Service, its based on JSONAPI Format.

Usage

Subscribe a user to a list of diffusion

curl -X POST \
  http(s)://<domain>/users/:user_id/subscriptions/subscribe \
  -H 'Accept: application/vnd.api+json' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
  "data": {
    "attributes": {
      "list": "Newsletters"
    }
  }
}'

Unubscribe a given user to a list of diffusion

curl -X POST \
  http(s)://<domain>/users/:user_id/subscriptions/subscribe \
  -H 'Accept: application/vnd.api+json' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
  "data": {
    "attributes": {
      "list": "Whatever List"
    }
  }
}'

Get the subscriptions of a given user

curl -X GET \
  http(s)://<domain>/users/:user_id/subscriptions \
  -H 'Accept: application/vnd.api+json' \
  -H 'Content-Type: application/vnd.api+json' \
  -H 'cache-control: no-cache'
{
    "data": [
        {
            "id": "1bbd2fc2-9deb-4c07-ab10-13ebea5f7ab5",
            "type": "subscription",
            "attributes": {
                "list": "Joel Test List"
            }
        }
    ]
}

See API Doc here https://documenter.getpostman.com/view/2646236/S11NMH9y

Installation

gem 'mail_opt_out'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mail_opt_out

Routes

mount MailOptOut::Engine => '/'

Migrations

bundle exec rails generate migration CreateMailOptOutLists

class CreateMailOptOutLists < ActiveRecord::Migration[5.2]
  def change
    create_table :mail_opt_out_lists do |t|
      t.string :number
      t.string :name
      t.text :description
      t.boolean :published, default: false

      t.timestamps
    end
  end
end
bundle exec rails generate migration CreateMailOptOutSubscriptions
class CreateMailOptOutSubscriptions < ActiveRecord::Migration[5.2]
  def change
    create_table :mail_opt_out_subscriptions do |t|
      t.references :list
      t.references :user, polymorphic: true, index: true

      t.timestamps
    end
  end
end

Third services

This Engine is designed to support serveral services, for now it come with Mailchimp

Mailchimp

This gem come with a integration to Mailchimp, however is totally optional.

If you want to activate it

gem 'gibbon'

Set ENV['MAILCHIMP_API_KEY']

To synchronize your Mailchimp list add Rake Task to periodically launch MailOptOut.sync

Configuration

If you have a different User model you define it.

If you to set thrid service as backgound just tick async = true

You can add config/initialize/mail_opt_out.rb

require 'mail_opt_out'

MailOptOut.user_class = 'User'
MailOptOut.async = true

Contributing

make sure all tests still passed, and every contribution is covered by test.

rake

Todo

By Priority 1 low, 5 high

Engine

  • 1 Add Generators
  • 1 Rake Task to sync existing data with services
  • 1 Rake Task to setup, start and cleanup dummy app
  • 1 Extract Engine, Gem and Services
  • mail-opt-out-engine
  • mail-opt-out-core
  • mail-opt-out-mailchimp

Core

  • 1 Rename List#number => List#code
  • 5 Make List Name Unique on Number Scope
  • 3 Make configurable email method on User#email
  • 3 Make configurable User#name, first_name, last_name
  • 1 Add Code Doc

Services (Mailchimp)

  • 2 Set FirstName LastName if it possible

License

The gem is available as open source under the terms of the MIT License.

About

Simple Mail List Opt In-Out Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors