Class: Proz::FreelancerMatches

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/proz/freelancer_matches.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, language_pair:, **options) ⇒ FreelancerMatches

Returns a new instance of FreelancerMatches.



8
9
10
11
12
# File 'lib/proz/freelancer_matches.rb', line 8

def initialize(key:, language_pair:, **options)
  @key = key
  @language_pair = { language_pair: language_pair }
  @options = options
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/proz/freelancer_matches.rb', line 7

def key
  @key
end

#language_pairObject (readonly)

Returns the value of attribute language_pair.



7
8
9
# File 'lib/proz/freelancer_matches.rb', line 7

def language_pair
  @language_pair
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/proz/freelancer_matches.rb', line 7

def options
  @options
end

Instance Method Details

#freelancer_matchesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/proz/freelancer_matches.rb', line 14

def freelancer_matches
  case
  when freelancer_matches_response.has_key?('error')
    if freelancer_matches_response['error'].eql?('invalid_api_key')
      raise 'Invalid API Key'
    else
      raise 'Invalid Request'
    end
  when freelancer_matches_response.has_key?('meta')
    if freelancer_matches_response['meta']['num_results'].eql?(0)
      {}
    else
      freelancer_matches_response['data']
    end
  else
    freelancer_matches_response['data']
  end
end