Module: CodasetAPI
- Defined in:
- lib/codaset/codaset-api.rb
Defined Under Namespace
Classes: Base, Error, Project, Ticket
Class Attribute Summary collapse
-
.account ⇒ Object
Returns the value of attribute account.
-
.client_id ⇒ Object
Returns the value of attribute client_id.
-
.client_secret ⇒ Object
Returns the value of attribute client_secret.
-
.domain_format ⇒ Object
Returns the value of attribute domain_format.
-
.host_format ⇒ Object
Returns the value of attribute host_format.
-
.password ⇒ Object
Returns the value of attribute password.
-
.protocol ⇒ Object
Returns the value of attribute protocol.
-
.site ⇒ Object
Returns the value of attribute site.
-
.token ⇒ Object
Returns the value of attribute token.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.access_token(master) ⇒ Object
Gets the OAuth2’s access token.
- .authenticate(username, password, client_id, client_secret) ⇒ Object
- .resources ⇒ Object
Class Attribute Details
.account ⇒ Object
Returns the value of attribute account.
19 20 21 |
# File 'lib/codaset/codaset-api.rb', line 19 def account @account end |
.client_id ⇒ Object
Returns the value of attribute client_id.
18 19 20 |
# File 'lib/codaset/codaset-api.rb', line 18 def client_id @client_id end |
.client_secret ⇒ Object
Returns the value of attribute client_secret.
18 19 20 |
# File 'lib/codaset/codaset-api.rb', line 18 def client_secret @client_secret end |
.domain_format ⇒ Object
Returns the value of attribute domain_format.
18 19 20 |
# File 'lib/codaset/codaset-api.rb', line 18 def domain_format @domain_format end |
.host_format ⇒ Object
Returns the value of attribute host_format.
18 19 20 |
# File 'lib/codaset/codaset-api.rb', line 18 def host_format @host_format end |
.password ⇒ Object
Returns the value of attribute password.
18 19 20 |
# File 'lib/codaset/codaset-api.rb', line 18 def password @password end |
.protocol ⇒ Object
Returns the value of attribute protocol.
18 19 20 |
# File 'lib/codaset/codaset-api.rb', line 18 def protocol @protocol end |
.site ⇒ Object
Returns the value of attribute site.
18 19 20 |
# File 'lib/codaset/codaset-api.rb', line 18 def site @site end |
.token ⇒ Object
Returns the value of attribute token.
18 19 20 |
# File 'lib/codaset/codaset-api.rb', line 18 def token @token end |
.username ⇒ Object
Returns the value of attribute username.
18 19 20 |
# File 'lib/codaset/codaset-api.rb', line 18 def username @username end |
Class Method Details
.access_token(master) ⇒ Object
Gets the OAuth2’s access token
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/codaset/codaset-api.rb', line 45 def access_token(master) @auth_url = '/authorization/token' consumer = OAuth2::Client.new(master.client_id, master.client_secret, {:site => {:url => master.site, :ssl => {:verify => OpenSSL::SSL::VERIFY_NONE, :ca_file => nil } }, :authorize_url => @auth_url, :parse_json => true}) response = consumer.request(:post, @auth_url, {:grant_type => 'password', :client_id => master.client_id, :client_secret => master.client_secret, :username => master.username, :password => master.password}, 'Content-Type' => 'application/x-www-form-urlencoded') OAuth2::AccessToken.new(consumer, response['access_token']).token end |
.authenticate(username, password, client_id, client_secret) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/codaset/codaset-api.rb', line 21 def authenticate(username, password, client_id, client_secret) @username = username @password = password @client_id = client_id @client_secret = client_secret @site = 'https://api.codaset.com' self::Base.user = username self::Base.password = password self::Base.site = @site self.token = access_token(self) end |
.resources ⇒ Object
77 78 79 |
# File 'lib/codaset/codaset-api.rb', line 77 def resources @resources ||= [] end |