Class: Proz::Freelancer
- Inherits:
-
Object
- Object
- Proz::Freelancer
- Includes:
- HTTParty
- Defined in:
- lib/proz/freelancer.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #freelancer ⇒ Object
-
#initialize(key:, uuid:) ⇒ Freelancer
constructor
A new instance of Freelancer.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(key:, uuid:) ⇒ Freelancer
Returns a new instance of Freelancer.
8 9 10 11 |
# File 'lib/proz/freelancer.rb', line 8 def initialize(key:, uuid:) @key = key @uuid = uuid end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
32 33 34 |
# File 'lib/proz/freelancer.rb', line 32 def method_missing(name, *args, &block) freelancer.has_key?(name.to_s) ? freelancer[name.to_s] : super end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/proz/freelancer.rb', line 7 def key @key end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
7 8 9 |
# File 'lib/proz/freelancer.rb', line 7 def uuid @uuid end |
Instance Method Details
#freelancer ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/proz/freelancer.rb', line 13 def freelancer case when freelancer_response.has_key?('error') if freelancer_response['error'].eql?('invalid_api_key') raise 'Invalid API Key' else raise 'Invalid Request' end when freelancer_response.has_key?('error_messages') if freelancer_response['error_messages'][0].eql?('No freelancer was found with that UUID.') raise 'No freelancer was found with that UUID' else raise 'Invalid Request' end else freelancer_response['data'] end end |