Sha256: bfcde104e76fd41162d78ce79ea89a08e0ab2a78c66a0756332835055689f81c

Contents?: true

Size: 913 Bytes

Versions: 13

Compression:

Stored size: 913 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: API_BASE_HOST, path: '/v1/templates',
                                       query: URI.encode_www_form(hash)))
    end

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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mailersend-ruby-2.0.1 lib/mailersend/templates/templates.rb
mailersend-ruby-2.0.0 lib/mailersend/templates/templates.rb
mailersend-ruby-1.6.0 lib/mailersend/templates/templates.rb
mailersend-ruby-1.5.2 lib/mailersend/templates/templates.rb
mailersend-ruby-1.5.1 lib/mailersend/templates/templates.rb
mailersend-ruby-1.5.0 lib/mailersend/templates/templates.rb
mailersend-ruby-1.4.0 lib/mailersend/templates/templates.rb
mailersend-ruby-1.3.2 lib/mailersend/templates/templates.rb
mailersend-ruby-1.3.1 lib/mailersend/templates/templates.rb
mailersend-ruby-1.3.0 lib/mailersend/templates/templates.rb
mailersend-ruby-1.2.0 lib/mailersend/templates/templates.rb
mailersend-ruby-1.1.0 lib/mailersend/templates/templates.rb
mailersend-ruby-1.0.1 lib/mailersend/templates/templates.rb