whoapi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2689c4e2bf41a7de235e905a3347156742f76b7e
4
+ data.tar.gz: f49692ce83e2b8e2290bc320ce1edf044bdff8f2
5
+ SHA512:
6
+ metadata.gz: 9c27a4a4c29d2a8e697b5f41220413a726b8a0d66965fd10614a441036ccf89307ecbf5c4e91ee72b26e2a289bfef63eed1a9c2400555a41c19d2700301f1ab1
7
+ data.tar.gz: f4f92b2a165060dd6dc543d3cdcfae00da6dca2c9be0197e664c8d71dc40c2d39e1575529e947db1f8916b7d05abf355aa75d2139257805ee6e5dbcf83de723f
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in whoapi.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 WhoAPI ® Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,437 @@
1
+ # Whoapi
2
+
3
+ [WhoAPI](https://whoapi.com) offers a range of services allowing the querying of domain name data. Track everything and never miss a renewal anymore (domain name, certificates, blacklists, etc).
4
+
5
+ This gem wraps all the calls to all the endpoints with easy-to-use Ruby methods.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'whoapi'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install whoapi
22
+
23
+ ## Usage
24
+
25
+ Once you've installed the gem, you're ready to use it - there is no configuration.
26
+
27
+ Here's a quick example on how to use this gem to do a domain availability check.
28
+
29
+ ```ruby
30
+ whoapi = WhoAPI::Client.new(YOUR_API_KEY)
31
+ whoapi.domain_availability('whoapi.com')
32
+ ```
33
+
34
+ This method will return the following hash:
35
+
36
+ ```ruby
37
+ { taken: 1 }
38
+ ```
39
+
40
+ That means, unfortunately, that `whoapi.com` is already registered!
41
+
42
+ See below for all the other available requests.
43
+
44
+ ### API Key
45
+
46
+ You can get an API Key by signing up at [whoapi.com](https://whoapi.com/user/signup). The API Key needs to be passed to the `WhoAPI::Client` at creation.
47
+
48
+ ### Public API
49
+
50
+ All the following methods are accessible on a `WhoAPI::Client` instance.
51
+
52
+ #### List of available methods
53
+
54
+ 1. [Domain Availability](#availability): `#domain_availability(domain_name)`
55
+ 2. [Email Blacklisting](#blacklist): `#blacklist_info(domain_name)`
56
+ 3. [Whois](#whois): `#whois_info(domain_name)`
57
+ 4. [SSL](#ssl): `#ssl_info(domain_name)`
58
+ 5. [Social](#social): `#social_availability(domain_name)`
59
+ 6. [Ranks](#ranks): `#ranking_info(domain_name, full_url = nil)`
60
+ 7. [Meta Data](#meta): `#meta_info(domain_name)`
61
+ 8. [DNS Zone](#dns): `#dns_zone(domain_name)`
62
+ 9. [Screenshot](#screenshot): `#screenshot(domain_name, full_url = nil)`
63
+ 10. [Hostname](#hostname): `#hostname_info(domain_name, ip = nil)`
64
+ 11. [Geo Location](#geo): `#geo_data(domain_name, ip = nil)`
65
+
66
+ #### <a name="availability"></a> 1. Domain Availability
67
+
68
+ Check domain availability for registration.
69
+
70
+ Method: `#domain_availability(domain_name)`
71
+
72
+ Arguments
73
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
74
+
75
+ Example:
76
+
77
+ ```ruby
78
+ WhoAPI::Client.new(YOUR_API_KEY).domain_availability('whoapi.com')
79
+ ```
80
+ Output
81
+
82
+ ```ruby
83
+ { taken: 1 }
84
+ ```
85
+
86
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/domain-availability).
87
+
88
+ #### 2. <a name="blacklist"></a> Email Blacklisting
89
+
90
+ Status of domain name and it's IP address on all the popular email blacklists.
91
+
92
+ Method: `#blacklist_info(domain_name)`
93
+
94
+ Arguments
95
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
96
+
97
+ Example:
98
+
99
+ ```ruby
100
+ WhoAPI::Client.new(YOUR_API_KEY).blacklist_info('whoapi.com')
101
+ ```
102
+ Output
103
+
104
+ ```ruby
105
+ {
106
+ ip: "52.32.117.162",
107
+ blacklisted: "0",
108
+ blacklists: [ {
109
+ tracker: "surbl.org",
110
+ blacklisted: "0"
111
+ },
112
+ {
113
+ tracker: "barracudacentral.org",
114
+ blacklisted: "0"
115
+ },
116
+ {
117
+ tracker: "sorbs.net",
118
+ blacklisted: "0"
119
+ },
120
+ {
121
+ tracker: "spamhaus.org",
122
+ blacklisted: "0"
123
+ } ]
124
+ }
125
+ ```
126
+
127
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/blacklist).
128
+
129
+ #### 3. <a name="whois"></a> Whois
130
+
131
+ Structured and parsed raw WHOIS data such as domain registration & expiry date, owner contact details, nameservers, registrar information etc.
132
+
133
+ Method: `#whois_info(domain_name)`
134
+
135
+ Arguments
136
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
137
+
138
+ Example:
139
+
140
+ ```ruby
141
+ WhoAPI::Client.new(YOUR_API_KEY).whois_info('whoapi.com')
142
+ ```
143
+ Partial Output
144
+
145
+ ```ruby
146
+ {
147
+ whois_server: "whois.publicdomainregistry.com",
148
+ limit_hit: false,
149
+ registered: true,
150
+ premium: false,
151
+ domain_status: ["clienttransferprohibited http://www.icann.org/epp#clienttransferprohibited"],
152
+ date_created: "2011-02-14 15:31:26",
153
+ date_updated: "2015-11-20 13:01:03",
154
+ date_expires: "2021-02-14 00:00:00",
155
+ ...
156
+ }
157
+ ```
158
+
159
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/whois).
160
+
161
+ #### 4. <a name="ssl"></a> SSL
162
+
163
+ Detailed domain certificate information.
164
+
165
+ Method: `#ssl_info(domain_name)`
166
+
167
+ Arguments
168
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
169
+
170
+ Example:
171
+
172
+ ```ruby
173
+ WhoAPI::Client.new(YOUR_API_KEY).ssl_info('whoapi.com')
174
+ ```
175
+ Output
176
+
177
+ ```ruby
178
+ {
179
+ certondomain: true,
180
+ category: "Private Organization",
181
+ organization: "WhoAPI Inc.",
182
+ street: "444 Castro street",
183
+ city: "Mountain View",
184
+ state: "California",
185
+ postalcode: "94041",
186
+ country: "US",
187
+ other: ["US", "Delaware"],
188
+ issuer: "COMODO CA Limited",
189
+ date_issued: "2016-01-11 00:00:00",
190
+ date_expires: "2017-03-11 23:59:59"
191
+ }
192
+ ```
193
+
194
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/ssl).
195
+
196
+ #### 5. <a name="social"></a> Social
197
+
198
+ Domain name availability status on popular social networks.
199
+
200
+ Method: `#social_availability(domain_name)`
201
+
202
+ Arguments
203
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
204
+
205
+ Example:
206
+
207
+ ```ruby
208
+ WhoAPI::Client.new(YOUR_API_KEY).social_availability('whoapi.com')
209
+ ```
210
+ Output
211
+
212
+ ```ruby
213
+ {
214
+ facebook_taken: "0",
215
+ linkedin_taken: "1",
216
+ twitter_taken: "0",
217
+ tumblr_taken: "1",
218
+ appstore_taken: "0",
219
+ appstore_link: "-1"
220
+ }
221
+ ```
222
+
223
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/social).
224
+
225
+ #### 6. <a name="ranks"></a> Ranks
226
+
227
+ Domain rank on popular systems like Google PageRank and Alexa.
228
+
229
+ Method: `#ranking_info(domain_name, full_url = nil)`
230
+
231
+ Arguments
232
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
233
+ - `full_url` (string, optional): optional field if you want to get specific url rank. This parameter will override the `domain_name` if provided.
234
+
235
+ Example:
236
+
237
+ ```ruby
238
+ WhoAPI::Client.new(YOUR_API_KEY).ranking_info('whoapi.com')
239
+ ```
240
+ Output
241
+
242
+ ```ruby
243
+ {
244
+ pr: "4",
245
+ alexa_reach: "310078",
246
+ alexa_popularity: "229302",
247
+ alexa_linksin: "-1",
248
+ email: nil,
249
+ title: nil
250
+ }
251
+ ```
252
+
253
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/ranks).
254
+
255
+ #### 7. <a name="meta"></a> Meta Data
256
+
257
+ Domain content meta tags: title&description.
258
+
259
+ Method: `#meta_info(domain_name)`
260
+
261
+ Arguments
262
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
263
+
264
+ Example:
265
+
266
+ ```ruby
267
+ WhoAPI::Client.new(YOUR_API_KEY).meta_info('whoapi.com')
268
+ ```
269
+ Output
270
+
271
+ ```ruby
272
+ {
273
+ title: "WhoAPI - Domain Data Hosting companies Can Use",
274
+ description: "WhoAPI homepage. Domain data that hosting companies, CSOs, webshops and domain investors can use. API, monitoring, reports, bulk and domain overview."
275
+ }
276
+ ```
277
+
278
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/meta).
279
+
280
+ #### 8. <a name="dns"></a> DNS Zone
281
+
282
+ Complete DNS Zone record in a structured hash.
283
+
284
+ Method: `#dns_zone(domain_name)`
285
+
286
+ Arguments
287
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
288
+
289
+ Example:
290
+
291
+ ```ruby
292
+ WhoAPI::Client.new(YOUR_API_KEY).dns_zone('whoapi.com')
293
+ ```
294
+ Output
295
+
296
+ ```ruby
297
+ {
298
+ ip: "52.32.117.162",
299
+ mx: [
300
+ { priority: "1", name: "aspmx.l.google.com"},
301
+ { priority: "5", name: "alt1.aspmx.l.google.com"},
302
+ { priority: "5", name: "alt2.aspmx.l.google.com"},
303
+ { priority: "10", name: "aspmx2.googlemail.com"},
304
+ { priority: "10", name: "aspmx3.googlemail.com"},
305
+ { priority: "10", name: "aspmx4.googlemail.com"},
306
+ { priority: "10", name: "aspmx5.googlemail.com"}],
307
+ arecord: ["52.32.117.162"],
308
+ soa: {
309
+ nameserver: "ns1.first-ns.de",
310
+ email: "postmaster@robot.first-ns.de",
311
+ serial_number: "2015112000",
312
+ refresh: "14400",
313
+ retry: "1800",
314
+ expire: "604800",
315
+ min_ttl: "86400"},
316
+ nameservers: ["ns1.first-ns.de.", "robotns2.second-ns.de.", "robotns3.second-ns.com."]}
317
+ ```
318
+
319
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/dns-zone).
320
+
321
+ #### 9. <a name="screenshot"></a> Screenshot
322
+
323
+ This method generates website screenshots in actual full vertical size and a website thumbnail.
324
+
325
+ Method: `#screenshot(domain_name, full_url = nil)`
326
+
327
+ Arguments
328
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
329
+ - `full_url` (string, optional): optional field if you want to get specific url rank. This parameter will override the `domain_name` if provided.
330
+
331
+ Example:
332
+
333
+ ```ruby
334
+ WhoAPI::Client.new(YOUR_API_KEY).screenshot('whoapi.com')
335
+ ```
336
+ Output
337
+
338
+ ```ruby
339
+ {
340
+ full_size: "http://178.62.104.203/tmp/e0dddcfa02522f28ea79c5126a24882d.jpg",
341
+ thumbnail: "http://178.62.104.203/tmp/e0dddcfa02522f28ea79c5126a24882d_th.jpg",
342
+ expires: "2016-01-16 11:38 GMT",
343
+ size: "1096x4206"
344
+ }
345
+ ```
346
+
347
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/screenshot).
348
+
349
+ #### 10. <a name="hostname"></a> Hostname
350
+
351
+ Get domain/server hostname.
352
+
353
+ Method: `#hostname_info(domain_name, ip = nil)`
354
+
355
+ Arguments
356
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
357
+ - `ip` (string, optional): Specify direct IP to check; we usually resolve IP from domain name. This parameter overrides domain name if provided.
358
+
359
+ Example:
360
+
361
+ ```ruby
362
+ WhoAPI::Client.new(YOUR_API_KEY).hostname_info('whoapi.com')
363
+ ```
364
+ Output
365
+
366
+ ```ruby
367
+ {
368
+ ip: "52.32.117.162",
369
+ basedomain: "ec2-52-32-117-162.us-west-2.compute.amazonaws.com",
370
+ hostname: "ec2-52-32-117-162.us-west-2.compute.amazonaws.com"
371
+ }
372
+ ```
373
+
374
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/hostname).
375
+
376
+ #### 11. <a name="geo"></a> Geo Location
377
+
378
+ Domain or IP geolocation.
379
+
380
+ Method: `#geo_data(domain_name, ip = nil)`
381
+
382
+ Arguments
383
+ - `domain_name` (string, mandatory): full domain name, including the tld e.g. whoapi.com
384
+ - `ip` (string, optional): Specify direct IP to check; we usually resolve IP from domain name. This parameter overrides domain name if provided.
385
+
386
+ Example:
387
+
388
+ ```ruby
389
+ WhoAPI::Client.new(YOUR_API_KEY).geo_data('google.com')
390
+ ```
391
+ Output
392
+
393
+ ```ruby
394
+ {
395
+ ip: "173.194.116.136",
396
+ geo_cc: "us",
397
+ geo_country: "United States",
398
+ geo_city: nil,
399
+ geo_latitude: nil,
400
+ geo_longitude: nil
401
+ }
402
+ ```
403
+
404
+ Read more about this endpoint [in the WhoAPI documentation](https://whoapi.com/index.php/documentation/api/geo-location).
405
+
406
+ ### Exceptions
407
+
408
+ Exceptions will be raised with a `WhoAPI::Error` in the format `Error code: x - xxxxx`.
409
+
410
+ #### HTTP Error
411
+
412
+ If something goes wrong with the HTTP request being made to access WhoAPI API, a `WhoAPI::Error` exception will be raised with the HTTP status code and the body of the response.
413
+
414
+ Example: `Error code: HTTP 500 - Interval Server Error`
415
+
416
+ #### API Error
417
+
418
+ If the API sends back a known error, a `WhoAPI::Error` will be raised with the API error code and the corresponding error message.
419
+
420
+ Example: `Error code: 12 - Invalid API account.`
421
+
422
+ The list of all errors, with their status code and description, can be found [here](https://whoapi.com/documentation).
423
+
424
+ ## Development
425
+
426
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
427
+
428
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
429
+
430
+ ## Contributing
431
+
432
+ Bug reports and pull requests are welcome on GitHub at https://github.com/whoapi/whoapi-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
433
+
434
+
435
+ ## License
436
+
437
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "whoapi"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ require "whoapi/version"
5
+ require "whoapi/error"
6
+ require "whoapi/symbolize"
7
+ require "whoapi/request"
8
+ require "whoapi/client"
9
+
10
+ module WhoAPI
11
+ end
@@ -0,0 +1,64 @@
1
+ module WhoAPI
2
+ class Client
3
+
4
+ def initialize(api_key)
5
+ @params = { apikey: api_key }
6
+ end
7
+
8
+ def domain_availability(domain_name)
9
+ request('taken', { domain: domain_name })
10
+ end
11
+
12
+ def blacklist_info(domain_name)
13
+ request('blacklist', { domain: domain_name })
14
+ end
15
+
16
+ def whois_info(domain_name)
17
+ request('whois', { domain: domain_name })
18
+ end
19
+
20
+ def ssl_info(domain_name)
21
+ request('cert', { domain: domain_name })
22
+ end
23
+
24
+ def social_availability(domain_name)
25
+ request('social', { domain: domain_name })
26
+ end
27
+
28
+ def meta_info(domain_name)
29
+ request('meta', { domain: domain_name })
30
+ end
31
+
32
+ def dns_zone(domain_name)
33
+ request('dnszone', { domain: domain_name })
34
+ end
35
+
36
+ def ranking_info(domain_name, full_url = nil)
37
+ request('ranks', build_params(domain_name, :fullurl, full_url))
38
+ end
39
+
40
+ def screenshot(domain_name, full_url = nil)
41
+ request('screenshot', build_params(domain_name, :fullurl, full_url))
42
+ end
43
+
44
+ def hostname_info(domain_name, ip = nil)
45
+ request('hostname', build_params(domain_name, :ip, ip))
46
+ end
47
+
48
+ def geo_data(domain_name, ip = nil)
49
+ request('geo', build_params(domain_name, :ip, ip))
50
+ end
51
+
52
+ private
53
+
54
+ def request(type, params)
55
+ WhoAPI::Request.new(type, @params.dup.merge(params)).run
56
+ end
57
+
58
+ def build_params(domain_name, label, value)
59
+ default = { domain: domain_name }
60
+ value ? default.merge({ label => value }) : default
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,15 @@
1
+ module WhoAPI
2
+ class Error < StandardError
3
+ attr_reader :status, :status_desc
4
+
5
+ def initialize(status, status_desc)
6
+ @status = status
7
+ @status_desc = status_desc
8
+ end
9
+
10
+ def message
11
+ "Error code: #{@status} - #{@status_desc}"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,43 @@
1
+ module WhoAPI
2
+ class Request
3
+ include WhoAPI::Symbolize
4
+
5
+ BASE_URL = 'api.whoapi.com'
6
+
7
+ def initialize(type, params)
8
+ @type = type
9
+ @params = params
10
+ end
11
+
12
+ def run
13
+ resp = call
14
+ json = JSON.parse(resp.body)
15
+ check_response(resp, json)
16
+ json.delete('status')
17
+ symbolize_recursive(json)
18
+ end
19
+
20
+ private
21
+
22
+ def call
23
+ HTTParty.get("http://#{BASE_URL}/#{query}")
24
+ end
25
+
26
+ def check_response(resp, json)
27
+ raise WhoAPI::Error.new("HTTP #{resp.code}", json) if resp.code != 200
28
+
29
+ unless json['status'] == '0'
30
+ raise WhoAPI::Error.new(json['status'], json['status_desc'])
31
+ end
32
+ end
33
+
34
+ def query
35
+ @query ||= build_query
36
+ end
37
+
38
+ def build_query
39
+ @params.each_with_object("?r=#{@type}") { |(k, v), q| q << "&#{k}=#{v}" }
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,27 @@
1
+ module WhoAPI
2
+ module Symbolize
3
+ extend self
4
+
5
+ def symbolize_recursive(hash)
6
+ {}.tap do |h|
7
+ hash.each { |key, value| h[key.to_sym] = transform(value) }
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def transform(thing)
14
+ case thing
15
+ when Hash; symbolize_recursive(thing)
16
+ when Array; thing.map { |v| transform(v) }
17
+ else; thing
18
+ end
19
+ end
20
+
21
+ refine Hash do
22
+ def deep_symbolize_keys
23
+ SymbolizeHelper.symbolize_recursive(self)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module WhoAPI
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'whoapi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "whoapi"
8
+ spec.version = WhoAPI::VERSION
9
+ spec.authors = ["Thibault Denizet"]
10
+
11
+ spec.summary = %q{Wrapper for the WhoAPI service.}
12
+ spec.description = %q{WhoAPI.com offers a range of services allowing the querying of domain name data. Track everything and never miss a renewal anymore (domain name, certificates, blacklists, etc).}
13
+ spec.homepage = "https://github.com/whoapi/whoapi-ruby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "httparty", "~> 0.13.7"
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "webmock", "~> 1.22"
26
+ spec.add_development_dependency "vcr", "~> 3.0"
27
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whoapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Thibault Denizet
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.7
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.22'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.22'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: WhoAPI.com offers a range of services allowing the querying of domain
98
+ name data. Track everything and never miss a renewal anymore (domain name, certificates,
99
+ blacklists, etc).
100
+ email:
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - CODE_OF_CONDUCT.md
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - lib/whoapi.rb
116
+ - lib/whoapi/client.rb
117
+ - lib/whoapi/error.rb
118
+ - lib/whoapi/request.rb
119
+ - lib/whoapi/symbolize.rb
120
+ - lib/whoapi/version.rb
121
+ - whoapi.gemspec
122
+ homepage: https://github.com/whoapi/whoapi-ruby
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.4.8
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Wrapper for the WhoAPI service.
146
+ test_files: []