Class: RavenTools::Client
- Inherits:
-
Object
- Object
- RavenTools::Client
- Defined in:
- lib/rb_raventools/client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
- #domain_info(domain) ⇒ Object
- #domains ⇒ Object
- #engines ⇒ Object
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
- #keyword_info(domain, keyword) ⇒ Object
- #keywords(domain) ⇒ Object
- #keywords_with_tags(domain) ⇒ Object
- #profile_info ⇒ Object
- #tag_info(domain, tag) ⇒ Object
- #tags(domain) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 |
# File 'lib/rb_raventools/client.rb', line 10 def initialize(api_key) @@api_key = api_key @@format = "json" self.api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/rb_raventools/client.rb', line 8 def api_key @api_key end |
Instance Method Details
#domain_info(domain) ⇒ Object
31 32 33 34 |
# File 'lib/rb_raventools/client.rb', line 31 def domain_info(domain) response = HTTParty.get(RavenTools::Address.build("domain_info", { domain: domain })) JSON.parse(response.body) end |
#domains ⇒ Object
26 27 28 29 |
# File 'lib/rb_raventools/client.rb', line 26 def domains response = HTTParty.get(RavenTools::Address.build("domains")) JSON.parse(response.body) end |
#engines ⇒ Object
21 22 23 24 |
# File 'lib/rb_raventools/client.rb', line 21 def engines response = HTTParty.get(RavenTools::Address.build("engines")) JSON.parse(response.body) end |
#keyword_info(domain, keyword) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rb_raventools/client.rb', line 41 def keyword_info(domain, keyword) method = "keywords_tags" response = HTTParty.get(RavenTools::Address.build(method, { domain: domain })) parsed_response = JSON.parse(response.body) keyword_info = [{ keyword: keyword }] parsed_response.each do |keywords| if keywords['keyword'] == keyword keyword_info << { tags: keywords['tags'].to_a } end end return keyword_info end |
#keywords(domain) ⇒ Object
36 37 38 39 |
# File 'lib/rb_raventools/client.rb', line 36 def keywords(domain) response = HTTParty.get(RavenTools::Address.build("keywords", { domain: domain })) JSON.parse(response.body) end |
#keywords_with_tags(domain) ⇒ Object
54 55 56 57 |
# File 'lib/rb_raventools/client.rb', line 54 def (domain) response = HTTParty.get(RavenTools::Address.build("keywords_tags", { domain: domain })) JSON.parse(response.body) end |
#profile_info ⇒ Object
16 17 18 19 |
# File 'lib/rb_raventools/client.rb', line 16 def profile_info response = HTTParty.get(RavenTools::Address.build("profile_info")) JSON.parse(response.body) end |
#tag_info(domain, tag) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/rb_raventools/client.rb', line 77 def tag_info(domain, tag) method = "keywords_tags" response = HTTParty.get(RavenTools::Address.build(method, { domain: domain })) parsed_response = JSON.parse(response.body) tag_info = [{ tag: tag }] keyword_list = [] parsed_response.each do |keywords| tag_list = keywords['tags'].to_a if tag_list.include? tag keyword_list << keywords['keyword'] end end tag_info << { keywords: keyword_list } return tag_info end |
#tags(domain) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rb_raventools/client.rb', line 59 def (domain) method = "keywords_tags" response = HTTParty.get(RavenTools::Address.build(method, { domain: domain })) parsed_response = JSON.parse(response.body) = [] parsed_response.each do |keywords| tag_list = keywords['tags'].to_a unless tag_list.size < 1 tag_list.each do |tag| unless .include? tag << tag end end end end return end |