Class: LivePaper::QrTrigger
- Inherits:
-
Trigger
- Object
- BaseObject
- Trigger
- LivePaper::QrTrigger
- Defined in:
- lib/live_paper/qr_trigger.rb
Constant Summary collapse
- DEFAULT_SUBSCRIPTION =
:month
Constants included from HttpClient
HttpClient::AUTH_URL, HttpClient::LP_API_HOST
Instance Attribute Summary collapse
-
#qrcode_url ⇒ Object
Returns the value of attribute qrcode_url.
Attributes inherited from Trigger
Attributes inherited from BaseObject
#date_created, #date_modified, #id, #link, #name
Instance Method Summary collapse
Methods inherited from Trigger
api_url, item_key, list_key, parse
Methods inherited from BaseObject
api_url, #assign_attributes, create, #delete, #errors, get, #initialize, item_key, list, list_key, parse, #rel, #save, #update
Methods included from HttpClient
#check_response, #http_request, #request_access_token, #request_handling_auth, #send_request
Constructor Details
This class inherits a constructor from LivePaper::BaseObject
Instance Attribute Details
#qrcode_url ⇒ Object
Returns the value of attribute qrcode_url.
5 6 7 |
# File 'lib/live_paper/qr_trigger.rb', line 5 def qrcode_url @qrcode_url end |
Instance Method Details
#download_qrcode ⇒ Object
16 17 18 19 20 21 |
# File 'lib/live_paper/qr_trigger.rb', line 16 def download_qrcode QrTrigger.request_handling_auth(self.qrcode_url, 'GET') do |request| response = QrTrigger.send_request(request) response.body.empty? ? nil : response.body end end |
#parse(data) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/live_paper/qr_trigger.rb', line 9 def parse(data) data = JSON.parse(data, symbolize_names: true)[:trigger] assign_attributes data self.qrcode_url=data[:link].select { |item| item[:rel] == "image" }.first[:href] self end |