Sha256: a9ea48b2c0eec791b3efdc027906a5861bb67c271dcc10090e82042a04885528

Contents?: true

Size: 561 Bytes

Versions: 3

Compression:

Stored size: 561 Bytes

Contents

# frozen_string_literal: true

module Whats
  module Actions
    class SendMessage
      PATH = "/v1/messages"

      def initialize(client, wa_id, body)
        @client = client
        @wa_id  = wa_id
        @body   = body
      end

      def call
        client.request PATH, payload
      end

      private

      attr_reader :client, :wa_id, :body

      def payload
        {
          recipient_type: "individual",
          to: wa_id,
          type: "text",
          text: {
            body: body
          }
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
whatsapp-1.0.0 lib/whats/actions/send_message.rb
whatsapp-0.1.5 lib/whats/actions/send_message.rb
whatsapp-0.1.4 lib/whats/actions/send_message.rb