Class: Ticketlocker::Client
- Inherits:
-
Object
- Object
- Ticketlocker::Client
- Defined in:
- lib/ticketlocker/client.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Instance Method Summary collapse
-
#initialize(args) ⇒ Client
constructor
A new instance of Client.
- #validate ⇒ Object (also: #valid?)
Constructor Details
#initialize(args) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ticketlocker/client.rb', line 9 def initialize(args) @token = args[:token] @base_url = args.fetch(:base_url, 'http://ticketocker.io/api') @conn = Faraday.new(url: base_url) do |faraday| faraday.request :json faraday.response :mashify faraday.response :json faraday.response :logger faraday.token_auth @token faraday.headers['User-Agent'] = "ticketlocker-ruby/#{Ticketlocker::VERSION}" faraday.adapter Faraday.default_adapter end if valid? return else raise Ticketlocker::Ruby::BadTokenError end end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
7 8 9 |
# File 'lib/ticketlocker/client.rb', line 7 def conn @conn end |
Instance Method Details
#validate ⇒ Object Also known as: valid?
32 33 34 35 |
# File 'lib/ticketlocker/client.rb', line 32 def validate response = conn.get('/api/validate') response.success? end |