Sha256: bc56bd3f9d1a08c14beca99ac9a44e133f5d07aec18f59c97fa43625d14c3263

Contents?: true

Size: 915 Bytes

Versions: 6

Compression:

Stored size: 915 Bytes

Contents

require 'excon'

module QuickappsFeedback
  class Feedback
    attr_reader :uid, :subject, :message, :support_type

    def initialize(uid,full_message,support_type)
      @uid = uid
      @subject, @message = full_message.split(':',2)
      @message ||= @subject
      @support_type = support_type
    end

    def user_account
      return @user_account if @user_account
      connection = Excon.new(ENV['USER_ACCOUNT_API'])
      result = connection.get(path: '/api/user_accounts',
                              headers: {'X-API-Token' => ENV['USER_ACCOUNT_API_KEY'] },
                              query: {uid: uid,
                                      provider: 'mxit'},
                              :expects => 200)
      @user_account = JSON.parse(result.body).first
    end

    def user_email
      user_account['email']
    end

    def user_real_name
      user_account['real_name']
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
quickapps_feedback-0.1.5 lib/quickapps_feedback/feedback.rb
quickapps_feedback-0.1.4 lib/quickapps_feedback/feedback.rb
quickapps_feedback-0.1.3 lib/quickapps_feedback/feedback.rb
quickapps_feedback-0.1.2 lib/quickapps_feedback/feedback.rb
quickapps_feedback-0.1.1 lib/quickapps_feedback/feedback.rb
quickapps_feedback-0.1.0 lib/quickapps_feedback/feedback.rb