Class: CommitLive::Status
- Inherits:
-
Object
- Object
- CommitLive::Status
- Defined in:
- lib/commit-live/lesson/status.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#netrc ⇒ Object
readonly
Returns the value of attribute netrc.
-
#sentry ⇒ Object
readonly
Returns the value of attribute sentry.
Instance Method Summary collapse
-
#initialize ⇒ Status
constructor
A new instance of Status.
- #token ⇒ Object
- #update(type, trackName) ⇒ Object
Constructor Details
#initialize ⇒ Status
Returns a new instance of Status.
10 11 12 13 14 |
# File 'lib/commit-live/lesson/status.rb', line 10 def initialize() @api = CommitLive::API.new @netrc = CommitLive::NetrcInteractor.new() @sentry = CommitLive::Sentry.new() end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
8 9 10 |
# File 'lib/commit-live/lesson/status.rb', line 8 def api @api end |
#netrc ⇒ Object (readonly)
Returns the value of attribute netrc.
8 9 10 |
# File 'lib/commit-live/lesson/status.rb', line 8 def netrc @netrc end |
#sentry ⇒ Object (readonly)
Returns the value of attribute sentry.
8 9 10 |
# File 'lib/commit-live/lesson/status.rb', line 8 def sentry @sentry end |
Instance Method Details
#token ⇒ Object
16 17 18 19 |
# File 'lib/commit-live/lesson/status.rb', line 16 def token netrc.read netrc.password end |
#update(type, trackName) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/commit-live/lesson/status.rb', line 21 def update(type, trackName) begin Timeout::timeout(15) do enc_url = URI.escape("/v1/user/track/#{trackName}") response = api.post( enc_url, headers: { 'access-token' => "#{token}" }, params: { 'method' => 'assignment_status', 'action' => type } ) if response.status != 202 sentry.("Update Lesson Status Failed", { 'url' => enc_url, 'track_name' => trackName, 'params' => { 'method' => 'assignment_status', 'action' => type }, 'response-body' => response.body, 'response-status' => response.status } ) end end rescue Timeout::Error puts "Error while updating lesson status." puts "Please check your internet connection." exit end end |