Sha256: 0c9972ad72ccbe70788b1b2d93b400031be692a7d2e19dffac1393d68423d50b

Contents?: true

Size: 1.6 KB

Versions: 3

Compression:

Stored size: 1.6 KB

Contents

module Klaviyo
  module Templates
    # https://www.klaviyo.com/docs/api/email-templates
    #
    module ApiOperations

      def all(client:)
        client.conn.get('/api/v1/email-templates', api_key: client.api_key)
      end

      def create(client:, name:, html:)
        client.conn.post(
          '/api/v1/email-templates',
          api_key: client.api_key,
          name: name,
          html: html
        )
      end

      def update(client:, id:, name:, html:)
        client.conn.put(
          "/api/v1/email-template/#{id}",
          api_key: client.api_key,
          name: name,
          html: html
        )
      end

      def delete(client:, id:)
        client.conn.delete(
          "/api/v1/email-template/#{id}",
          api_key: client.api_key
        )
      end

      def clone(client:, id:, name:)
        client.conn.post(
          "/api/v1/email-template/#{id}/clone",
          api_key: client.api_key,
          name: name
        )
      end

      def render(client:, id:, context:)
        client.conn.post(
          "/api/v1/email-template/#{id}/render",
          api_key: client.api_key,
          context: context
        )
      end

      def render_and_send(
            client:, id:, context:,
            service:, from_email:, from_name:, subject:, to:
          )
        client.conn.post(
          "/api/v1/email-template/#{id}/send",
          api_key: client.api_key,
          context: context,
          service: service,
          from_email: from_email,
          from_name: from_name,
          subject: subject,
          to: to
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
parallel588-klaviyo-0.7.0 lib/klaviyo/templates/api_operations.rb
parallel588-klaviyo-0.6.0 lib/klaviyo/templates/api_operations.rb
parallel588-klaviyo-0.5.0 lib/klaviyo/templates/api_operations.rb