lib/travis/client/methods.rb in travis-1.11.1 vs lib/travis/client/methods.rb in travis-1.12.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'travis/client'
require 'yaml'
module Travis
module Client
@@ -15,16 +17,17 @@
def api_endpoint
session.uri
end
def github_auth(github_token)
- reply = session.post_raw("/auth/github", :github_token => github_token)
- unless reply.respond_to?(:key?) && reply.key?("access_token")
- raise InvalidTokenError, 'token is invalid, or does not have sufficient scope; see https://docs.travis-ci.com/user/github-oauth-scopes/ for more information on scope'
+ reply = session.post_raw('/auth/github', github_token:)
+ unless reply.respond_to?(:key?) && reply.key?('access_token')
+ raise InvalidTokenError,
+ 'token is invalid, or does not have sufficient scope; see https://docs.travis-ci.com/user/github-oauth-scopes/ for more information on scope'
end
- session.access_token = reply["access_token"]
+ session.access_token = reply['access_token']
end
def explicit_api_endpoint?
@explicit_api_endpoint ||= false
end
@@ -65,26 +68,28 @@
def account(name)
session.find_one(Account, name)
end
def accounts
- session.find_many(Account, :all => true)
+ session.find_many(Account, all: true)
end
def broadcasts
session.find_many(Broadcast)
end
def restart(entity)
# btw, internally we call this reset, not restart, as it resets the state machine
# but we thought that would be too confusing
raise Error, "cannot restart a #{entity.class.one}" unless entity.restartable?
+
session.post_raw("/#{entity.class.many}/#{entity.id}/restart")
entity.reload
end
def cancel(entity)
raise Error, "cannot cancel a #{entity.class.one}" unless entity.cancelable?
+
session.post_raw("/#{entity.class.many}/#{entity.id}/cancel")
entity.reload
end
def logout