require 'helper'

class TestAyeSms < Minitest::Test

  def setup
    VCR.insert_cassette 'ayeApi', match_requests_on: [:path, :method]

    @api = AyeSms.new(base_url: 'https://ayesms.pl',
                      client_id: '4884405928e1341ff33b10ae57aa926ecbcb4c7342e9ae630e08d765df1a0762',
                      client_secret: 'b320437b4501c163d3c84e518fc26248b75c3a851f5513691a5ed638c9c7dd19')
  end

  def teardown
    VCR.eject_cassette
  end

  def test_account_ballance
    current_account  = @api.current_account
    assert_includes current_account.keys, 'credits_left'
    assert_equal current_account.credits_left, 983
  end

  def test_sms_create
    content   = 'Hello from Aye'
    recipient = '+48793376378'
    message   = @api.send_sms(recipient: recipient, content: content)

    assert_equal message.content, content
    assert_equal message.recipient, recipient
  end

  def test_sms_get
    message_id = 'ffe2a1f600007b5d206fbac1'
    message    = @api.get_sms(message_id)

    assert_equal message.content, "Hello from Aye"
    assert_equal message.recipient, "+48793376378"
  end
end
