Sha256: ce7a96700961d9c465b289a5926fa70945f076bb52619439115a9caba3f9f1bf

Contents?: true

Size: 997 Bytes

Versions: 5

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

require 'test_helper'

class PingConversationTest < Test::Unit::TestCase
  def test_create_conversation
    fake "api/ping-api/v1/conversations", method: :post, body: load_fixture('ping/conversation')

    conversation = ShopifyAPI::Ping::Conversation.new(
      topic: 'my topic',
      participants: [
        {
          name: 'foo',
          id: 'test',
          group: 'customer',
        },
      ]
    )

    conversation.save

    assert_equal "d315d4f7-53bd-49ec-8808-23f6db3c641a", conversation.id
  end

  def test_send_message
    fake "api/ping-api/v1/conversations/123/messages", method: :post, body: load_fixture('ping/message')

    conversation = ShopifyAPI::Ping::Conversation.new(id: '123')
    message = conversation.send_message(
      dedupe_key: SecureRandom.uuid,
      content: {
        text: "Hello from shopify_api",
      },
      sender_id: 'test',
    )

    assert_equal "d0c7a2e6-8084-4e79-8483-e4a1352b81f7", message.id
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shopify_api-5.2.1 test/ping/conversation_test.rb
shopify_api-5.2.0 test/ping/conversation_test.rb
shopify_api-5.1.0 test/ping/conversation_test.rb
shopify_api-5.0.0 test/ping/conversation_test.rb
shopify_api-4.13.0 test/ping/conversation_test.rb