Sha256: 46368170b9b2880018ac61268c463f3be7e322ef1c56736cfe976e64d7090e35

Contents?: true

Size: 908 Bytes

Versions: 2

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

module Mailersend
  # Recipients endpoint from MailerSend API.
  class Recipients
    attr_accessor :client,
                  :page,
                  :limit,
                  :recipient_id

    def initialize(client = Mailersend::Client.new)
      @client = client
      @page = page
      @limit = limit
      @recipient_id = recipient_id
    end

    def list(page: nil, limit: nil)
      hash = {
        'page' => page,
        'limit' => limit
      }

      client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/recipients',
                                       query: URI.encode_www_form(hash)))
    end

    def single(recipient_id:)
      client.http.get("#{MAILERSEND_API_URL}/recipients/#{recipient_id}")
    end

    def delete(recipient_id:)
      client.http.delete("#{MAILERSEND_API_URL}/recipients/#{recipient_id}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mailersend-ruby-2.0.3 lib/mailersend/recipients/recipients.rb
mailersend-ruby-2.0.2 lib/mailersend/recipients/recipients.rb