Sha256: 3470ce5088c7fcd69054b4a056d4389bf8a82888f1fe81ca75fdd092fd007b7c

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true

module Mailersend
  # Templates endpoint from MailerSend API.
  class Templates
    attr_accessor :client,
                  :page,
                  :limit,
                  :template_id

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

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

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

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

    def delete(template_id:)
      client.http.delete("#{MAILERSEND_API_URL}/templates/#{template_id}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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