Class: ZammadAPI::Transport
- Inherits:
-
Object
- Object
- ZammadAPI::Transport
- Defined in:
- lib/zammad_api/transport.rb
Instance Attribute Summary collapse
-
#on_behalf_of ⇒ Object
Returns the value of attribute on_behalf_of.
-
#password ⇒ Object
Returns the value of attribute password.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(config, logger) ⇒ Transport
constructor
A new instance of Transport.
Constructor Details
#initialize(config, logger) ⇒ Transport
Returns a new instance of Transport.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/zammad_api/transport.rb', line 9 def initialize(config, logger) @logger = logger @logger.debug "Transport to #{config[:url]} with #{config[:user]}:#{config[:password]}" @conn = Faraday.new(url: config[:url]) do |faraday| #faraday.request :url_encoded # form-encode POST params #faraday.response :logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end @conn.headers[:user_agent] = 'Zammad API Ruby' if config[:http_token] && !config[:http_token].empty? @conn.request :authorization, 'Token', config[:http_token] elsif config[:oauth2_token] && !config[:oauth2_token].empty? @conn.request :authorization, 'Bearer', config[:oauth2_token] else @conn.request :authorization, :basic, config[:user], config[:password] end end |
Instance Attribute Details
#on_behalf_of ⇒ Object
Returns the value of attribute on_behalf_of.
7 8 9 |
# File 'lib/zammad_api/transport.rb', line 7 def on_behalf_of @on_behalf_of end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/zammad_api/transport.rb', line 7 def password @password end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/zammad_api/transport.rb', line 7 def url @url end |
#user ⇒ Object
Returns the value of attribute user.
7 8 9 |
# File 'lib/zammad_api/transport.rb', line 7 def user @user end |