glassdoor-api 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2991d9e4fcf741922cb359f95d56ce1ab24e44a4
4
- data.tar.gz: 895b858793a7b2769a02cbda7a7d0e95bfb75408
2
+ SHA256:
3
+ metadata.gz: a7ba69f8d5c8dff21f0e236a38ebaa0e7a33151e5b2add6f3dc94137788b50cb
4
+ data.tar.gz: 1d0fdf47b82c83de624ea6d2398f23ed011c6ee1c79ddcfff71a27464e32fb25
5
5
  SHA512:
6
- metadata.gz: a55935b00063d47b33287d9fb36b6afd493ca6ddd5f6642ec3a0c204147f030b756e71541cc5b3c8fcf0e4c9f5921f056ec30854fa39d2b8f576785e5dd88294
7
- data.tar.gz: 96923436400c55cc052b7d8f642943c605e575965ad70adaed0f1c324b6743c8255b64901fd11ec2b469426c2b8eaf74bcebcfaa6bfec993b2f1325d81fd5ed2
6
+ metadata.gz: d4fa2de84ee0af5b7d334cbd5f74c2dcfdd56e59d6e7133e117ea6159502f6d5f9420ee78e80e1b6431a27d7419323f0954ba512843e6e0296b291f40a0c522a
7
+ data.tar.gz: 8c60f5316e5d9e7d0ade834c2f39f86083dfb480db903b75f29d2ecbb59b7769d566f2215ac356f43aa00ca6b646c4f755e1b7deb0f3f0da9746fee98a4034da
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Glassdoor::Api
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/glassdoor/api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This is an unofficial gem to utilize Glassdoor's API.
6
4
 
7
5
  ## Installation
8
6
 
@@ -20,9 +18,27 @@ Or install it yourself as:
20
18
 
21
19
  $ gem install glassdoor-api
22
20
 
23
- ## Usage
21
+ ## Setup
24
22
 
25
- TODO: Write usage instructions here
23
+ 1. Require the gem with
24
+ ```ruby
25
+ require 'glassdoor'
26
+ ```
27
+ 2. Visit the [Glassdoor API page](https://www.glassdoor.com/developer/register_input.htm) and register for an API key.
28
+ 3. You will receive an email with your partner id and partner key
29
+ 4. Setup configuration with:
30
+ ```ruby
31
+ config = Glassdoor.configuration
32
+ config.partner_id = "your-partner-id"
33
+ config.partner_key = "your-partner-key"
34
+ ```
35
+
36
+ ## Searching for a Company
37
+
38
+ 1. Search using title
39
+ ```ruby
40
+ Glassdoor::Clients::Company.find_by_title("apple")
41
+ ```
26
42
 
27
43
  ## Development
28
44
 
@@ -1,6 +1,15 @@
1
1
  module Glassdoor
2
2
  module Clients
3
3
  module Company
4
+ def self.search_by_title(title, page = 1, per_page = 20)
5
+ api = Glassdoor::Utils::Api.instance
6
+ hash = api.gd_get(action: 'employers', q: title, pn: page, ps: per_page)
7
+
8
+ hash['employers'].map do |company|
9
+ Models::Company.new(company)
10
+ end
11
+ end
12
+
4
13
  def self.find_by_title(title)
5
14
  api = Glassdoor::Utils::Api.instance
6
15
  hash = api.gd_get(action: 'employers', q: title)
@@ -1,6 +1,6 @@
1
1
  module Glassdoor
2
2
  class Config
3
- attr_accessor :partner_id, :partner_key, :base_uri, :time_out, :format, :version_api
3
+ attr_accessor :partner_id, :partner_key, :base_url, :time_out, :format, :version_api
4
4
 
5
5
  def initialize
6
6
  set_defaults
@@ -22,7 +22,7 @@ module Glassdoor
22
22
  def set_defaults
23
23
  @partner_id = 'ruby-glassdoor-api' # Get a developer key at https://www.glassdoor.com/api/index.htm
24
24
  @partner_key = 'ruby-glassdoor-api'
25
- @base_uri = 'http://api.glassdoor.com/api/api.htm'
25
+ @base_url = 'https://api.glassdoor.com/api/api.htm'
26
26
  @time_out = 5
27
27
  @format = 'json'
28
28
  @version_api = '1'
@@ -1,7 +1,7 @@
1
1
  module Glassdoor
2
2
  module Models
3
3
  class Company
4
- attr_accessor :id, :name, :url, :industry, :logo,
4
+ attr_reader :id, :name, :url, :industry, :sector_name, :logo,
5
5
  :overall_rating, :culture_and_values_rating, :senior_leadership_rating,
6
6
  :compensation_and_benefits_rating, :career_opportunities_rating,
7
7
  :work_life_balance_rating, :recommend_to_friend_rating, :review
@@ -12,6 +12,7 @@ module Glassdoor
12
12
  @name = args['name'] || ''
13
13
  @url = args['website'] || ''
14
14
  @industry = args['industry'] || ''
15
+ @sector_name = args['sectorName'] || ''
15
16
  @overall_rating = args['overallRating'].to_f
16
17
  @culture_and_values_rating = args['cultureAndValuesRating'].to_f
17
18
  @senior_leadership_rating = args['seniorLeadershipRating'].to_f
@@ -1,7 +1,7 @@
1
1
  module Glassdoor
2
2
  module Models
3
3
  class Review
4
- attr_accessor :id, :date, :job_title, :location, :logo,
4
+ attr_reader :id, :date, :job_title, :location, :logo,
5
5
 
6
6
  :headline, :pros, :cons, :overall
7
7
 
@@ -1,50 +1,43 @@
1
- require 'httparty'
1
+ require 'rest-client'
2
+ require 'addressable'
2
3
 
3
4
  module Glassdoor
4
5
  module Utils
5
- class RequestError < Exception; end
6
- class ResponseUnsuccessError < Exception; end
6
+ class RequestError < StandardError; end
7
+ class ResponseUnsuccessError < StandardError; end
7
8
 
8
9
  class Api
9
- include HTTParty
10
-
11
- base_uri 'http://api.glassdoor.com/api/api.htm'
12
-
13
10
  def self.instance
14
- api = Glassdoor::Utils::Api.new
15
- api
11
+ Glassdoor::Utils::Api.new
16
12
  end
17
13
 
18
14
  def initialize
19
- self.class.default_params 't.p' => Glassdoor.configuration.partner_id,
20
- 't.k' => Glassdoor.configuration.partner_key,
21
- userip: '0.0.0.0',
22
- useragent: '',
23
- v: Glassdoor.configuration.version_api,
24
- format: 'json',
25
- page: ''
26
-
27
-
28
- self.class.default_timeout Glassdoor.configuration.time_out
15
+ @default_params = {
16
+ 't.p' => Glassdoor.configuration.partner_id,
17
+ 't.k' => Glassdoor.configuration.partner_key,
18
+ userip: '0.0.0.0',
19
+ useragent: '',
20
+ v: Glassdoor.configuration.version_api,
21
+ format: 'json',
22
+ page: ''
23
+ }
29
24
  end
30
25
 
31
26
  def gd_get(options={})
32
- self.class.base_uri Glassdoor.configuration.base_uri
33
- options = options.merge(self.class.default_params)
34
- response = self.class.get('', query: options)
35
- validate_response(response)
27
+ uri = Addressable::URI.parse(Glassdoor.configuration.base_url)
28
+ uri.query_values = options.merge(@default_params)
29
+
30
+ response = RestClient::Request.execute(method: :get, url: uri.to_s, timeout: Glassdoor.configuration.time_out)
31
+ response_hash = MultiJson.load(response)
32
+ validate_response(response_hash)
36
33
  end
37
34
 
38
- def validate_response(response)
39
- if response.code == 200
40
- hash = JSON.parse(response.body)
41
- unless hash['success']
42
- raise ResponseUnsuccessError.new hash['status']
43
- end
44
- hash['response']
45
- else
46
- raise RequestError.new response.message
35
+ def validate_response(response_hash)
36
+ unless response_hash['success']
37
+ raise ResponseUnsuccessError.new response_hash['status']
47
38
  end
39
+
40
+ response_hash['response']
48
41
  end
49
42
  end
50
43
  end
@@ -1,3 +1,3 @@
1
1
  module Glassdoor
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glassdoor-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bazylchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.9'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,39 +81,47 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: httparty
84
+ name: rest-client
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0.11'
89
+ version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '0.11'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: json
98
+ name: addressable
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.7'
104
101
  - - ">="
105
102
  - !ruby/object:Gem::Version
106
- version: 1.7.7
103
+ version: '0'
107
104
  type: :runtime
108
105
  prerelease: false
109
106
  version_requirements: !ruby/object:Gem::Requirement
110
107
  requirements:
111
- - - "~>"
108
+ - - ">="
112
109
  - !ruby/object:Gem::Version
113
- version: '1.7'
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: multi_json
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
114
115
  - - ">="
115
116
  - !ruby/object:Gem::Version
116
- version: 1.7.7
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
117
125
  description: Wrapper for Glassdoor API
118
126
  email:
119
127
  - ilya.bazylchuk@gmail.com
@@ -151,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
159
  - !ruby/object:Gem::Version
152
160
  version: '0'
153
161
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.2.2
162
+ rubygems_version: 3.1.2
156
163
  signing_key:
157
164
  specification_version: 4
158
165
  summary: Wrapper for Glassdoor API