Sha256: e837048ccfa82c0dd0c14b36be86dd1f6ed92e1ae285855e17dcc6f6324ef059

Contents?: true

Size: 544 Bytes

Versions: 3

Compression:

Stored size: 544 Bytes

Contents

# frozen_string_literal: true

module DashamailTransactional
  class Response
    def initialize(answer)
      @answer = answer
      @body   = JSON.parse(@answer.body)['response']
    end

    def success?
      @body.dig('msg', 'err_code').to_i.zero?
    end

    def http_code
      @answer.code
    end

    def text
      @body.dig('msg', 'text')
    end

    def transaction_id
      @body.dig('data', 'transaction_id')
    end

    def data
      @body['data']
    end

    attr_reader :body

    def raw
      @answer
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dashamail_transactional-0.1.3.1 lib/dashamail/response.rb
dashamail_transactional-0.1.3 lib/dashamail/response.rb
dashamail_transactional-0.1.2 lib/dashamail/response.rb