Class: ShedCloud::PartnerApi::Auth
- Inherits:
-
Object
- Object
- ShedCloud::PartnerApi::Auth
- Defined in:
- lib/shedcloud/partner_api/auth.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
Instance Method Summary collapse
- #api_key? ⇒ Boolean
-
#initialize(api_key: nil, client_id: nil, client_secret: nil) ⇒ Auth
constructor
A new instance of Auth.
- #validate! ⇒ Object
Constructor Details
#initialize(api_key: nil, client_id: nil, client_secret: nil) ⇒ Auth
Returns a new instance of Auth.
8 9 10 11 12 |
# File 'lib/shedcloud/partner_api/auth.rb', line 8 def initialize(api_key: nil, client_id: nil, client_secret: nil) @api_key = api_key @client_id = client_id @client_secret = client_secret end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/shedcloud/partner_api/auth.rb', line 6 def api_key @api_key end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
6 7 8 |
# File 'lib/shedcloud/partner_api/auth.rb', line 6 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
6 7 8 |
# File 'lib/shedcloud/partner_api/auth.rb', line 6 def client_secret @client_secret end |
Instance Method Details
#api_key? ⇒ Boolean
21 22 23 |
# File 'lib/shedcloud/partner_api/auth.rb', line 21 def api_key? !api_key.to_s.strip.empty? end |
#validate! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/shedcloud/partner_api/auth.rb', line 14 def validate! has_key = !api_key.to_s.strip.empty? has_oauth = !client_id.to_s.strip.empty? && !client_secret.to_s.strip.empty? raise ArgumentError, 'auth: set exactly one of api_key or client_id+client_secret' if has_key == has_oauth end |