Class: Yandex::Webmaster::Hosts::Verification
- Defined in:
- lib/yandex-webmaster/hosts/verification.rb
Constant Summary collapse
- STATES =
[ 'in_progress', 'never_verified', 'verification_failed', 'verified', 'waiting' ].freeze
- CHECKABLE_TYPES =
[ 'dns_record', 'html_file', 'meta_tag', 'txt_file', 'whois' ].freeze
- NON_CHECKABLE_TYPES =
[ 'auto', 'manual', 'pdd', 'pdd_external', 'delegation' ].freeze
- TYPES =
(CHECKABLE_TYPES + NON_CHECKABLE_TYPES).flatten.freeze
Constants included from Request
Request::METHODS, Request::METHODS_WITH_BODIES
Constants included from Connection
Connection::ACCEPT, Connection::ACCEPT_CHARSET, Connection::ALLOWED_OPTIONS, Connection::CONTENT_TYPE, Connection::USER_AGENT
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
Attributes inherited from Base
Attributes included from Authorization
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Verification
constructor
A new instance of Verification.
- #run(type) ⇒ Object
- #verified? ⇒ Boolean
Methods inherited from Base
#attributes=, const_missing, define_attributes, #method_missing
Methods included from Request
#delete_request, #get_request, #post_request, #put_request, #request
Methods included from Connection
Methods included from Authorization
#auth_code, #authenticate, #authenticated?, #authorize_url, #oauth, #token
Constructor Details
#initialize(attributes = {}) ⇒ Verification
Returns a new instance of Verification.
46 47 48 49 50 |
# File 'lib/yandex-webmaster/hosts/verification.rb', line 46 def initialize(attributes = {}) super(attributes) self.state ||= 'never_verified' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Yandex::Webmaster::Base
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
44 45 46 |
# File 'lib/yandex-webmaster/hosts/verification.rb', line 44 def host @host end |
Instance Method Details
#run(type) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/yandex-webmaster/hosts/verification.rb', line 58 def run(type) raise ArgumentError if !CHECKABLE_TYPES.include?(type.to_s.underscore.downcase) # data = XML::Document.string("<host><type>#{type.underscore.upcase}</type></host>").to_s data = "<host><type>#{type.to_s.underscore.upcase}</type></host>" response = self.request(:put, self.host.resources[:verify_host], :data => data) # return true if response.status.to_i == 204 end |
#verified? ⇒ Boolean
54 55 56 |
# File 'lib/yandex-webmaster/hosts/verification.rb', line 54 def verified? self.state == 'verified' end |