Class: Prospector::Client
- Inherits:
-
Object
- Object
- Prospector::Client
- Defined in:
- lib/prospector/client.rb
Constant Summary collapse
- DEFAULT_ENDPOINT =
'http://api.gemprospector.com/v1/specifications.json'
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Class Method Summary collapse
Instance Method Summary collapse
- #client_secret ⇒ Object
- #deliver(specifications, ruby_version) ⇒ Object
-
#initialize(endpoint = DEFAULT_ENDPOINT, secret_token = nil, client_secret = nil) ⇒ Client
constructor
A new instance of Client.
- #secret_token ⇒ Object
Constructor Details
#initialize(endpoint = DEFAULT_ENDPOINT, secret_token = nil, client_secret = nil) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 |
# File 'lib/prospector/client.rb', line 11 def initialize(endpoint = DEFAULT_ENDPOINT, secret_token = nil, client_secret = nil) @endpoint = URI(endpoint) @secret_token = secret_token @client_secret = client_secret end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/prospector/client.rb', line 5 def endpoint @endpoint end |
Class Method Details
.deliver(*args) ⇒ Object
7 8 9 |
# File 'lib/prospector/client.rb', line 7 def self.deliver(*args) new.deliver(*args) end |
Instance Method Details
#client_secret ⇒ Object
29 30 31 |
# File 'lib/prospector/client.rb', line 29 def client_secret @client_secret ||= Prospector.configuration.client_secret end |
#deliver(specifications, ruby_version) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/prospector/client.rb', line 17 def deliver(specifications, ruby_version) set_request_body(specifications, ruby_version) case response.code when "401" then raise AuthenticationError when "402" then raise AccountSubscriptionStatusError, json[:error] when "200" then return true else raise UnknownError end end |
#secret_token ⇒ Object
33 34 35 |
# File 'lib/prospector/client.rb', line 33 def secret_token @secret_token ||= Prospector.configuration.secret_token end |